jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r554573 - in /jackrabbit/trunk/contrib/spi: jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/
Date Mon, 09 Jul 2007 09:00:18 GMT
Author: mreutegg
Date: Mon Jul  9 02:00:17 2007
New Revision: 554573

URL: http://svn.apache.org/viewvc?view=rev&rev=554573
Log:
- spi-rmi: throw InterruptedException in ServerRepositoryService if session is not live anymore
- jcr2spi: remove unused parameters in methods of WorkspaceManager

Modified:
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
    jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java

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=554573&r1=554572&r2=554573
==============================================================================
--- 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
Mon Jul  9 02:00:17 2007
@@ -164,7 +164,7 @@
         changeFeed = createChangeFeed(pollTimeout);
         definitionProvider = createDefinitionProvider(rootNodeDef, getEffectiveNodeTypeProvider());
 
-        TransientItemStateFactory stateFactory = createItemStateFactory(ntRegistry);
+        TransientItemStateFactory stateFactory = createItemStateFactory();
         this.isf = stateFactory;
         this.hierarchyManager = createHierarchyManager(stateFactory, service.getIdFactory());
         createHierarchyListener(hierarchyManager);
@@ -345,7 +345,7 @@
      *
      * @return
      */
-    private TransientItemStateFactory createItemStateFactory(NodeTypeRegistry ntReg) {
+    private TransientItemStateFactory createItemStateFactory() {
         ItemStateFactory isf = new WorkspaceItemStateFactory(service, sessionInfo, getItemDefinitionProvider());
         TransientItemStateFactory tisf = new TransientISFactory(isf, getItemDefinitionProvider());
         return tisf;
@@ -372,9 +372,8 @@
      *
      * @param descriptors
      * @return
-     * @throws RepositoryException
      */
-    private NamespaceRegistryImpl createNamespaceRegistry(Map descriptors) throws RepositoryException
{
+    private NamespaceRegistryImpl createNamespaceRegistry(Map descriptors) {
         boolean level2 = Boolean.valueOf((String) descriptors.get(Repository.LEVEL_2_SUPPORTED)).booleanValue();
         return new NamespaceRegistryImpl(this, level2);
     }
@@ -408,7 +407,8 @@
 
     /**
      *
-     * @param ntReg
+     * @param rootDefinition
+     * @param entProvider
      * @return
      */
     private ItemDefinitionProvider createDefinitionProvider(QNodeDefinition rootDefinition,
EffectiveNodeTypeProvider entProvider) {
@@ -611,9 +611,13 @@
      * changes have been applied to the repository.
      *
      * @param eventBundles the event bundles generated by the repository service
-     * as the effect of an local or external change.
-     */
-    private void onEventReceived(EventBundle[] eventBundles, InternalEventListener[] lstnrs)
{
+     *                     as the effect of an local or external change.
+     * @throws InterruptedException if this thread is interrupted while waiting
+     *                              for the {@link #updateSync}.
+     */
+    private void onEventReceived(EventBundle[] eventBundles,
+                                 InternalEventListener[] lstnrs)
+            throws InterruptedException {
         if (log.isDebugEnabled()) {
             log.debug("received {} event bundles.", new Integer(eventBundles.length));
             for (int i = 0; i < eventBundles.length; i++) {
@@ -645,13 +649,9 @@
                 }
             }
         }
+
         // do not deliver events while an operation executes
-        try {
-            updateSync.acquire();
-        } catch (InterruptedException e) {
-            log.warn("Unable to acquire update mutext");
-            return;
-        }
+        updateSync.acquire();
         try {
             // notify listener
             for (int i = 0; i < eventBundles.length; i++) {

Modified: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java?view=diff&rev=554573&r1=554572&r2=554573
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java
Mon Jul  9 02:00:17 2007
@@ -710,7 +710,12 @@
                                    EventFilter[] filters)
             throws RepositoryException, InterruptedException, RemoteException {
         try {
-            SessionInfo sInfo = getSessionInfo(sessionInfo);
+            SessionInfo sInfo;
+            try {
+                sInfo = getSessionInfo(sessionInfo);
+            } catch (RepositoryException e) {
+                throw new InterruptedException();
+            }
             // create local event filter instances
             filters = createLocalEventFilters(sInfo, filters);
             EventBundle[] bundles = service.getEvents(sInfo, timeout, filters);

Modified: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java?view=diff&rev=554573&r1=554572&r2=554573
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
Mon Jul  9 02:00:17 2007
@@ -209,8 +209,10 @@
      * {@inheritDoc}
      */
     public void dispose(SessionInfo sessionInfo) throws RepositoryException {
-        subscriptions.remove(sessionInfo);
-        getSessionInfoImpl(sessionInfo).getSession().logout();
+        synchronized (sessionInfo) {
+            subscriptions.remove(sessionInfo);
+            getSessionInfoImpl(sessionInfo).getSession().logout();
+        }
     }
 
     /**
@@ -902,14 +904,7 @@
                                          boolean noLocal)
             throws UnsupportedRepositoryOperationException, RepositoryException {
         // make sure there is an event subscription for this session info
-        SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
-        if (!subscriptions.containsKey(sInfo)) {
-            EventSubscription subscr = new EventSubscription(idFactory, sInfo);
-            ObservationManager obsMgr = sInfo.getSession().getWorkspace().getObservationManager();
-            obsMgr.addEventListener(subscr, EventSubscription.ALL_EVENTS,
-                    "/", true, null, null, true);
-            subscriptions.put(sInfo, subscr);
-        }
+        getSubscription(sessionInfo);
 
         Set ntNames = null;
         if (nodeTypeName != null) {
@@ -925,14 +920,7 @@
                                    long timeout,
                                    EventFilter[] filters)
             throws RepositoryException, UnsupportedRepositoryOperationException, InterruptedException
{
-        EventSubscription subscr = (EventSubscription) subscriptions.get(sessionInfo);
-        if (subscr != null) {
-            return subscr.getEventBundles(filters, timeout);
-        } else {
-            // sleep for at most one second, then return
-            Thread.sleep(Math.min(timeout, 1000));
-            return new EventBundle[0];
-        }
+        return getSubscription(sessionInfo).getEventBundles(filters, timeout);
     }
 
     /**
@@ -1009,6 +997,25 @@
     }
 
     //----------------------------< internal >----------------------------------
+
+    private EventSubscription getSubscription(SessionInfo sessionInfo)
+            throws RepositoryException {
+        SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
+        EventSubscription subscr;
+        synchronized (sInfo) {
+            subscr = (EventSubscription) subscriptions.get(sInfo);
+            if (subscr == null) {
+                subscr = new EventSubscription(idFactory, sInfo);
+                if (sInfo.getSession().isLive()) {
+                    ObservationManager obsMgr = sInfo.getSession().getWorkspace().getObservationManager();
+                    obsMgr.addEventListener(subscr, EventSubscription.ALL_EVENTS,
+                            "/", true, null, null, true);
+                }
+                subscriptions.put(sInfo, subscr);
+            }
+        }
+        return subscr;
+    }
 
     private final class BatchImpl implements Batch {
 



Mime
View raw message