jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r948827 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/ main/java/org/apache/jackrabbit/core/data/ test/java/org/apache/jackrabbit/core/data/
Date Thu, 27 May 2010 13:26:42 GMT
Author: jukka
Date: Thu May 27 13:26:41 2010
New Revision: 948827

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

Use the RepositoryContext to track the DataStore instance, if one is configured.

PS. Removed the conditions on the execution of data store tests. Our current test configuration
always includes the data store, so there's no need for the conditionals.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java
    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
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCConcurrentTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/TestTwoGetStreams.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java?rev=948827&r1=948826&r2=948827&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
Thu May 27 13:26:41 2010
@@ -95,11 +95,6 @@ public abstract class ItemImpl implement
     protected final SessionImpl session;
 
     /**
-     * the <code>Repository</code> object
-     */
-    protected final RepositoryImpl rep;
-
-    /**
      * Item data associated with this item.
      */
     protected final ItemData data;
@@ -123,7 +118,6 @@ public abstract class ItemImpl implement
      */
     ItemImpl(ItemManager itemMgr, SessionImpl session, ItemData data) {
         this.session = session;
-        rep = (RepositoryImpl) session.getRepository();
         stateMgr = session.getItemStateManager();
         this.id = data.getId();
         this.itemMgr = itemMgr;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java?rev=948827&r1=948826&r2=948827&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
Thu May 27 13:26:41 2010
@@ -32,6 +32,7 @@ import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.ConstraintViolationException;
 
 import org.apache.commons.collections.map.ReferenceMap;
+import org.apache.jackrabbit.core.data.DataStore;
 import org.apache.jackrabbit.core.id.ItemId;
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.id.PropertyId;
@@ -96,6 +97,11 @@ public class ItemManager implements Dump
     private final HierarchyManager hierMgr;
 
     /**
+     * The data store of this repository, or <code>null</code>
+     */
+    private final DataStore dataStore;
+
+    /**
      * A cache for item instances created by this <code>ItemManager</code>
      */
     private final Map<ItemId, ItemData> itemCache;
@@ -114,17 +120,20 @@ public class ItemManager implements Dump
      * @param session     the session associated with the new instance
      * @param rootNodeDef the definition of the root node
      * @param rootNodeId  the id of the root node
+     * @param dataStore   the data store of this repository, or <code>null</code>
      */
     protected ItemManager(SessionItemStateManager sism,
                           HierarchyManager hierMgr,
                           SessionImpl session,
-                          org.apache.jackrabbit.spi.commons.nodetype.NodeDefinitionImpl rootNodeDef,
-                          NodeId rootNodeId) {
+                          NodeDefinitionImpl rootNodeDef,
+                          NodeId rootNodeId,
+                          DataStore dataStore) {
         this.sism = sism;
         this.hierMgr = hierMgr;
         this.session = session;
         this.rootNodeDef = rootNodeDef;
         this.rootNodeId = rootNodeId;
+        this.dataStore = dataStore;
 
         // setup item cache with weak references to items
         itemCache = new ReferenceMap(ReferenceMap.HARD, ReferenceMap.WEAK);
@@ -142,16 +151,19 @@ public class ItemManager implements Dump
      * @param session           the session associated with the new instance
      * @param rootNodeDef       the definition of the root node
      * @param rootNodeId        the id of the root node
+     * @param dataStore   the data store of this repository, or <code>null</code>
      * @return the item manager instance.
      */
     public static ItemManager createInstance(
             SessionItemStateManager itemStateProvider,
             HierarchyManager hierMgr,
             SessionImpl session,
-            org.apache.jackrabbit.spi.commons.nodetype.NodeDefinitionImpl rootNodeDef,
-            NodeId rootNodeId) {
-        ItemManager mgr = new ItemManager(itemStateProvider, hierMgr,
-                session, rootNodeDef, rootNodeId);
+            NodeDefinitionImpl rootNodeDef,
+            NodeId rootNodeId,
+            DataStore dataStore) {
+        ItemManager mgr = new ItemManager(
+                itemStateProvider, hierMgr, session, rootNodeDef,
+                rootNodeId, dataStore);
         itemStateProvider.addListener(mgr);
         return mgr;
     }
@@ -841,7 +853,7 @@ public class ItemManager implements Dump
 
     private PropertyImpl createPropertyInstance(PropertyData data) {
         // check special nodes
-        return new PropertyImpl(this, session, data);
+        return new PropertyImpl(this, session, data, dataStore);
     }
 
     //---------------------------------------------------< item cache methods >

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java?rev=948827&r1=948826&r2=948827&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
Thu May 27 13:26:41 2010
@@ -2840,6 +2840,7 @@ public class NodeImpl extends ItemImpl i
         try {
             // create session on other workspace for current subject
             // (may throw NoSuchWorkspaceException and AccessDeniedException)
+            RepositoryImpl rep = (RepositoryImpl) session.getRepository();
             srcSession = rep.createSession(session.getSubject(), workspaceName);
 
             // search nearest ancestor that is referenceable

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java?rev=948827&r1=948826&r2=948827&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
Thu May 27 13:26:41 2010
@@ -37,6 +37,7 @@ import javax.jcr.nodetype.ConstraintViol
 import javax.jcr.nodetype.PropertyDefinition;
 import javax.jcr.version.VersionException;
 
+import org.apache.jackrabbit.core.data.DataStore;
 import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.security.authorization.Permission;
 import org.apache.jackrabbit.core.state.ItemState;
@@ -65,15 +66,24 @@ public class PropertyImpl extends ItemIm
     private final PropertyData data;
 
     /**
+     * The data store of this repository, or <code>null</code>
+     */
+    private final DataStore dataStore;
+
+    /**
      * Package private constructor.
      *
      * @param itemMgr    the <code>ItemManager</code> that created this <code>Property</code>
      * @param session    the <code>Session</code> through which this <code>Property</code>
is acquired
      * @param data       the property data
+     * @param dataStore  the data store of this repository, or <code>null</code>
      */
-    PropertyImpl(ItemManager itemMgr, SessionImpl session, PropertyData data) {
+    PropertyImpl(
+            ItemManager itemMgr, SessionImpl session, PropertyData data,
+            DataStore dataStore) {
         super(itemMgr, session, data);
         this.data = data;
+        this.dataStore = dataStore;
         // value will be read on demand
     }
 
@@ -348,7 +358,7 @@ public class PropertyImpl extends ItemIm
             Value targetValue = ValueHelper.convert(
                     ValueFormat.getJCRValue(InternalValue.create(name), session, session.getValueFactory()),
                     reqType, session.getValueFactory());
-            internalValue = InternalValue.create(targetValue, session, rep.getDataStore());
+            internalValue = InternalValue.create(targetValue, session, dataStore);
         } else {
             // no type conversion required
             internalValue = InternalValue.create(name);
@@ -399,7 +409,7 @@ public class PropertyImpl extends ItemIm
                         Value targetValue = ValueHelper.convert(
                                 ValueFormat.getJCRValue(InternalValue.create(name), session,
session.getValueFactory()),
                                 reqType, session.getValueFactory());
-                        internalValue = InternalValue.create(targetValue, session, rep.getDataStore());
+                        internalValue = InternalValue.create(targetValue, session, dataStore);
                     } else {
                         // no type conversion required
                         internalValue = InternalValue.create(name);
@@ -674,10 +684,10 @@ public class PropertyImpl extends ItemIm
             // type conversion required
             Value targetVal = ValueHelper.convert(
                     value, reqType, session.getValueFactory());
-            internalValue = InternalValue.create(targetVal, session, rep.getDataStore());
+            internalValue = InternalValue.create(targetVal, session, dataStore);
         } else {
             // no type conversion required
-            internalValue = InternalValue.create(value, session, rep.getDataStore());
+            internalValue = InternalValue.create(value, session, dataStore);
         }
         internalSetValue(new InternalValue[]{internalValue}, reqType);
     }
@@ -746,8 +756,8 @@ public class PropertyImpl extends ItemIm
                         value = ValueHelper.convert(
                                 value, reqType, session.getValueFactory());
                     }
-                    internalValues[i] = InternalValue.create(
-                            value, session, rep.getDataStore());
+                    internalValues[i] =
+                        InternalValue.create(value, session, dataStore);
                 } else {
                     internalValues[i] = null;
                 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java?rev=948827&r1=948826&r2=948827&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java
Thu May 27 13:26:41 2010
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.core;
 
+import org.apache.jackrabbit.core.data.DataStore;
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
@@ -61,6 +62,11 @@ public class RepositoryContext {
     private FileSystem fileSystem;
 
     /**
+     * The data store of this repository, can be <code>null</code>.
+     */
+    private DataStore dataStore;
+
+    /**
      * Creates a component context for the given repository.
      *
      * @param repository repository instance
@@ -180,4 +186,24 @@ public class RepositoryContext {
         this.fileSystem = fileSystem;
     }
 
+    /**
+     * Returns the data store of this repository, or <code>null</code>
+     * if a data store is not configured.
+     *
+     * @return data store
+     */
+    public DataStore getDataStore() {
+        return dataStore;
+    }
+
+    /**
+     * Sets the data store of this repository.
+     *
+     * @param dataStore data store
+     */
+    public void setDataStore(DataStore dataStore) {
+        assert dataStore != null;
+        this.dataStore = dataStore;
+    }
+
 }

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=948827&r1=948826&r2=948827&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 13:26:41 2010
@@ -253,7 +253,7 @@ public class RepositoryCopier {
         PersistenceCopier copier = new PersistenceCopier(
                 source.getInternalVersionManager().getPersistenceManager(),
                 target.getInternalVersionManager().getPersistenceManager(),
-                target.getRepository().getDataStore());
+                target.getDataStore());
         copier.copy(RepositoryImpl.VERSION_STORAGE_NODE_ID);
         copier.copy(RepositoryImpl.ACTIVITIES_NODE_ID);
     }
