jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r698161 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: RepositoryImpl.java config/DataStoreConfig.java config/RepositoryConfig.java config/RepositoryConfigurationParser.java data/DataStoreFactory.java
Date Tue, 23 Sep 2008 12:44:17 GMT
Author: jukka
Date: Tue Sep 23 05:44:16 2008
New Revision: 698161

URL: http://svn.apache.org/viewvc?rev=698161&view=rev
Log:
JCR-1438: Replace Config classes with factories

Replaced DataStoreConfig with DataStoreFactory

Added:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/DataStoreFactory.java
  (with props)
Removed:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/DataStoreConfig.java
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfig.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?rev=698161&r1=698160&r2=698161&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
Tue Sep 23 05:44:16 2008
@@ -31,7 +31,6 @@
 import org.apache.jackrabbit.core.cluster.UpdateEventChannel;
 import org.apache.jackrabbit.core.cluster.UpdateEventListener;
 import org.apache.jackrabbit.core.config.ClusterConfig;
-import org.apache.jackrabbit.core.config.DataStoreConfig;
 import org.apache.jackrabbit.core.config.PersistenceManagerConfig;
 import org.apache.jackrabbit.core.config.RepositoryConfig;
 import org.apache.jackrabbit.core.config.SecurityManagerConfig;
@@ -272,11 +271,9 @@
             nsReg = createNamespaceRegistry(new BasedFileSystem(repStore, "/namespaces"));
             ntReg = createNodeTypeRegistry(nsReg, new BasedFileSystem(repStore, "/nodetypes"));
 
-            if (repConfig.getDataStoreConfig() != null) {
+            dataStore = repConfig.getDataStore();
+            if (dataStore != null) {
                 assert InternalValue.USE_DATA_STORE;
-                dataStore = createDataStore();
-            } else {
-                dataStore = null;
             }
 
             // init workspace configs
@@ -694,18 +691,6 @@
         }
     }
 
-    /**
-     * Create a data store object using the data store configuration.
-     *
-     * @return the data store object
-     */
-    protected DataStore createDataStore() throws RepositoryException {
-        DataStoreConfig dsc = repConfig.getDataStoreConfig();
-        DataStore dataStore = (DataStore) dsc.newInstance();
-        dataStore.init(repConfig.getHomeDir());
-        return dataStore;
-    }
-
     protected NamespaceRegistryImpl getNamespaceRegistry() {
         // check sanity of this instance
         sanityCheck();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfig.java?rev=698161&r1=698160&r2=698161&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfig.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfig.java
Tue Sep 23 05:44:16 2008
@@ -17,6 +17,8 @@
 package org.apache.jackrabbit.core.config;
 
 import org.apache.commons.io.IOUtils;
+import org.apache.jackrabbit.core.data.DataStore;
+import org.apache.jackrabbit.core.data.DataStoreFactory;
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.fs.FileSystemException;
 import org.apache.jackrabbit.core.fs.FileSystemFactory;
@@ -61,7 +63,7 @@
  * addition the workspace configuration object keeps track of all configured
  * workspaces.
  */
-public class RepositoryConfig implements FileSystemFactory {
+public class RepositoryConfig implements FileSystemFactory, DataStoreFactory {
 
     /** the default logger */
     private static Logger log = LoggerFactory.getLogger(RepositoryConfig.class);
@@ -221,9 +223,10 @@
     private final ClusterConfig cc;
 
     /**
-     * Optional data store configuration
+     * The optional data store factory, returns <code>null</code> if
+     * the data store is not configured.
      */
-    private final DataStoreConfig dataStoreConfig;
+    private final DataStoreFactory dsf;
 
     /**
      * Creates a repository configuration object.
@@ -239,7 +242,7 @@
      * @param vc versioning configuration
      * @param sc search configuration for system search manager.
      * @param cc optional cluster configuration
-     * @param dataStoreConfig configuration for data store
+     * @param dsf data store factory
      * @param parser configuration parser
      */
     public RepositoryConfig(
@@ -247,7 +250,8 @@
             String workspaceDirectory, String workspaceConfigDirectory,
             String defaultWorkspace, int workspaceMaxIdleTime,
             Element template, VersioningConfig vc, SearchConfig sc,
-            ClusterConfig cc, DataStoreConfig dataStoreConfig, RepositoryConfigurationParser
parser) {
+            ClusterConfig cc, DataStoreFactory dsf,
+            RepositoryConfigurationParser parser) {
         workspaces = new HashMap();
         this.home = home;
         this.sec = sec;
@@ -260,7 +264,7 @@
         this.vc = vc;
         this.sc = sc;
         this.cc = cc;
-        this.dataStoreConfig = dataStoreConfig;
+        this.dsf = dsf;
         this.parser = parser;
     }
 
@@ -754,12 +758,15 @@
     }
 
     /**
-     * Returns the data store configuration. Returns <code>null</code> if data
store
-     * has not been configured.
+     * Creates and returns the configured data store. Returns
+     * <code>null</code> if a data store has not been configured.
+     *
+     * @return the configured data store, or <code>null</code>
+     * @throws RepositoryException if the data store can not be created
      */
-    public DataStoreConfig getDataStoreConfig() {
-        return dataStoreConfig;
+    public DataStore getDataStore() throws RepositoryException {
+        return dsf.getDataStore();
     }
-}
 
+}
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java?rev=698161&r1=698160&r2=698161&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java
Tue Sep 23 05:44:16 2008
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.core.config;
 
+import org.apache.jackrabbit.core.data.DataStore;
+import org.apache.jackrabbit.core.data.DataStoreFactory;
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.fs.FileSystemException;
 import org.apache.jackrabbit.core.fs.FileSystemFactory;
@@ -249,12 +251,12 @@
         // Optional journal configuration
         ClusterConfig cc = parseClusterConfig(root);
 
-        // Optional data store configuration
-        DataStoreConfig dsc = parseDataStoreConfig(root);
+        // Optional data store factory
+        DataStoreFactory dsf = getDataStoreFactory(root, home);
 
         return new RepositoryConfig(home, securityConfig, fsf,
                 workspaceDirectory, workspaceConfigDirectory, defaultWorkspace,
-                maxIdleTime, template, vc, sc, cc, dsc, this);
+                maxIdleTime, template, vc, sc, cc, dsf, this);
     }
 
     /**
@@ -683,19 +685,26 @@
      * @return journal configuration, or <code>null</code>
      * @throws ConfigurationException if the configuration is broken
      */
