jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r156056 - in incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config: AbstractConfig.java AccessManagerConfig.java ConfigurationParser.java PersistenceManagerConfig.java RepositoryConfig.java SearchConfig.java VersioningConfig.java WorkspaceConfig.java
Date Thu, 03 Mar 2005 16:16:06 GMT
Author: jukka
Date: Thu Mar  3 08:16:02 2005
New Revision: 156056

URL: http://svn.apache.org/viewcvs?view=rev&rev=156056
Log:
Refactoring step 2 (JCR-53)
 - Started XML parser class ConfigurationParser
 - Moved AbstractConfig.replaceVars to ConfigurationParser
 - Moved AbstractConfig.createFileSystem to ConfigurationParser
 - Moved simple XML parsing methods to ConfigurationParser

Added:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/ConfigurationParser.java
Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/AbstractConfig.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/AccessManagerConfig.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/PersistenceManagerConfig.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/RepositoryConfig.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/SearchConfig.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/VersioningConfig.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/WorkspaceConfig.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/AbstractConfig.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/AbstractConfig.java?view=diff&r1=156055&r2=156056
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/AbstractConfig.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/AbstractConfig.java
Thu Mar  3 08:16:02 2005
@@ -16,23 +16,17 @@
  */
 package org.apache.jackrabbit.core.config;
 
-import org.apache.commons.collections.BeanMap;
-import org.apache.jackrabbit.core.fs.FileSystem;
-import org.apache.jackrabbit.core.util.Text;
+import java.io.IOException;
+
+import javax.jcr.RepositoryException;
+
 import org.apache.log4j.Logger;
 import org.jdom.Document;
-import org.jdom.Element;
 import org.jdom.input.SAXBuilder;
 import org.xml.sax.EntityResolver;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 
-import javax.jcr.RepositoryException;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
 /**
  * <code>AbstractConfig</code> is the superclass of
  * <code>RepositoryConfig</code> and <code>WorkspaceConfig</code>.
@@ -69,67 +63,6 @@
             log.debug(msg);
             throw new RepositoryException(msg, e);
         }
-    }
-
-    /**
-     * Creates a {@link org.apache.jackrabbit.core.fs.FileSystem} instance
-     * based on the config <code>fsConfig</code>.
-     *
-     * @param fsConfig  a {@link #FILE_SYSTEM_ELEMENT}.
-     * @param variables values of variables to be replaced in config.
-     * @return a {@link org.apache.jackrabbit.core.fs.FileSystem} instance.
-     * @throws RepositoryException if an error occurs while creating the
-     *                             {@link org.apache.jackrabbit.core.fs.FileSystem}.
-     */
-    static FileSystem createFileSystem(Element fsConfig, Map variables)
-            throws RepositoryException {
-        FileSystem fs;
-        String className = "";
-        try {
-            // create the file system object
-            className = fsConfig.getAttributeValue(CLASS_ATTRIB);
-            Class c = Class.forName(className);
-            fs = (FileSystem) c.newInstance();
-
-            // set the properties of the file system object from the
-            // param elements in the config
-            BeanMap bm = new BeanMap(fs);
-            List paramList = fsConfig.getChildren(PARAM_ELEMENT);
-            for (Iterator i = paramList.iterator(); i.hasNext();) {
-                Element param = (Element) i.next();
-                String paramName = param.getAttributeValue(NAME_ATTRIB);
-                String paramValue = param.getAttributeValue(VALUE_ATTRIB);
-                // replace variables in param value
-                bm.put(paramName, replaceVars(paramValue, variables));
-            }
-            fs.init();
-        } catch (Exception e) {
-            String msg = "Cannot instantiate implementing class " + className;
-            log.debug(msg);
-            throw new RepositoryException(msg, e);
-        }
-        return fs;
-    }
-
-    /**
-     * Helper method that replaces in the given string any occurences of the keys
-     * in the specified map with their associated values.
-     *
-     * @param s
-     * @param vars
-     * @return
-     */
-    protected static String replaceVars(String s, Map vars) {
-        if (vars.size() == 0) {
-            return s;
-        }
-        Iterator iter = vars.keySet().iterator();
-        while (iter.hasNext()) {
-            String varName = (String) iter.next();
-            String varValue = (String) vars.get(varName);
-            s = Text.replace(s, varName, varValue);
-        }
-        return s;
     }
 
     //-------------------------------------------------------< EntityResolver >

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/AccessManagerConfig.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/AccessManagerConfig.java?view=diff&r1=156055&r2=156056
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/AccessManagerConfig.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/AccessManagerConfig.java
Thu Mar  3 08:16:02 2005
@@ -16,13 +16,8 @@
  */
 package org.apache.jackrabbit.core.config;
 
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
 import java.util.Properties;
 
