jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1547593 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/
Date Tue, 03 Dec 2013 21:28:55 GMT
Author: mduerig
Date: Tue Dec  3 21:28:55 2013
New Revision: 1547593

URL: http://svn.apache.org/r1547593
Log:
OAK-1120: Enhance observation mechanism to support Apache Sling
Loop registration of observation listeners through the whiteboard instead of having ContentSession
implement Observable

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentSessionImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeProcessor.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/SessionContext.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentSessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentSessionImpl.java?rev=1547593&r1=1547592&r2=1547593&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentSessionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentSessionImpl.java
Tue Dec  3 21:28:55 2013
@@ -16,10 +16,8 @@
  */
 package org.apache.jackrabbit.oak.core;
 
-import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkState;
 
-import java.io.Closeable;
 import java.io.IOException;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicLong;
@@ -30,9 +28,7 @@ import javax.security.auth.login.LoginEx
 import org.apache.jackrabbit.oak.api.AuthInfo;
 import org.apache.jackrabbit.oak.api.ContentSession;
 import org.apache.jackrabbit.oak.api.Root;
-import org.apache.jackrabbit.oak.spi.commit.Observable;
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
-import org.apache.jackrabbit.oak.spi.commit.Observer;
 import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
 import org.apache.jackrabbit.oak.spi.security.SecurityProvider;
 import org.apache.jackrabbit.oak.spi.security.authentication.LoginContext;
@@ -43,7 +39,7 @@ import org.slf4j.LoggerFactory;
 /**
  * {@code MicroKernel}-based implementation of the {@link ContentSession} interface.
  */
-class ContentSessionImpl implements ContentSession, Observable {
+class ContentSessionImpl implements ContentSession {
 
     private static final Logger log = LoggerFactory.getLogger(ContentSessionImpl.class);
 
@@ -68,7 +64,6 @@ class ContentSessionImpl implements Cont
                               @Nonnull NodeStore store,
                               @Nonnull CommitHook hook,
                               @Nonnull QueryIndexProvider indexProvider) {
-        checkArgument(store instanceof Observable);
         this.loginContext = loginContext;
         this.securityProvider = securityProvider;
         this.workspaceName = workspaceName;
@@ -118,11 +113,6 @@ class ContentSessionImpl implements Cont
         };
     }
 
-    @Override
-    public Closeable addObserver(Observer observer) {
-        return ((Observable) store).addObserver(observer);
-    }
-
     //-----------------------------------------------------------< Closable >---
     @Override
     public synchronized void close() throws IOException {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeProcessor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeProcessor.java?rev=1547593&r1=1547592&r2=1547593&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeProcessor.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeProcessor.java
Tue Dec  3 21:28:55 2013
@@ -18,11 +18,8 @@
  */
 package org.apache.jackrabbit.oak.plugins.observation;
 
-import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkState;
 
-import java.io.Closeable;
-import java.io.IOException;
 import java.util.concurrent.atomic.AtomicReference;
 
 import javax.annotation.Nonnull;
@@ -40,7 +37,6 @@ import org.apache.jackrabbit.oak.namepat
 import org.apache.jackrabbit.oak.plugins.observation.filter.EventIterator;
 import org.apache.jackrabbit.oak.plugins.observation.filter.FilterProvider;
 import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
-import org.apache.jackrabbit.oak.spi.commit.Observable;
 import org.apache.jackrabbit.oak.spi.commit.Observer;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.whiteboard.Registration;
@@ -65,8 +61,8 @@ public class ChangeProcessor implements 
     private final EventListener eventListener;
     private final AtomicReference<FilterProvider> filterProvider;
 
-    private Closeable observer;
-    private Registration mbean;
+    private Registration observerSubscription;
+    private Registration mBeanSubscription;
     private NodeState previousRoot;
     private boolean stopping;
 
@@ -74,7 +70,6 @@ public class ChangeProcessor implements 
             ContentSession contentSession,
             NamePathMapper namePathMapper,
             ListenerTracker tracker, FilterProvider filter) {
-        checkArgument(contentSession instanceof Observable);
         this.contentSession = contentSession;
         this.namePathMapper = namePathMapper;
         this.tracker = tracker;
@@ -97,11 +92,10 @@ public class ChangeProcessor implements 
      * @throws IllegalStateException if started already
      */
     public synchronized void start(Whiteboard whiteboard) {
-        checkState(observer == null, "Change processor started already");
-        observer = ((Observable) contentSession).addObserver(this);
-        mbean = WhiteboardUtils.registerMBean(whiteboard, EventListenerMBean.class,
+        checkState(observerSubscription == null, "Change processor started already");
+        observerSubscription = WhiteboardUtils.registerObserver(whiteboard, this);
+        mBeanSubscription = WhiteboardUtils.registerMBean(whiteboard, EventListenerMBean.class,
                 tracker.getListenerMBean(), "EventListener", tracker.toString());
-
     }
 
     /**
@@ -110,14 +104,10 @@ public class ChangeProcessor implements 
      * @throws IllegalStateException if not yet started or stopped already
      */
     public synchronized void stop() {
-        checkState(observer != null, "Change processor not started");
-        try {
-            stopping = true;
-            mbean.unregister();
-            observer.close();
-        } catch (IOException e) {
-            log.error("Error while stopping change listener", e);
-        }
+        checkState(observerSubscription != null, "Change processor not started");
+        stopping = true;
+        mBeanSubscription.unregister();
+        observerSubscription.unregister();
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/SessionContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/SessionContext.java?rev=1547593&r1=1547592&r2=1547593&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/SessionContext.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/SessionContext.java
Tue Dec  3 21:28:55 2013
@@ -42,7 +42,6 @@ import org.apache.jackrabbit.api.securit
 import org.apache.jackrabbit.api.security.authorization.PrivilegeManager;
 import org.apache.jackrabbit.api.security.principal.PrincipalManager;
 import org.apache.jackrabbit.api.security.user.UserManager;
-import org.apache.jackrabbit.oak.api.ContentSession;
 import org.apache.jackrabbit.oak.jcr.delegate.AccessControlManagerDelegator;
 import org.apache.jackrabbit.oak.jcr.delegate.JackrabbitAccessControlManagerDelegator;
 import org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate;
@@ -58,7 +57,6 @@ import org.apache.jackrabbit.oak.namepat
 import org.apache.jackrabbit.oak.namepath.NamePathMapperImpl;
 import org.apache.jackrabbit.oak.plugins.nodetype.ReadOnlyNodeTypeManager;
 import org.apache.jackrabbit.oak.plugins.value.ValueFactoryImpl;
-import org.apache.jackrabbit.oak.spi.commit.Observable;
 import org.apache.jackrabbit.oak.spi.security.SecurityConfiguration;
 import org.apache.jackrabbit.oak.spi.security.SecurityProvider;
 import org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration;
@@ -250,11 +248,6 @@ public class SessionContext implements N
     @Nonnull
     public ObservationManager getObservationManager() throws UnsupportedRepositoryOperationException
{
         if (observationManager == null) {
-            ContentSession contentSession = getSessionDelegate().getContentSession();
-            if (!(contentSession instanceof Observable)) {
-                throw new UnsupportedRepositoryOperationException("Observation not supported
for session " + contentSession);
-            }
-
             observationManager = new ObservationManagerImpl(
                 delegate,
                 ReadOnlyNodeTypeManager.getInstance(delegate.getRoot(), namePathMapper),



Mime
View raw message