jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r156047 - in incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config: AccessManagerConfig.java BeanConfig.java PersistenceManagerConfig.java RepositoryConfig.java SearchConfig.java VersioningConfig.java WorkspaceConfig.java
Date Thu, 03 Mar 2005 15:09:49 GMT
Author: jukka
Date: Thu Mar  3 07:09:46 2005
New Revision: 156047

URL: http://svn.apache.org/viewcvs?view=rev&rev=156047
Log:
Refactoring step 1 (JCR-53)
 - Moved common configuration fields to a new BeanConfig base class
 - Moved XML parsing to static factory methods

Added:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/BeanConfig.java
Modified:
    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/AccessManagerConfig.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/AccessManagerConfig.java?view=diff&r1=156046&r2=156047
==============================================================================
--- 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 07:09:46 2005
@@ -16,13 +16,12 @@
  */
 package org.apache.jackrabbit.core.config;
 
-import org.jdom.Element;
-
-import java.util.Collections;
-import java.util.HashMap;
 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
@@ -30,33 +29,23 @@
  *
  * @see RepositoryConfig#getAccessManagerConfig()
  */
-public class AccessManagerConfig {
+public class AccessManagerConfig extends BeanConfig {
 
     private static final String CLASS_ATTRIB = "class";
 
     /**
-     * FQN of class implementing the <code>AccessManager</code> interface
-     */
-    private final String className;
-
-    /**
-     * Parameters for configuring the persistence manager.
-     */
-    private final Map params;
-
-    /**
      * Creates a new <code>PersistenceManagerConfig</code>.
      *
      * @param config the config root element for this <code>PersistenceManagerConfig</code>.
      * @param vars   map of variable values.
      */
-    AccessManagerConfig(Element config, Map vars) {
+    static AccessManagerConfig parse(Element config, Map vars) {
         // FQN of persistence manager class
-        className = config.getAttributeValue(CLASS_ATTRIB);
+        String className = config.getAttributeValue(CLASS_ATTRIB);
 
         // read the PersistenceManager properties from the
         // <param/> elements in the config
-        Map params = new HashMap();
+        Properties params = new Properties();
         List paramList = config.getChildren(AbstractConfig.PARAM_ELEMENT);
         for (Iterator i = paramList.iterator(); i.hasNext();) {
             Element param = (Element) i.next();
@@ -65,26 +54,12 @@
             // replace variables in param value
             params.put(paramName, AbstractConfig.replaceVars(paramValue, vars));
         }
-        this.params = Collections.unmodifiableMap(params);
+        
+        return new AccessManagerConfig(className, params);
     }
-
-    /**
-     * Returns configuration parameters. Each entry in the map represents
-     * a name/value pair where both name and value are <code>String</code>s.
-     *
-     * @return Map of configuration parameters.
-     */
-    public Map getParameters() {
-        return params;
-    }
-
-    /**
-     * Returns the FQN of a class implementing the <code>PersistenceManager</code>
interface
-     *
-     * @return FQN of persistence manager class
-     */
-    public String getClassName() {
-        return className;
+    
+    public AccessManagerConfig(String className, Properties properties) {
+        super(className, properties);
     }
 
 }

Added: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/BeanConfig.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/BeanConfig.java?view=auto&rev=156047
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/BeanConfig.java
(added)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/BeanConfig.java
Thu Mar  3 07:09:46 2005
@@ -0,0 +1,67 @@
+/*
+ * 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.util.Properties;
+
+/**
+ * Bean configuration class. BeanConfig instances contain the class name
+ * and property information required to instantiate a class that conforms
+ * with the JavaBean conventions.
+ */
+public class BeanConfig {
+
+    /**
+     * The class name of the configured bean.
+     */
+    private String className;
+
+    /**
+     * The initial properties of the configured bean.
+     */
+    private Properties properties;
+
+    /**
+     * Creates a bean configuration.
+     *
+     * @param className class name of the bean
+     * @param properties initial properties of the bean
+     */
+    protected BeanConfig(String className, Properties properties) {
+        this.className = className;
+        this.properties = properties;
+    }
+
+    /**
+     * Returns the class name of the configured bean.
+     *
+     * @return class name of the bean
+     */
+    public String getClassName() {
+        return className;
+    }
+
+    /**
+     * Returns the initial properties of the configured bean.
+     *
+     * @return initial properties of the bean
+     */
+    public Properties getParameters() {
+        return properties;
+    }
+
+}

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=156046&r2=156047
==============================================================================
--- 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 07:09:46 2005
@@ -16,9 +16,12 @@
  */
 package org.apache.jackrabbit.core.config;
 
-import org.jdom.Element;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
 
-import java.util.*;
+import org.jdom.Element;
 
 /**
  * A <code>PersistenceManagerConfig</code> represents the configuration of a
@@ -26,33 +29,23 @@
  *
  * @see WorkspaceConfig#getPersistenceManagerConfig()
  */
-public class PersistenceManagerConfig {
+public class PersistenceManagerConfig extends BeanConfig {
 
     private static final String CLASS_ATTRIB = "class";
 
     /**
-     * FQN of class implementing the <code>PersistenceManager</code> interface
-     */
-    private final String className;
-
-    /**
-     * Parameters for configuring the persistence manager.
-     */
-    private final Map params;
-
-    /**
      * Creates a new <code>PersistenceManagerConfig</code>.
      *
      * @param config the config root element for this <code>PersistenceManagerConfig</code>.
      * @param vars   map of variable values.
      */
-    PersistenceManagerConfig(Element config, Map vars) {
+    static PersistenceManagerConfig parse(Element config, Map vars) {
         // FQN of persistence manager class
-        className = config.getAttributeValue(CLASS_ATTRIB);
+        String className = config.getAttributeValue(CLASS_ATTRIB);
 
         // read the PersistenceManager properties from the
         // <param/> elements in the config
-        Map params = new HashMap();
+        Properties params = new Properties();
         List paramList = config.getChildren(AbstractConfig.PARAM_ELEMENT);
         for (Iterator i = paramList.iterator(); i.hasNext();) {
             Element param = (Element) i.next();
@@ -61,26 +54,12 @@
             // replace variables in param value
             params.put(paramName, AbstractConfig.replaceVars(paramValue, vars));
         }
-        this.params = Collections.unmodifiableMap(params);
-    }
 
-    /**
-     * Returns configuration parameters. Each entry in the map represents
-     * a name/value pair where both name and value are <code>String</code>s.
-     *
-     * @return Map of configuration parameters.
-     */
-    public Map getParameters() {
-        return params;
+        return new PersistenceManagerConfig(className, params);
     }
 
-    /**
-     * Returns the FQN of a class implementing the <code>PersistenceManager</code>
interface
-     *
-     * @return FQN of persistence manager class
-     */
-    public String getClassName() {
-        return className;
+    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=156046&r2=156047
==============================================================================
--- 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 07:09:46 2005
@@ -148,7 +148,7 @@
         Element secEleme = config.getRootElement().getChild(SECURITY_ELEMENT);
         appName = secEleme.getAttributeValue(APP_NAME_ATTRIB);
         Element amElem = secEleme.getChild(ACCESS_MANAGER_ELEMENT);
-        amConfig = new AccessManagerConfig(amElem, vars);
+        amConfig = AccessManagerConfig.parse(amElem, vars);
 
         // workspaces
         Element wspsElem = config.getRootElement().getChild(WORKSPACES_ELEMENT);

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=156046&r2=156047
==============================================================================
--- 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 07:09:46 2005
@@ -16,20 +16,20 @@
  */
 package org.apache.jackrabbit.core.config;
 
-import org.jdom.Element;
-import org.apache.jackrabbit.core.fs.FileSystem;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
 
 import javax.jcr.RepositoryException;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Collections;
-import java.util.List;
-import java.util.Iterator;
+
+import org.apache.jackrabbit.core.fs.FileSystem;
+import org.jdom.Element;
 
 /**
  * Implements the search configuration.
  */
-public class SearchConfig {
+public class SearchConfig extends BeanConfig {
 
     /** FQN of the default query handler implementation */
     private static final String DEFAULT_QUERY_HANDLER
@@ -38,15 +38,6 @@
     /** The <code>FileSystem</code> for the search index. */
     private final FileSystem fs;
 
-    /** Parameters for configuring the search index. */
-    private Map params = new HashMap();
-
-    /**
-     * The FQN of the class implementing the
-     * {@link org.apache.jackrabbit.core.search.QueryHandler} interface.
-     */
-    private final String handlerClassName;
-
     /**
      * Creates a new <code>SearchConfig</code>.
      * @param config the config root element for this <code>SearchConfig</code>.
@@ -54,12 +45,13 @@
      * @throws RepositoryException if an error occurs while creating the
      *  <code>SearchConfig</code>.
      */
-    SearchConfig(Element config, Map vars) throws RepositoryException {
+    static SearchConfig parse(Element config, Map vars) throws RepositoryException {
         // create FileSystem
         Element fsElement = config.getChild(AbstractConfig.FILE_SYSTEM_ELEMENT);
-        this.fs = AbstractConfig.createFileSystem(fsElement, vars);
+        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();
@@ -68,21 +60,17 @@
             // replace variables in param value
             params.put(paramName, AbstractConfig.replaceVars(paramValue, vars));
         }
-        // seal
-        params = Collections.unmodifiableMap(params);
 
         // handler class name
-        handlerClassName = config.getAttributeValue(AbstractConfig.CLASS_ATTRIB, 
+        String handlerClassName = config.getAttributeValue(AbstractConfig.CLASS_ATTRIB,
                 DEFAULT_QUERY_HANDLER);
+
+        return new SearchConfig(fs, handlerClassName, params);
     }
 
-    /**
-     * Returns configuration parameters. Each entry in the map represents
-     * a name value pair. Where both name and values are <code>String</code>s.
-     * @return Map of config parameters.
-     */
-    public Map getParameters() {
-        return params;
+    public SearchConfig(FileSystem fs, String className, Properties properties) {
+        super(className, properties);
+        this.fs = fs;
     }
 
     /**
@@ -100,7 +88,7 @@
      *   interface.
      */
     public String getHandlerClassName() {
-        return handlerClassName;
+        return getClassName();
     }
 
 }

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=156046&r2=156047
==============================================================================
--- 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 07:09:46 2005
@@ -16,12 +16,13 @@
  */
 package org.apache.jackrabbit.core.config;
 
-import org.apache.jackrabbit.core.fs.FileSystem;
-import org.jdom.Element;
+import java.io.File;
+import java.util.Map;
 
 import javax.jcr.RepositoryException;
-import java.util.*;
-import java.io.File;
+
+import org.apache.jackrabbit.core.fs.FileSystem;
+import org.jdom.Element;
 
 /**
  * This Class implements the configuration object for the versioning.
@@ -37,9 +38,6 @@
     /** The <code>FileSystem</code> for the versioing. */
     private final FileSystem fs;
 
-    /** Parameters for configuring the versioning */
-    private Map params = new HashMap();
-
     /** The <code>PersistenceManagerConfig</code> for the versioning */
     private final PersistenceManagerConfig pmConfig;
 
@@ -61,19 +59,7 @@
 
         // persistence manager config
         Element pmElem = config.getChild(WorkspaceConfig.PERSISTENCE_MANAGER_ELEMENT);
-        pmConfig = new PersistenceManagerConfig(pmElem, vars);
-
-        // gather params
-        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));
-        }
-        // seal
-        params = Collections.unmodifiableMap(params);
+        pmConfig = PersistenceManagerConfig.parse(pmElem, vars);
     }
 
     /**

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=156046&r2=156047
==============================================================================
--- 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 07:09:46 2005
@@ -126,12 +126,12 @@
 
         // persistence manager config
         Element pmElem = wspElem.getChild(PERSISTENCE_MANAGER_ELEMENT);
-        pmConfig = new PersistenceManagerConfig(pmElem, vars);
+        pmConfig = PersistenceManagerConfig.parse(pmElem, vars);
 
         // search config (optional)
         Element searchElem = wspElem.getChild(SEARCH_INDEX_ELEMENT);
         if (searchElem != null) {
-            searchConfig = new SearchConfig(searchElem, vars);
+            searchConfig = SearchConfig.parse(searchElem, vars);
         }
     }
 



Mime
View raw message