@@ -272,7 +272,7 @@ public class RepositoryCopier {
             PersistenceCopier copier = new PersistenceCopier(
                     source.getRepository().getWorkspaceInfo(name).getPersistenceManager(),
                     target.getRepository().getWorkspaceInfo(name).getPersistenceManager(),
-                    target.getRepository().getDataStore());
+                    target.getDataStore());
             copier.excludeNode(RepositoryImpl.SYSTEM_ROOT_NODE_ID);
             copier.copy(RepositoryImpl.ROOT_NODE_ID);
 

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=948827&r1=948826&r2=948827&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 13:26:41 2010
@@ -183,11 +183,6 @@ public class RepositoryImpl extends Abst
     protected final RepositoryConfig repConfig;
 
     /**
-     * Data store for binary properties.
-     */
-    private final DataStore dataStore;
-
-    /**
      * the delegating observation dispatcher for all workspaces
      */
     private final DelegatingObservationDispatcher delegatingDispatcher =
@@ -309,7 +304,10 @@ public class RepositoryImpl extends Abst
             context.setNodeTypeRegistry(new NodeTypeRegistry(
                     context.getNamespaceRegistry(), context.getFileSystem()));
 
-            dataStore = repConfig.getDataStore();
+            DataStore dataStore = repConfig.getDataStore();
+            if (dataStore != null) {
+                context.setDataStore(dataStore);
+            }
 
             // init workspace configs
             for (WorkspaceConfig config : repConfig.getWorkspaceConfigs()) {
@@ -411,10 +409,6 @@ public class RepositoryImpl extends Abst
         return context;
     }
 
