You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by md...@apache.org on 2013/07/31 12:57:09 UTC

svn commit: r1508806 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr: RepositoryImpl.java delegate/SessionDelegate.java

Author: mduerig
Date: Wed Jul 31 10:57:09 2013
New Revision: 1508806

URL: http://svn.apache.org/r1508806
Log:
OAK-803: Backwards compatibility of long-lived sessions
Make default refresh interval configurable through default-refresh-interval feature flag

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java?rev=1508806&r1=1508805&r2=1508806&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java Wed Jul 31 10:57:09 2013
@@ -17,7 +17,6 @@
 package org.apache.jackrabbit.oak.jcr;
 
 import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.concurrent.TimeUnit.SECONDS;
 
 import java.util.Collections;
 import java.util.Map;
@@ -65,7 +64,7 @@ public class RepositoryImpl implements J
     /**
      * Default value for {@link #REFRESH_INTERVAL}.
      */
-    private static final long DEFAULT_REFRESH_INTERVAL = SECONDS.toMillis(1);
+    private static final long DEFAULT_REFRESH_INTERVAL = Long.getLong("default-refresh-interval", 1);
 
     private final Descriptors descriptors = new Descriptors(new SimpleValueFactory());
     private final ContentRepository contentRepository;
@@ -195,7 +194,7 @@ public class RepositoryImpl implements J
             }
             Long refreshInterval = getRefreshInterval(credentials);
             if (refreshInterval == null) {
-                refreshInterval = getLong(attributes, REFRESH_INTERVAL);
+                refreshInterval = getRefreshInterval(attributes);
             } else if (attributes.containsKey(REFRESH_INTERVAL)) {
                 throw new RepositoryException("Duplicate attribute '" + REFRESH_INTERVAL + "'.");
             }
@@ -243,8 +242,8 @@ public class RepositoryImpl implements J
         return null;
     }
 
-    private static Long getLong(Map<String, Object> attributes, String name) {
-        return toLong(attributes.get(name));
+    private static Long getRefreshInterval(Map<String, Object> attributes) {
+        return toLong(attributes.get(REFRESH_INTERVAL));
     }
 
     private static String getString(Map<String, Object> attributes, String name) {

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java?rev=1508806&r1=1508805&r2=1508806&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java Wed Jul 31 10:57:09 2013
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.oak.jcr.de
 import static com.google.common.base.Preconditions.checkNotNull;
 import static java.util.concurrent.TimeUnit.MILLISECONDS;
 import static java.util.concurrent.TimeUnit.MINUTES;
+import static java.util.concurrent.TimeUnit.SECONDS;
 
 import java.io.IOException;
 
@@ -67,12 +68,16 @@ public class SessionDelegate {
      * Create a new session delegate for a {@code ContentSession}. The refresh behaviour of the
      * session is governed by the value of the {@code refreshInterval} argument: if the session
      * has been idle longer than that value, an implicit refresh will take place.
+     * In addition a refresh can always be scheduled from the next access by an explicit call
+     * to {@link #refreshAtNextAccess()}. This is typically done from within the observation event
+     * dispatcher in order.
+     *
      * @param contentSession  the content session
-     * @param refreshInterval  refresh interval in seconds or {@code -1} for never.
+     * @param refreshInterval  refresh interval in seconds.
      */
     public SessionDelegate(@Nonnull ContentSession contentSession, long refreshInterval) {
         this.contentSession = checkNotNull(contentSession);
-        this.refreshInterval = refreshInterval;
+        this.refreshInterval = MILLISECONDS.convert(refreshInterval, SECONDS);
         this.root = contentSession.getLatestRoot();
         this.idManager = new IdentifierManager(root);
         this.initStackTrace = new Exception("The session was created here:");