-import org.jdom.Element;
-
 /**
  * A <code>AccessManagerConfig</code> represents the configuration of an
  * <code>AccessManager</code>.
@@ -31,33 +26,6 @@
  */
 public class AccessManagerConfig extends BeanConfig {
 
-    private static final String CLASS_ATTRIB = "class";
-
-    /**
-     * Creates a new <code>PersistenceManagerConfig</code>.
-     *
-     * @param config the config root element for this <code>PersistenceManagerConfig</code>.
-     * @param vars   map of variable values.
-     */
-    static AccessManagerConfig parse(Element config, Map vars) {
-        // FQN of persistence manager class
-        String className = config.getAttributeValue(CLASS_ATTRIB);
-
-        // read the PersistenceManager properties from the
-        // <param/> elements in the config
-        Properties params = new Properties();
-        List paramList = config.getChildren(AbstractConfig.PARAM_ELEMENT);
-        for (Iterator i = paramList.iterator(); i.hasNext();) {
-            Element param = (Element) i.next();
-            String paramName = param.getAttributeValue(AbstractConfig.NAME_ATTRIB);
-            String paramValue = param.getAttributeValue(AbstractConfig.VALUE_ATTRIB);
-            // replace variables in param value
-            params.put(paramName, AbstractConfig.replaceVars(paramValue, vars));
-        }
-        
-        return new AccessManagerConfig(className, params);
-    }
-    
     public AccessManagerConfig(String className, Properties properties) {
         super(className, properties);
     }

Added: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/ConfigurationParser.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/ConfigurationParser.java?view=auto&rev=156056
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/ConfigurationParser.java
(added)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/ConfigurationParser.java
Thu Mar  3 08:16:02 2005
@@ -0,0 +1,203 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.core.config;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.jcr.RepositoryException;
+
+import org.apache.commons.collections.BeanMap;
+import org.apache.jackrabbit.core.fs.FileSystem;
+import org.apache.jackrabbit.core.util.Text;
+import org.jdom.Element;
+
+/**
+ * TODO
+ */
+public class ConfigurationParser {
+
+    private static final String CLASS_ATTRIBUTE = "class";
+
+    private static final String PARAM_ELEMENT = "param";
+    private static final String NAME_ATTRIBUTE = "name";
+    private static final String VALUE_ATTRIBUTE = "value";
+
+    /** attribute name of home dir */
+    private static final String ROOTPATH_ATTRIBUTE = "rootPath";
+
+
+    /** FQN of the default query handler implementation */
+    private static final String DEFAULT_QUERY_HANDLER
+            = "org.apache.jackrabbit.core.search.lucene.SearchIndex";
+
+    private Map variables;
+
+    public ConfigurationParser(Map variables) {
+        this.variables = variables;
+    }
+
+    /**
+     * Creates a new <code>PersistenceManagerConfig</code>.
+     *
+     * @param config the config root element for this <code>PersistenceManagerConfig</code>.
+     */
+    public AccessManagerConfig parseAccessManagerConfig(Element config) {
+        // FQN of persistence manager class
+        String className = config.getAttributeValue(CLASS_ATTRIBUTE);
+
+        // read the PersistenceManager properties from the
+        // <param/> elements in the config
+        Properties params = parseParameters(config);
+
+        return new AccessManagerConfig(className, params);
+    }
+
+    /**
+     * Creates a new <code>PersistenceManagerConfig</code>.
+     *
+     * @param config the config root element for this <code>PersistenceManagerConfig</code>.
+     */
+    public PersistenceManagerConfig parsePersistenceManagerConfig(Element config) {
+        // FQN of persistence manager class
+        String className = config.getAttributeValue(CLASS_ATTRIBUTE);
+
+        // read the PersistenceManager properties from the
+        // <param/> elements in the config
+        Properties params = parseParameters(config);
+
+        return new PersistenceManagerConfig(className, params);
+    }
+
+    /**
+     * Creates a new <code>SearchConfig</code>.
+     * @param config the config root element for this <code>SearchConfig</code>.
+     * @throws RepositoryException if an error occurs while creating the
+     *  <code>SearchConfig</code>.
+     */
+    public SearchConfig parseSearchConfig(Element config) throws RepositoryException {
+        // create FileSystem
+        Element fsElement = config.getChild(AbstractConfig.FILE_SYSTEM_ELEMENT);
+        FileSystem fs = createFileSystem(fsElement);
+
+        // handler class name
+        String handlerClassName = config.getAttributeValue(CLASS_ATTRIBUTE,
+                DEFAULT_QUERY_HANDLER);
+
+        // gather params
+        Properties params = parseParameters(config);
+
+        return new SearchConfig(fs, handlerClassName, params);
+    }
+
+    /**
+     * Creates a new <code>VersioningConfig</code>.
+     * @param config the config root element for this <code>VersioningConfig</code>.
+     * @param vars map of variable values.
+     * @throws RepositoryException if an error occurs while creating the
+     *  <code>SearchConfig</code>.
+     */
+    public VersioningConfig parseVersioningConfig(Element config) throws RepositoryException
{
+        // home dir
+        File homeDir = new File(replaceVariables(config.getAttributeValue(ROOTPATH_ATTRIBUTE)));
+
+        // create FileSystem
+        Element fsElement = config.getChild(AbstractConfig.FILE_SYSTEM_ELEMENT);
+        FileSystem fs = createFileSystem(fsElement);
+
+        // persistence manager config
+        Element pmElem = config.getChild(WorkspaceConfig.PERSISTENCE_MANAGER_ELEMENT);
+        PersistenceManagerConfig pmConfig =
+            parsePersistenceManagerConfig(pmElem);
+
+        return new VersioningConfig(homeDir, fs, pmConfig);
+    }
+
+    public Properties parseParameters(Element element) {
+        Properties parameters = new Properties();
+
+        Iterator iterator = element.getChildren(PARAM_ELEMENT).iterator();
+        while (iterator.hasNext()) {
+            Element parameter = (Element) iterator.next();
+            String name = parameter.getAttributeValue(NAME_ATTRIBUTE);
+            String value = parameter.getAttributeValue(VALUE_ATTRIBUTE);
+            // replace variables in param value
+            parameters.put(name, replaceVariables(value));
+        }
+
+        return parameters;
+    }
+
+    /**
+     * Creates a {@link org.apache.jackrabbit.core.fs.FileSystem} instance
+     * based on the config <code>fsConfig</code>.
+     *
+     * @param fsConfig  a {@link #FILE_SYSTEM_ELEMENT}.
+     * @return a {@link org.apache.jackrabbit.core.fs.FileSystem} instance.
+     * @throws RepositoryException if an error occurs while creating the
+     *                             {@link org.apache.jackrabbit.core.fs.FileSystem}.
+     */
+    public FileSystem createFileSystem(Element fsConfig) throws RepositoryException {
+        FileSystem fs;
+        String className = "";
+        try {
+            // create the file system object
+            className = fsConfig.getAttributeValue(CLASS_ATTRIBUTE);
+            Class c = Class.forName(className);
+            fs = (FileSystem) c.newInstance();
+
+            // set the properties of the file system object from the
+            // param elements in the config
+            BeanMap bm = new BeanMap(fs);
+            List paramList = fsConfig.getChildren(PARAM_ELEMENT);
+            for (Iterator i = paramList.iterator(); i.hasNext();) {
+                Element param = (Element) i.next();
+                String paramName = param.getAttributeValue(NAME_ATTRIBUTE);
+                String paramValue = param.getAttributeValue(VALUE_ATTRIBUTE);
+                // replace variables in param value
+                bm.put(paramName, replaceVariables(paramValue));
+            }
+            fs.init();
+        } catch (Exception e) {
+            String msg = "Cannot instantiate implementing class " + className;
+            throw new RepositoryException(msg, e);
+        }
+        return fs;
+    }
+
+    /**
+     * Helper method that replaces in the given string any occurences of the keys
+     * in the specified map with their associated values.
+     *
+     * @param s
+     * @param vars
+     * @return
+     */
+    public String replaceVariables(String value) {
+        Iterator iterator = variables.keySet().iterator();
+        while (iterator.hasNext()) {
+            String varName = (String) iterator.next();
+            String varValue = (String) variables.get(varName);
+            value = Text.replace(value, varName, varValue);
+        }
+        return value;
+    }
+
+}

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/PersistenceManagerConfig.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/PersistenceManagerConfig.java?view=diff&r1=156055&r2=156056
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/PersistenceManagerConfig.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/PersistenceManagerConfig.java
Thu Mar  3 08:16:02 2005
@@ -16,13 +16,8 @@
  */
 package org.apache.jackrabbit.core.config;
 
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
 import java.util.Properties;
 
-import org.jdom.Element;
-
 /**
  * A <code>PersistenceManagerConfig</code> represents the configuration of a
  * <code>PersistenceManager</code>.
@@ -30,33 +25,6 @@
  * @see WorkspaceConfig#getPersistenceManagerConfig()
  */
 public class PersistenceManagerConfig extends BeanConfig {
-
-    private static final String CLASS_ATTRIB = "class";
-
-    /**
-     * Creates a new <code>PersistenceManagerConfig</code>.
-     *
-     * @param config the config root element for this <code>PersistenceManagerConfig</code>.
-     * @param vars   map of variable values.
-     */
-    static PersistenceManagerConfig parse(Element config, Map vars) {
-        // FQN of persistence manager class
-        String className = config.getAttributeValue(CLASS_ATTRIB);
-
-        // read the PersistenceManager properties from the
-        // <param/> elements in the config
-        Properties params = new Properties();
-        List paramList = config.getChildren(AbstractConfig.PARAM_ELEMENT);
-        for (Iterator i = paramList.iterator(); i.hasNext();) {
-            Element param = (Element) i.next();
-            String paramName = param.getAttributeValue(AbstractConfig.NAME_ATTRIB);
-            String paramValue = param.getAttributeValue(AbstractConfig.VALUE_ATTRIB);
-            // replace variables in param value
-            params.put(paramName, AbstractConfig.replaceVars(paramValue, vars));
-        }
-
-        return new PersistenceManagerConfig(className, params);
-    }
 
     public PersistenceManagerConfig(String className, Properties properties) {
         super(className, properties);

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/RepositoryConfig.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/RepositoryConfig.java?view=diff&r1=156055&r2=156056
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/RepositoryConfig.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/RepositoryConfig.java
Thu Mar  3 08:16:02 2005
@@ -140,20 +140,22 @@
      * @throws RepositoryException
      */
     protected void init(Document config) throws RepositoryException {
+        ConfigurationParser parser = new ConfigurationParser(vars);
+
         // file system
         Element fsConfig = config.getRootElement().getChild(FILE_SYSTEM_ELEMENT);
-        repFS = createFileSystem(fsConfig, vars);
+        repFS = parser.createFileSystem(fsConfig);
 
         // security & access manager config
         Element secEleme = config.getRootElement().getChild(SECURITY_ELEMENT);
         appName = secEleme.getAttributeValue(APP_NAME_ATTRIB);
         Element amElem = secEleme.getChild(ACCESS_MANAGER_ELEMENT);
-        amConfig = AccessManagerConfig.parse(amElem, vars);
+        amConfig = parser.parseAccessManagerConfig(amElem);
 
         // workspaces
         Element wspsElem = config.getRootElement().getChild(WORKSPACES_ELEMENT);
-        wspConfigRootDir = replaceVars(wspsElem.getAttributeValue(ROOT_PATH_ATTRIB), vars);
-        defaultWspName = replaceVars(wspsElem.getAttributeValue(DEFAULT_WORKSPACE_ATTRIB),
vars);
+        wspConfigRootDir = parser.replaceVariables(wspsElem.getAttributeValue(ROOT_PATH_ATTRIB));
+        defaultWspName = parser.replaceVariables(wspsElem.getAttributeValue(DEFAULT_WORKSPACE_ATTRIB));
 
         // load wsp configs
         File wspRoot = new File(wspConfigRootDir);
@@ -194,7 +196,7 @@
 
         // load versioning config
         Element vElement = config.getRootElement().getChild(VERSIONING_ELEMENT);
-        vConfig = new VersioningConfig(vElement, vars);
+        vConfig = parser.parseVersioningConfig(vElement);
     }
 
     /**

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/SearchConfig.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/SearchConfig.java?view=diff&r1=156055&r2=156056
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/SearchConfig.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/SearchConfig.java
Thu Mar  3 08:16:02 2005
@@ -16,57 +16,17 @@
  */
 package org.apache.jackrabbit.core.config;
 
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
 import java.util.Properties;
 
-import javax.jcr.RepositoryException;
-
 import org.apache.jackrabbit.core.fs.FileSystem;
-import org.jdom.Element;
 
 /**
  * Implements the search configuration.
  */
 public class SearchConfig extends BeanConfig {
 
-    /** FQN of the default query handler implementation */
-    private static final String DEFAULT_QUERY_HANDLER
-            = "org.apache.jackrabbit.core.search.lucene.SearchIndex";
-
     /** The <code>FileSystem</code> for the search index. */
     private final FileSystem fs;
-
-    /**
-     * Creates a new <code>SearchConfig</code>.
-     * @param config the config root element for this <code>SearchConfig</code>.
-     * @param vars map of variable values.
-     * @throws RepositoryException if an error occurs while creating the
-     *  <code>SearchConfig</code>.
-     */
-    static SearchConfig parse(Element config, Map vars) throws RepositoryException {
-        // create FileSystem
-        Element fsElement = config.getChild(AbstractConfig.FILE_SYSTEM_ELEMENT);
-        FileSystem fs = AbstractConfig.createFileSystem(fsElement, vars);
-
-        // gather params
-        Properties params = new Properties();
-        List paramList = config.getChildren(AbstractConfig.PARAM_ELEMENT);
-        for (Iterator i = paramList.iterator(); i.hasNext();) {
-            Element param = (Element) i.next();
-            String paramName = param.getAttributeValue(AbstractConfig.NAME_ATTRIB);
-            String paramValue = param.getAttributeValue(AbstractConfig.VALUE_ATTRIB);
-            // replace variables in param value
-            params.put(paramName, AbstractConfig.replaceVars(paramValue, vars));
-        }
-
-        // handler class name
-        String handlerClassName = config.getAttributeValue(AbstractConfig.CLASS_ATTRIB,
-                DEFAULT_QUERY_HANDLER);
-
-        return new SearchConfig(fs, handlerClassName, params);
-    }
 
     public SearchConfig(FileSystem fs, String className, Properties properties) {
         super(className, properties);

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/VersioningConfig.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/VersioningConfig.java?view=diff&r1=156055&r2=156056
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/VersioningConfig.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/VersioningConfig.java
Thu Mar  3 08:16:02 2005
@@ -17,21 +17,14 @@
 package org.apache.jackrabbit.core.config;
 
 import java.io.File;
-import java.util.Map;
-
-import javax.jcr.RepositoryException;
 
 import org.apache.jackrabbit.core.fs.FileSystem;
-import org.jdom.Element;
 
 /**
  * This Class implements the configuration object for the versioning.
  */
 public class VersioningConfig {
 
-    /** attribute name of home dir */
-    private static final String ROOTPATH_ATTRIB = "rootPath";
-
     /** the homedir for the versioning */
     private final File homeDir;
 
@@ -41,27 +34,12 @@
     /** The <code>PersistenceManagerConfig</code> for the versioning */
     private final PersistenceManagerConfig pmConfig;
 
-    /**
-     * Creates a new <code>VersioningConfig</code>.
-     * @param config the config root element for this <code>VersioningConfig</code>.
-     * @param vars map of variable values.
-     * @throws RepositoryException if an error occurs while creating the
-     *  <code>SearchConfig</code>.
-     */
-    VersioningConfig(Element config, Map vars) throws RepositoryException {
-
-        // home dir
-        homeDir = new File(AbstractConfig.replaceVars(config.getAttributeValue(ROOTPATH_ATTRIB),
vars));
-
-        // create FileSystem
-        Element fsElement = config.getChild(AbstractConfig.FILE_SYSTEM_ELEMENT);
-        this.fs = AbstractConfig.createFileSystem(fsElement, vars);
-
-        // persistence manager config
-        Element pmElem = config.getChild(WorkspaceConfig.PERSISTENCE_MANAGER_ELEMENT);
-        pmConfig = PersistenceManagerConfig.parse(pmElem, vars);
+    public VersioningConfig(File homeDir, FileSystem fs, PersistenceManagerConfig pmc) {
+        this.homeDir = homeDir;
+        this.fs = fs;
+        this.pmConfig = pmc;
     }
-
+    
     /**
      * Returns the virtual file system where the workspace stores global state.
      *

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/WorkspaceConfig.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/WorkspaceConfig.java?view=diff&r1=156055&r2=156056
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/WorkspaceConfig.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/WorkspaceConfig.java
Thu Mar  3 08:16:02 2005
@@ -28,6 +28,7 @@
 import java.io.FileReader;
 import java.io.IOException;
 import java.util.HashMap;
+import java.util.Properties;
 
 /**
  * A <code>WorkspaceConfig</code> ...
@@ -55,7 +56,7 @@
     public static final String WORKSPACE_HOME_VARIABLE = "${wsp.home}";
     public static final String WORKSPACE_NAME_VARIABLE = "${wsp.name}";
 
-    private final HashMap vars;
+    private final Properties vars;
 
     /**
      * workspace home directory
@@ -94,7 +95,7 @@
         super(is);
         this.wspHomeDir = wspHomeDir;
         // initialize variables
-        vars = new HashMap();
+        vars = new Properties();
         vars.put(WORKSPACE_HOME_VARIABLE, wspHomeDir);
         // read config
         init(config);
@@ -114,24 +115,26 @@
             // init with wsp home dirname
             wspName = new File(wspHomeDir).getName();
         } else {
-            wspName = replaceVars(wspName, vars);
+            ConfigurationParser parser = new ConfigurationParser(vars);
+            wspName = parser.replaceVariables(wspName);
         }
-        
+
         // set name variable
         vars.put(WORKSPACE_NAME_VARIABLE, wspName);
+        ConfigurationParser parser = new ConfigurationParser(vars);
 
         // file system
         Element fsElem = wspElem.getChild(FILE_SYSTEM_ELEMENT);
-        wspFS = createFileSystem(fsElem, vars);
+        wspFS = parser.createFileSystem(fsElem);
 
         // persistence manager config
         Element pmElem = wspElem.getChild(PERSISTENCE_MANAGER_ELEMENT);
-        pmConfig = PersistenceManagerConfig.parse(pmElem, vars);
+        pmConfig = parser.parsePersistenceManagerConfig(pmElem);
 
         // search config (optional)
         Element searchElem = wspElem.getChild(SEARCH_INDEX_ELEMENT);
         if (searchElem != null) {
-            searchConfig = SearchConfig.parse(searchElem, vars);
+            searchConfig = parser.parseSearchConfig(searchElem);
         }
     }
 



Mime
View raw message