-    protected DataStoreConfig parseDataStoreConfig(Element parent)
+    protected DataStoreFactory getDataStoreFactory(
+            final Element parent, final String directory)
             throws ConfigurationException {
-        NodeList children = parent.getChildNodes();
-        for (int i = 0; i < children.getLength(); i++) {
-            Node child = children.item(i);
-            if (child.getNodeType() == Node.ELEMENT_NODE
-                    && DATA_STORE_ELEMENT.equals(child.getNodeName())) {
-                DataStoreConfig cfg = new DataStoreConfig(parseBeanConfig(
-                        parent, DATA_STORE_ELEMENT));
-                return cfg;
+        return new DataStoreFactory() {
+            public DataStore getDataStore() throws RepositoryException {
+                NodeList children = parent.getChildNodes();
+                for (int i = 0; i < children.getLength(); i++) {
+                    Node child = children.item(i);
+                    if (child.getNodeType() == Node.ELEMENT_NODE
+                            && DATA_STORE_ELEMENT.equals(child.getNodeName())) {
+                        BeanConfig bc =
+                            parseBeanConfig(parent, DATA_STORE_ELEMENT);
+                        DataStore store = (DataStore) bc.newInstance();
+                        store.init(directory);
+                        return store;
+                    }
+                }
+                return null;
             }
-        }
-        return null;
+        };
     }
 
     /**

Added: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/DataStoreFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/DataStoreFactory.java?rev=698161&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/DataStoreFactory.java
(added)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/DataStoreFactory.java
Tue Sep 23 05:44:16 2008
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.data;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * Factory interface for creating {@link DataStore} instances. Used
+ * to decouple the repository internals from the repository configuration
+ * mechanism.
+ *
+ * @since Jackrabbit 1.5
+ * @see <a href="https://issues.apache.org/jira/browse/JCR-1438">JCR-1438</a>
+ */
+public interface DataStoreFactory {
+
+    /**
+     * Creates, initializes, and returns a {@link DataStore} instance
+     * for use by the repository. Note that no information is passed from
+     * the client, so all required configuration information must be
+     * encapsulated in the factory.
+     *
+     * @return initialized data store
+     * @throws RepositoryException if the data store can not be created
+     */
+    DataStore getDataStore() throws RepositoryException;
+
+}

Propchange: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/DataStoreFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message