jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r555263 - in /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: WorkspaceImpl.java WorkspaceManager.java
Date Wed, 11 Jul 2007 13:16:22 GMT
Author: mreutegg
Date: Wed Jul 11 06:16:21 2007
New Revision: 555263

URL: http://svn.apache.org/viewvc?view=rev&rev=555263
Log:
JCR-1022: Reduce calls to RepositoryService.getRepositoryDescriptors()

Modified:
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java?view=diff&rev=555263&r1=555262&r2=555263
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
Wed Jul 11 06:16:21 2007
@@ -88,7 +88,7 @@
     /**
      * The Session that created this <code>Workspace</code> object.
      */
-    private final SessionImpl session;
+    protected final SessionImpl session;
 
     /**
      * WorkspaceManager acting as ItemStateManager on the workspace level
@@ -107,7 +107,7 @@
         wspManager = createManager(
                 config.getRepositoryService(),
                 sessionInfo,
-                session.getCacheBehaviour(), 
+                session.getCacheBehaviour(),
                 3 * 1000); // 3 seconds poll timeout
     }
 
@@ -462,7 +462,8 @@
                                              SessionInfo sessionInfo,
                                              CacheBehaviour cacheBehaviour,
                                              int pollTimeout) throws RepositoryException
{
-        return new WorkspaceManager(service, sessionInfo, cacheBehaviour, pollTimeout);
+        return new WorkspaceManager(service, sessionInfo, cacheBehaviour,
+                pollTimeout, session.isSupportedOption(Repository.OPTION_OBSERVATION_SUPPORTED));
     }
 
     /**

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java?view=diff&rev=555263&r1=555262&r2=555263
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
Wed Jul 11 06:16:21 2007
@@ -93,7 +93,6 @@
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.NoSuchWorkspaceException;
 import javax.jcr.ItemExistsException;
-import javax.jcr.Repository;
 import javax.jcr.InvalidItemStateException;
 import javax.jcr.MergeException;
 import javax.jcr.Session;
@@ -152,17 +151,17 @@
     private final Set listeners = new HashSet();
 
     public WorkspaceManager(RepositoryService service, SessionInfo sessionInfo,
-                            CacheBehaviour cacheBehaviour, int pollTimeout)
+                            CacheBehaviour cacheBehaviour, int pollTimeout,
+                            boolean enableObservation)
         throws RepositoryException {
         this.service = service;
         this.sessionInfo = sessionInfo;
         this.cacheBehaviour = cacheBehaviour;
 
-        Map repositoryDescriptors = service.getRepositoryDescriptors();
         nsRegistry = createNamespaceRegistry(NamespaceCache.getInstance(service));
         QNodeDefinition rootNodeDef = service.getNodeDefinition(sessionInfo, service.getRootId(sessionInfo));
         ntRegistry = createNodeTypeRegistry(rootNodeDef, nsRegistry);
-        changeFeed = createChangeFeed(pollTimeout);
+        changeFeed = createChangeFeed(pollTimeout, enableObservation);
         definitionProvider = createDefinitionProvider(rootNodeDef, getEffectiveNodeTypeProvider());
 
         TransientItemStateFactory stateFactory = createItemStateFactory();
@@ -421,22 +420,17 @@
      * RepositoryService.
      *
      * @param pollTimeout the polling timeout in milliseconds.
+     * @param enableObservation if observation should be enabled.
      * @return the background polling thread or <code>null</code> if the underlying
      *         <code>RepositoryService</code> does not support observation.
      */
-    private Thread createChangeFeed(int pollTimeout) {
+    private Thread createChangeFeed(int pollTimeout, boolean enableObservation) {
         Thread t = null;
-        try {
-            String desc = (String) service.getRepositoryDescriptors().get(
-                    Repository.OPTION_OBSERVATION_SUPPORTED);
-            if ("true".equals(desc)) {
-                t = new Thread(new ChangePolling(pollTimeout));
-                t.setName("Change Polling");
-                t.setDaemon(true);
-                t.start();
-            }
-        } catch (RepositoryException e) {
-            log.warn("Unable to get repository descriptors: " + e);
+        if (enableObservation) {
+            t = new Thread(new ChangePolling(pollTimeout));
+            t.setName("Change Polling");
+            t.setDaemon(true);
+            t.start();
         }
         return t;
     }



Mime
View raw message