-    public DataStore getDataStore() {
-        return dataStore;
-    }
-
     /**
      * Get the cache manager of this repository, useful
      * for setting its memory parameters.
@@ -494,7 +488,7 @@ public class RepositoryImpl extends Abst
         FileSystem fs = vConfig.getFileSystem();
         PersistenceManager pm = createPersistenceManager(
                 vConfig.getHomeDir(), fs,
-                vConfig.getPersistenceManagerConfig(), dataStore);
+                vConfig.getPersistenceManagerConfig());
 
         ISMLocking ismLocking = vConfig.getISMLocking();
 
@@ -1095,6 +1089,7 @@ public class RepositoryImpl extends Abst
 
         repDescriptors.clear();
 
+        DataStore dataStore = context.getDataStore();
         if (dataStore != null) {
             try {
                 // close the datastore
@@ -1312,8 +1307,8 @@ public class RepositoryImpl extends Abst
      *                             not be instantiated/initialized
      */
     private PersistenceManager createPersistenceManager(
-            File homeDir, FileSystem fs, PersistenceManagerConfig pmConfig,
-            DataStore dataStore) throws RepositoryException {
+            File homeDir, FileSystem fs, PersistenceManagerConfig pmConfig)
+            throws RepositoryException {
         try {
             PersistenceManager pm = pmConfig.newInstance(PersistenceManager.class);
             pm.init(new PMContext(
@@ -1321,7 +1316,7 @@ public class RepositoryImpl extends Abst
                     context.getRootNodeId(),
                     context.getNamespaceRegistry(),
                     context.getNodeTypeRegistry(),
-                    dataStore));
+                    context.getDataStore()));
             return pm;
         } catch (Exception e) {
             String msg = "Cannot instantiate persistence manager " + pmConfig.getClassName();
@@ -1906,10 +1901,8 @@ public class RepositoryImpl extends Abst
             fs = config.getFileSystem();
 
             persistMgr = createPersistenceManager(
-                    new File(config.getHomeDir()),
-                    fs,
-                    config.getPersistenceManagerConfig(),
-                    dataStore);
+                    new File(config.getHomeDir()), fs,
+                    config.getPersistenceManagerConfig());
 
             // JCR-2551: Recovery from a lost version history
             if (Boolean.getBoolean("org.apache.jackrabbit.version.recovery")) {
@@ -2295,12 +2288,6 @@ public class RepositoryImpl extends Abst
             getWorkspaceInfo(workspace).getLockManager();
         }
 
