jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r948770 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: RepositoryCopier.java RepositoryImpl.java RepositoryManagerImpl.java
Date Thu, 27 May 2010 10:35:15 GMT
Author: jukka
Date: Thu May 27 10:35:15 2010
New Revision: 948770

URL: http://svn.apache.org/viewvc?rev=948770&view=rev
Log:
JCR-2640: Internal repository context

Address Stefan's point about not accessing the context variable directly from external classes

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryCopier.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryManagerImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryCopier.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryCopier.java?rev=948770&r1=948769&r2=948770&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryCopier.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryCopier.java
Thu May 27 10:35:15 2010
@@ -60,14 +60,14 @@ public class RepositoryCopier {
         LoggerFactory.getLogger(RepositoryCopier.class);
 
     /**
-     * Source repository.
+     * Source repository context.
      */
-    private final RepositoryImpl source;
+    private final RepositoryContext source;
 
     /**
-     * Target repository.
+     * Target repository context.
      */
-    private final RepositoryImpl target;
+    private final RepositoryContext target;
 
     /**
      * Copies the contents of the repository in the given source directory
@@ -175,8 +175,12 @@ public class RepositoryCopier {
      * @param target target repository
      */
     public RepositoryCopier(RepositoryImpl source, RepositoryImpl target) {
-        this.source = source;
-        this.target = target;
+        // TODO: It would be better if we were given the RepositoryContext
+        // instances directly. Perhaps we should use something like
+        // RepositoryImpl.getRepositoryCopier(RepositoryImpl target)
+        // instead of this public constructor to achieve that.
+        this.source = source.getRepositoryContext();
+        this.target = target.getRepositoryContext();
     }
 
     /**
@@ -196,8 +200,8 @@ public class RepositoryCopier {
     public void copy() throws RepositoryException {
         logger.info(
                 "Copying repository content from {} to {}",
-                source.repConfig.getHomeDir(),
-                target.repConfig.getHomeDir());
+                source.getRepository().repConfig.getHomeDir(),
+                target.getRepository().repConfig.getHomeDir());
         try {
             copyNamespaces();
             copyNodeTypes();
@@ -209,8 +213,8 @@ public class RepositoryCopier {
     }
 
     private void copyNamespaces() throws RepositoryException {
-        NamespaceRegistry sourceRegistry = source.context.getNamespaceRegistry();
-        NamespaceRegistry targetRegistry = target.context.getNamespaceRegistry();
+        NamespaceRegistry sourceRegistry = source.getNamespaceRegistry();
+        NamespaceRegistry targetRegistry = target.getNamespaceRegistry();
 
         logger.info("Copying registered namespaces");
         Collection<String> existing = Arrays.asList(targetRegistry.getURIs());
@@ -224,8 +228,8 @@ public class RepositoryCopier {
     }
 
     private void copyNodeTypes() throws RepositoryException {
-        NodeTypeRegistry sourceRegistry = source.context.getNodeTypeRegistry();
-        NodeTypeRegistry targetRegistry = target.context.getNodeTypeRegistry();
+        NodeTypeRegistry sourceRegistry = source.getNodeTypeRegistry();
+        NodeTypeRegistry targetRegistry = target.getNodeTypeRegistry();
 
         logger.info("Copying registered node types");
         Collection<Name> existing =
@@ -247,33 +251,36 @@ public class RepositoryCopier {
     private void copyVersionStore() throws RepositoryException {
         logger.info("Copying version histories");
         PersistenceCopier copier = new PersistenceCopier(
-                source.context.getInternalVersionManager().getPersistenceManager(),
-                target.context.getInternalVersionManager().getPersistenceManager(),
-                target.getDataStore());
+                source.getInternalVersionManager().getPersistenceManager(),
+                target.getInternalVersionManager().getPersistenceManager(),
+                target.getRepository().getDataStore());
         copier.copy(RepositoryImpl.VERSION_STORAGE_NODE_ID);
         copier.copy(RepositoryImpl.ACTIVITIES_NODE_ID);
     }
 
     private void copyWorkspaces() throws RepositoryException {
-        Collection<String> existing = Arrays.asList(target.getWorkspaceNames());
-        for (String name : source.getWorkspaceNames()) {
+        Collection<String> existing =
+            Arrays.asList(target.getRepository().getWorkspaceNames());
+        for (String name : source.getRepository().getWorkspaceNames()) {
             logger.info("Copying workspace {}" , name);
 
             if (!existing.contains(name)) {
-                target.createWorkspace(name);
+                target.getRepository().createWorkspace(name);
             }
 
             // Copy all the workspace content
             PersistenceCopier copier = new PersistenceCopier(
-                    source.getWorkspaceInfo(name).getPersistenceManager(),
-                    target.getWorkspaceInfo(name).getPersistenceManager(),
-                    target.getDataStore());
+                    source.getRepository().getWorkspaceInfo(name).getPersistenceManager(),
+                    target.getRepository().getWorkspaceInfo(name).getPersistenceManager(),
+                    target.getRepository().getDataStore());
             copier.excludeNode(RepositoryImpl.SYSTEM_ROOT_NODE_ID);
             copier.copy(RepositoryImpl.ROOT_NODE_ID);
 
             // Copy all the active open-scoped locks
-            LockManagerImpl sourceLockManager = source.getLockManager(name);
-            LockManagerImpl targetLockManager = target.getLockManager(name);
+            LockManagerImpl sourceLockManager =
+                source.getRepository().getLockManager(name);
+            LockManagerImpl targetLockManager =
+                target.getRepository().getLockManager(name);
             targetLockManager.copyOpenScopedLocksFrom(sourceLockManager);
         }
     }

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=948770&r1=948769&r2=948770&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
Thu May 27 10:35:15 2010
@@ -418,6 +418,19 @@ public class RepositoryImpl extends Abst
         }
     }
 
+    /**
+     * Returns the internal component context of this repository.
+     * This package-private method should only be used when there is
+     * no other reasonable way to access the repository context.
+     * A better design would be to access the repository instance
+     * through the repository context.
+     *
+     * @return repository context
+     */
+    RepositoryContext getRepositoryContext() { // TODO: Get rid of this method
+        return context;
+    }
+
     public DataStore getDataStore() {
         return dataStore;
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryManagerImpl.java?rev=948770&r1=948769&r2=948770&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryManagerImpl.java
Thu May 27 10:35:15 2010
@@ -46,7 +46,8 @@ public class RepositoryManagerImpl imple
             throw new RepositoryException("Repository is stopped");
         }
         ArrayList<PersistenceManager> pmList = new ArrayList<PersistenceManager>();
-        InternalVersionManagerImpl vm = rep.context.getInternalVersionManager();
+        InternalVersionManagerImpl vm =
+            rep.getRepositoryContext().getInternalVersionManager();
         PersistenceManager pm = vm.getPersistenceManager();
         pmList.add(pm);
         String[] wspNames = rep.getWorkspaceNames();
@@ -55,8 +56,8 @@ public class RepositoryManagerImpl imple
             String wspName = wspNames[i];
             WorkspaceInfo wspInfo = rep.getWorkspaceInfo(wspName);
             // this will initialize the workspace if required
-            SessionImpl session =
-                SystemSession.create(rep.context, wspInfo.getConfig());
+            SessionImpl session = SystemSession.create(
+                    rep.getRepositoryContext(), wspInfo.getConfig());
             // mark this session as 'active' so the workspace does not get disposed
             // by the workspace-janitor until the garbage collector is done
             rep.onSessionCreated(session);



Mime
View raw message