jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r506924 - in /jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit: server/ webdav/jcr/ webdav/jcr/observation/
Date Tue, 13 Feb 2007 09:25:53 GMT
Author: mreutegg
Date: Tue Feb 13 01:25:52 2007
New Revision: 506924

URL: http://svn.apache.org/viewvc?view=rev&rev=506924
Log:
Add PollTimeout header (required for spi2dav)

Modified:
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/AbstractWebdavServlet.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionManagerImpl.java

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/AbstractWebdavServlet.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/AbstractWebdavServlet.java?view=diff&rev=506924&r1=506923&r2=506924
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/AbstractWebdavServlet.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/AbstractWebdavServlet.java
Tue Feb 13 01:25:52 2007
@@ -809,7 +809,8 @@
             response.sendError(DavServletResponse.SC_METHOD_NOT_ALLOWED);
             return;
         }
-        EventDiscovery ed = ((ObservationResource) resource).poll(request.getSubscriptionId());
+        EventDiscovery ed = ((ObservationResource) resource).poll(
+                request.getSubscriptionId(), request.getPollTimeout());
         response.sendPollResponse(ed);
     }
 

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java?view=diff&rev=506924&r1=506923&r2=506924
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java
Tue Feb 13 01:25:52 2007
@@ -289,11 +289,11 @@
     }
 
     /**
-     * @see ObservationResource#poll(String)
-     * @see SubscriptionManager#poll(String, org.apache.jackrabbit.webdav.observation.ObservationResource)
+     * @see ObservationResource#poll(String, long)
+     * @see SubscriptionManager#poll(String, long, org.apache.jackrabbit.webdav.observation.ObservationResource)
      */
-    public EventDiscovery poll(String subscriptionId) throws DavException {
-        return subsMgr.poll(subscriptionId, this);
+    public EventDiscovery poll(String subscriptionId, long timeout) throws DavException {
+        return subsMgr.poll(subscriptionId, timeout, this);
     }
 
     //--------------------------------------------------------------------------

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java?view=diff&rev=506924&r1=506923&r2=506924
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java
Tue Feb 13 01:25:52 2007
@@ -262,11 +262,20 @@
      * recorded since the last call to this method and clears the list of event
      * bundles.
      *
+     * @param timeout time in milliseconds to wait at most for events if none
+     *                are present currently.
      * @return object listing all events that were recorded.
      * @see #onEvent(EventIterator)
      */
-    synchronized EventDiscovery discoverEvents() {
+    synchronized EventDiscovery discoverEvents(long timeout) {
         EventDiscovery ed = new EventDiscovery();
+        if (eventBundles.isEmpty() && timeout > 0) {
+            try {
+                wait(timeout);
+            } catch (InterruptedException e) {
+                // continue and possibly return empty event discovery
+            }
+        }
         Iterator it = eventBundles.iterator();
         while (it.hasNext()) {
             EventBundle eb = (EventBundle) it.next();
@@ -335,13 +344,13 @@
     //--------------------------------------------< EventListener interface >---
     /**
      * Records the events passed as a new event bundle in order to make them
-     * available with the next {@link #discoverEvents()} request. If this
+     * available with the next {@link #discoverEvents(long)} request. If this
      * subscription is expired it will remove itself as listener from the
      * observation manager.
      *
      * @param events to be recorded.
      * @see EventListener#onEvent(EventIterator)
-     * @see #discoverEvents()
+     * @see #discoverEvents(long)
      */
     public synchronized void onEvent(EventIterator events) {
         if (!isExpired()) {
@@ -354,6 +363,7 @@
                 log.warn("Exception while unsubscribing: " + e);
             }
         }
+        notifyAll();
     }
 
     //--------------------------------------------------------------------------
@@ -445,7 +455,7 @@
      * provides the possibility to retrieve the Xml representation of the
      * bundle and the events included in order to respond to a POLL request.
      *
-     * @see SubscriptionImpl#discoverEvents()
+     * @see SubscriptionImpl#discoverEvents(long)
      */
     private class EventBundleImpl implements EventBundle {
 
@@ -508,7 +518,10 @@
             if (tId == null) {
                 tId = UUID.randomUUID().toString();
             }
-            eventBundles.add(new EventBundleImpl(events, tId));
+            synchronized (SubscriptionImpl.this) {
+                eventBundles.add(new EventBundleImpl(events, tId));
+                SubscriptionImpl.this.notifyAll();
+            }
         }
 
         //-----------------------------< TransactionListener >------------------

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionManagerImpl.java?view=diff&rev=506924&r1=506923&r2=506924
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionManagerImpl.java
Tue Feb 13 01:25:52 2007
@@ -184,14 +184,15 @@
      * by the given id.
      *
      * @param subscriptionId
+     * @param timeout timeout in milliseconds
      * @param resource
      * @return object encapsulating the events.
      */
-    public EventDiscovery poll(String subscriptionId, ObservationResource resource)
+    public EventDiscovery poll(String subscriptionId, long timeout, ObservationResource resource)
             throws DavException {
 
         SubscriptionImpl subs = validate(subscriptionId, resource);
-        return subs.discoverEvents();
+        return subs.discoverEvents(timeout);
     }
 
     /**



Mime
View raw message