jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1065622 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/ main/java/org/apache/jackrabbit/core/config/ test/java/org/apache/jackrabbit/core/config/
Date Mon, 31 Jan 2011 14:13:45 GMT
Author: jukka
Date: Mon Jan 31 14:13:45 2011
New Revision: 1065622

URL: http://svn.apache.org/viewvc?rev=1065622&view=rev
Log:
JCR-2870: Transient Repository cannot be used more than once when configured with DataSources

Patch by Chris Schmidt.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransientRepository.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfig.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/RepositoryConfigTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransientRepository.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransientRepository.java?rev=1065622&r1=1065621&r2=1065622&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransientRepository.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransientRepository.java
Mon Jan 31 14:13:45 2011
@@ -168,15 +168,16 @@ public class TransientRepository extends
     }
 
     /**
-     * Creates a transient repository proxy that will use the given repository
-     * configuration to initialize the underlying repository instance.
+     * Creates a transient repository proxy that will use a copy of the given 
+     * repository configuration to initialize the underlying repository 
+     * instance.
      *
      * @param config repository configuration
      */
     public TransientRepository(final RepositoryConfig config) {
         this(new RepositoryFactory() {
             public RepositoryImpl getRepository() throws RepositoryException {
-                return RepositoryImpl.create(config);
+                return RepositoryImpl.create(RepositoryConfig.create(config));
             }
         }, config.getHomeDir());
     }

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=1065622&r1=1065621&r2=1065622&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
Mon Jan 31 14:13:45 2011
@@ -350,6 +350,25 @@ public class RepositoryConfig
     }
 
     /**
+     * Creates a repository configuration object based on an existing configuration. The
factories
+     * contained within the configuration will be newly initialized, but all other information
+     * will be the same.
+     *
+     * @param config repository configuration to create the new instance from
+     * @return repository configuration
+     * @throws ConfigurationException on configuration errors
+     */
+    public static RepositoryConfig create(RepositoryConfig config) throws ConfigurationException
+    {
+        RepositoryConfig copiedConfig = new RepositoryConfig(config.home, config.sec, config.fsf,
+                config.workspaceDirectory, config.workspaceConfigDirectory, config.defaultWorkspace,
+                config.workspaceMaxIdleTime, config.template, config.vc, config.qhf, config.cc,
+                config.dsf, config.rlf, config.dsc, new ConnectionFactory(), config.parser);
+        copiedConfig.init();
+        return copiedConfig;
+    }
+
+    /**
      * map of workspace names and workspace configurations
      */
     private Map<String, WorkspaceConfig> workspaces;

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/RepositoryConfigTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/RepositoryConfigTest.java?rev=1065622&r1=1065621&r2=1065622&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/RepositoryConfigTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/RepositoryConfigTest.java
Mon Jan 31 14:13:45 2011
@@ -195,42 +195,7 @@ public class RepositoryConfigTest extend
      * Test that the repository configuration file is correctly parsed.
      */
     public void testRepositoryConfig() throws Exception {
-        assertEquals(DIR.getPath(), config.getHomeDir());
-        assertEquals("default", config.getDefaultWorkspaceName());
-        assertEquals(
-                new File(DIR, "workspaces").getPath(),
-                new File(config.getWorkspacesConfigRootDir()).getPath());
-        assertEquals("Jackrabbit", config.getSecurityConfig().getAppName());
-
-        // SecurityManagerConfig
-        SecurityManagerConfig smc =
-            config.getSecurityConfig().getSecurityManagerConfig();
-        assertEquals(
-                "org.apache.jackrabbit.core.DefaultSecurityManager",
-                smc.getClassName());
-        assertTrue(smc.getParameters().isEmpty());
-        assertNotNull(smc.getWorkspaceName());
-
-        BeanConfig bc = smc.getWorkspaceAccessConfig();
-        if (bc != null) {
-            WorkspaceAccessManager wac =
-                smc.getWorkspaceAccessConfig().newInstance(WorkspaceAccessManager.class);
-            assertEquals("org.apache.jackrabbit.core.security.simple.SimpleWorkspaceAccessManager",
wac.getClass().getName());
-        }
-
-        // AccessManagerConfig
-        AccessManagerConfig amc =
-            config.getSecurityConfig().getAccessManagerConfig();
-        assertEquals(
-                "org.apache.jackrabbit.core.security.DefaultAccessManager",
-                amc.getClassName());
-        assertTrue(amc.getParameters().isEmpty());
-
-        VersioningConfig vc = config.getVersioningConfig();
-        assertEquals(new File(DIR, "version"), vc.getHomeDir());
-        assertEquals(
-                "org.apache.jackrabbit.core.persistence.pool.DerbyPersistenceManager",
-                vc.getPersistenceManagerConfig().getClassName());
+        assertRepositoryConfiguration(config);
     }
 
     public void testInit() throws Exception {
@@ -313,4 +278,57 @@ public class RepositoryConfigTest extend
         }
     }
 
+    /**
+     * Test that a RepositoryConfig can be copied into a new instance.
+     *
+     * @throws Exception if an unexpected error occurs during the test
+     */
+    public void testCopyConfig() throws Exception
+    {
+        RepositoryConfig copyConfig = RepositoryConfig.create(config);
+
+        assertNotNull("Configuration not created properly", copyConfig);
+        assertRepositoryConfiguration(copyConfig);
+    }
+
+    private void assertRepositoryConfiguration(RepositoryConfig config)
+            throws ConfigurationException {
+        assertEquals(DIR.getPath(), config.getHomeDir());
+        assertEquals("default", config.getDefaultWorkspaceName());
+        assertEquals(
+                new File(DIR, "workspaces").getPath(),
+                new File(config.getWorkspacesConfigRootDir()).getPath());
+        assertEquals("Jackrabbit", config.getSecurityConfig().getAppName());
+
+        // SecurityManagerConfig
+        SecurityManagerConfig smc =
+            config.getSecurityConfig().getSecurityManagerConfig();
+        assertEquals(
+                "org.apache.jackrabbit.core.DefaultSecurityManager",
+                smc.getClassName());
+        assertTrue(smc.getParameters().isEmpty());
+        assertNotNull(smc.getWorkspaceName());
+
+        BeanConfig bc = smc.getWorkspaceAccessConfig();
+        if (bc != null) {
+            WorkspaceAccessManager wac =
+                smc.getWorkspaceAccessConfig().newInstance(WorkspaceAccessManager.class);
+            assertEquals("org.apache.jackrabbit.core.security.simple.SimpleWorkspaceAccessManager",
wac.getClass().getName());
+        }
+
+        // AccessManagerConfig
+        AccessManagerConfig amc =
+            config.getSecurityConfig().getAccessManagerConfig();
+        assertEquals(
+                "org.apache.jackrabbit.core.security.DefaultAccessManager",
+                amc.getClassName());
+        assertTrue(amc.getParameters().isEmpty());
+
+        VersioningConfig vc = config.getVersioningConfig();
+        assertEquals(new File(DIR, "version"), vc.getHomeDir());
+        assertEquals(
+                "org.apache.jackrabbit.core.persistence.pool.DerbyPersistenceManager",
+                vc.getPersistenceManagerConfig().getClassName());
+    }
+
 }



Mime
View raw message