-        /**
-         * {@inheritDoc}
-         */
-        public DataStore getDataStore() {
-            return RepositoryImpl.this.getDataStore();
-        }
     }
 
     /**

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=948827&r1=948826&r2=948827&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 13:26:41 2010
@@ -77,7 +77,9 @@ public class RepositoryManagerImpl imple
             }
             ipmList[i] = (IterablePersistenceManager) pm;
         }
-        GarbageCollector gc = new GarbageCollector(rep, null, ipmList, sessions);
+        GarbageCollector gc = new GarbageCollector(
+                rep.getRepositoryContext().getDataStore(),
+                null, ipmList, sessions);
         return gc;
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java?rev=948827&r1=948826&r2=948827&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
Thu May 27 13:26:41 2010
@@ -289,7 +289,8 @@ public class SessionImpl extends Abstrac
 
         namePathResolver = new DefaultNamePathResolver(this, this, true);
         ntMgr = new NodeTypeManagerImpl(
-                repositoryContext.getNodeTypeRegistry(), this, rep.getDataStore());
+                repositoryContext.getNodeTypeRegistry(), this,
+                repositoryContext.getDataStore());
         String wspName = wspConfig.getName();
         wsp = createWorkspaceInstance(
                 wspConfig, rep.getWorkspaceStateManager(wspName));
@@ -344,7 +345,8 @@ public class SessionImpl extends Abstrac
         return ItemManager.createInstance(
                 itemStateMgr, hierMgr, this,
                 ntMgr.getRootNodeDefinition(),
-                repositoryContext.getRootNodeId());
+                repositoryContext.getRootNodeId(),
+                repositoryContext.getDataStore());
     }
 
     /**
@@ -694,7 +696,8 @@ public class SessionImpl extends Abstrac
             }
             ipmList[i] = (IterablePersistenceManager) pm;
         }
-        GarbageCollector gc = new GarbageCollector(rep, this, ipmList, sessions);
+        GarbageCollector gc = new GarbageCollector(
+                repositoryContext.getDataStore(), this, ipmList, sessions);
         return gc;
     }
 
@@ -1278,7 +1281,8 @@ public class SessionImpl extends Abstrac
      */
     public ValueFactory getValueFactory() {
         if (valueFactory == null) {
-            valueFactory = new ValueFactoryImpl(this, rep.getDataStore());
+            valueFactory =
+                new ValueFactoryImpl(this, repositoryContext.getDataStore());
         }
         return valueFactory;
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java?rev=948827&r1=948826&r2=948827&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java
Thu May 27 13:26:41 2010
@@ -20,7 +20,6 @@ import org.apache.jackrabbit.api.managem
 import org.apache.jackrabbit.api.management.MarkEventListener;
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.id.PropertyId;
-import org.apache.jackrabbit.core.RepositoryImpl;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.SessionListener;
 import org.apache.jackrabbit.core.observation.SynchronousEventListener;
@@ -107,13 +106,15 @@ public class GarbageCollector implements
      * This method is usually not called by the application, it is called
      * by SessionImpl.createDataStoreGarbageCollector().
      *
-     * @param rep the repository
+     * @param dataStore the data store to be garbage-collected
      * @param session the session that created this object (optional)
      * @param list the persistence managers
      * @param sessionList the sessions to access the workspaces
      */
-    public GarbageCollector(RepositoryImpl rep, SessionImpl session, IterablePersistenceManager[]
list, Session[] sessionList) {
-        store = rep.getDataStore();
+    public GarbageCollector(
+            DataStore dataStore, SessionImpl session,
+            IterablePersistenceManager[] list, Session[] sessionList) {
+        this.store = dataStore;
         this.pmList = list;
         this.persistenceManagerScan = list != null;
         this.sessionList = sessionList;

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCConcurrentTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCConcurrentTest.java?rev=948827&r1=948826&r2=948827&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCConcurrentTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCConcurrentTest.java
Thu May 27 13:26:41 2010
@@ -18,7 +18,6 @@ package org.apache.jackrabbit.core.data;
 
 import org.apache.jackrabbit.api.management.DataStoreGarbageCollector;
 import org.apache.jackrabbit.api.management.MarkEventListener;
-import org.apache.jackrabbit.core.RepositoryImpl;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.test.AbstractJCRTest;
 import org.slf4j.Logger;
@@ -46,11 +45,7 @@ public class GCConcurrentTest extends Ab
     public void testConcurrentDelete() throws Exception {
         Node root = testRootNode;
         Session session = root.getSession();
-        RepositoryImpl rep = (RepositoryImpl) session.getRepository();
-        if (rep.getDataStore() == null) {
-            LOG.info("testGC skipped. Data store is not used.");
-            return;
-        }
+
         final String testNodeName = "testConcurrentDelete";
         node(root, testNodeName);
         session.save();
@@ -72,11 +67,7 @@ public class GCConcurrentTest extends Ab
     public void testGC() throws Exception {
         Node root = testRootNode;
         Session session = root.getSession();
-        RepositoryImpl rep = (RepositoryImpl) session.getRepository();
-        if (rep.getDataStore() == null) {
-            LOG.info("testGC skipped. Data store is not used.");
-            return;
-        }
+
         GCThread gc = new GCThread(session);
         Thread gcThread = new Thread(gc, "Datastore Garbage Collector");
 

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java?rev=948827&r1=948826&r2=948827&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java
Thu May 27 13:26:41 2010
@@ -18,7 +18,6 @@ package org.apache.jackrabbit.core.data;
 
 import org.apache.jackrabbit.api.management.DataStoreGarbageCollector;
 import org.apache.jackrabbit.api.management.MarkEventListener;
-import org.apache.jackrabbit.core.RepositoryImpl;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.test.AbstractJCRTest;
 import org.slf4j.Logger;
@@ -45,11 +44,7 @@ public class GarbageCollectorTest extend
 
     public void testCloseSessionWhileRunningGc() throws Exception {
         final Session session = getHelper().getReadWriteSession();
-        RepositoryImpl rep = (RepositoryImpl) session.getRepository();
-        if (rep.getDataStore() == null) {
-            LOG.info("testConcurrentClose skipped. Data store is not used.");
-            return;
-        }
+
         final DataStoreGarbageCollector gc = ((SessionImpl) session).createDataStoreGarbageCollector();
         final Exception[] ex = new Exception[1];
         gc.setMarkEventListener(new MarkEventListener() {
@@ -83,11 +78,7 @@ public class GarbageCollectorTest extend
     public void testConcurrentGC() throws Exception {
         Node root = testRootNode;
         Session session = root.getSession();
-        RepositoryImpl rep = (RepositoryImpl) session.getRepository();
-        if (rep.getDataStore() == null) {
-            LOG.info("testConcurrentGC skipped. Data store is not used.");
-            return;
-        }
+
         final SynchronousChannel sync = new SynchronousChannel();
         final Node node = root.addNode("slowBlob");
         final int blobLength = 1000;
@@ -141,12 +132,6 @@ public class GarbageCollectorTest extend
         Node root = testRootNode;
         Session session = root.getSession();
 
-        RepositoryImpl rep = (RepositoryImpl) session.getRepository();
-        if (rep.getDataStore() == null) {
-            LOG.info("testGC skipped. Data store is not used.");
-            return;
-        }
-
         deleteMyNodes();
         runGC(session, true);
 
@@ -218,12 +203,6 @@ public class GarbageCollectorTest extend
         Node root = testRootNode;
         Session session = root.getSession();
 
-        RepositoryImpl rep = (RepositoryImpl) session.getRepository();
-        if (rep.getDataStore() == null) {
-            LOG.info("testTransientObjects skipped. Data store is not used.");
-            return;
-        }
-
         deleteMyNodes();
 
         Credentials cred = getHelper().getSuperuserCredentials();

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/TestTwoGetStreams.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/TestTwoGetStreams.java?rev=948827&r1=948826&r2=948827&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/TestTwoGetStreams.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/TestTwoGetStreams.java
Thu May 27 13:26:41 2010
@@ -20,12 +20,10 @@ import java.io.IOException;
 import java.io.InputStream;
 
 import javax.jcr.Node;
-import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.ValueFactory;
 
 import org.apache.jackrabbit.api.JackrabbitValue;
-import org.apache.jackrabbit.core.RepositoryImpl;
 import org.apache.jackrabbit.test.AbstractJCRTest;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -39,20 +37,10 @@ public class TestTwoGetStreams extends A
 
     private static final int STREAM_LENGTH = 256 * 1024;
 
-    private boolean isDataStoreEnabled() throws RepositoryException {
-        RepositoryImpl rep = (RepositoryImpl) superuser.getRepository();
-        return rep.getDataStore() != null;
-    }
-
     /**
      * Test the JackrabbitValue.getContentIdentity feature.
      */
     public void testContentIdentity() throws Exception {
-        if (!isDataStoreEnabled()) {
-            log.info("testContentIdentity skipped. Data store is not used.");
-            return;
-        }
-
         Node root = superuser.getRootNode();
         ValueFactory vf = superuser.getValueFactory();
 
@@ -94,11 +82,6 @@ public class TestTwoGetStreams extends A
      * Test reading from two concurrently opened streams.
      */
     public void testTwoGetStreams() throws Exception {
-        if (!isDataStoreEnabled()) {
-            log.info("testContentIdentity skipped. Data store is not used.");
-            return;
-        }
-
         Node root = superuser.getRootNode();
         ValueFactory vf = superuser.getValueFactory();
         root.setProperty("p1", vf.createBinary(new RandomInputStream(1, STREAM_LENGTH)));
@@ -125,11 +108,6 @@ public class TestTwoGetStreams extends A
      * Tests reading concurrently from two different streams.
      */
     public void testTwoStreamsConcurrently() throws Exception {
-        if (!isDataStoreEnabled()) {
-            log.info("testContentIdentity skipped. Data store is not used.");
-            return;
-        }
-
         Node root = superuser.getRootNode();
         ValueFactory vf = superuser.getValueFactory();
         root.setProperty("p1", vf.createBinary(new RandomInputStream(1, STREAM_LENGTH)));
@@ -156,11 +134,6 @@ public class TestTwoGetStreams extends A
      * same property.
      */
     public void testTwoStreamsFromSamePropertyConcurrently() throws Exception {
-        if (!isDataStoreEnabled()) {
-            log.info("testContentIdentity skipped. Data store is not used.");
-            return;
-        }
-
         Node root = superuser.getRootNode();
         ValueFactory vf = superuser.getValueFactory();
         root.setProperty("p1", vf.createBinary(new RandomInputStream(1, STREAM_LENGTH)));



Mime
View raw message