jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r446866 - in /jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core: ./ observation/
Date Sat, 16 Sep 2006 12:34:26 GMT
Author: jukka
Date: Sat Sep 16 05:34:25 2006
New Revision: 446866

URL: http://svn.apache.org/viewvc?view=rev&rev=446866
Log:
JCR-565: Renamed ObservationManagerFactory to ObservationDispatcher and inlined the factory
method

Added:
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ObservationDispatcher.java
      - copied, changed from r446799, jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerFactory.java
Removed:
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerFactory.java
Modified:
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/DelegatingObservationDispatcher.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?view=diff&rev=446866&r1=446865&r2=446866
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
Sat Sep 16 05:34:25 2006
@@ -37,7 +37,7 @@
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.nodetype.virtual.VirtualNodeTypeStateManager;
 import org.apache.jackrabbit.core.observation.DelegatingObservationDispatcher;
-import org.apache.jackrabbit.core.observation.ObservationManagerFactory;
+import org.apache.jackrabbit.core.observation.ObservationDispatcher;
 import org.apache.jackrabbit.core.security.AuthContext;
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.PMContext;
@@ -712,12 +712,12 @@
         return getWorkspaceInfo(workspaceName).getItemStateProvider();
     }
 
-    ObservationManagerFactory getObservationManagerFactory(String workspaceName)
+    ObservationDispatcher getObservationDispatcher(String workspaceName)
             throws NoSuchWorkspaceException {
         // check sanity of this instance
         sanityCheck();
 
-        return getWorkspaceInfo(workspaceName).getObservationManagerFactory();
+        return getWorkspaceInfo(workspaceName).getObservationDispatcher();
     }
 
     /**
@@ -1292,9 +1292,9 @@
         private SharedItemStateManager itemStateMgr;
 
         /**
-         * observation manager factory (instantiated on init)
+         * observation dispatcher (instantiated on init)
          */
-        private ObservationManagerFactory obsMgrFactory;
+        private ObservationDispatcher dispatcher;
 
         /**
          * system session (lazily instantiated)
@@ -1453,17 +1453,17 @@
         }
 
         /**
-         * Returns the observation manager factory for this workspace
+         * Returns the observation dispatcher for this workspace
          *
-         * @return the observation manager factory for this workspace
+         * @return the observation dispatcher for this workspace
          */
-        ObservationManagerFactory getObservationManagerFactory() {
+        ObservationDispatcher getObservationDispatcher() {
             if (!isInitialized()) {
                 throw new IllegalStateException("workspace '" + getName()
                         + "' not initialized");
             }
 
-            return obsMgrFactory;
+            return dispatcher;
         }
 
         /**
@@ -1623,10 +1623,10 @@
                     throw new RepositoryException(msg, ise);
                 }
 
-                obsMgrFactory = new ObservationManagerFactory();
+                dispatcher = new ObservationDispatcher();
 
                 // register the observation factory of that workspace
-                delegatingDispatcher.addDispatcher(obsMgrFactory);
+                delegatingDispatcher.addDispatcher(dispatcher);
 
                 initialized = true;
 
@@ -1691,11 +1691,11 @@
                 log.info("shutting down workspace '" + getName() + "'...");
 
                 // deregister the observation factory of that workspace
-                delegatingDispatcher.removeDispatcher(obsMgrFactory);
+                delegatingDispatcher.removeDispatcher(dispatcher);
 
                 // dispose observation manager factory
-                obsMgrFactory.dispose();
-                obsMgrFactory = null;
+                dispatcher.dispose();
+                dispatcher = null;
 
                 // shutdown search managers
                 if (searchMgr != null) {

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java?view=diff&rev=446866&r1=446865&r2=446866
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
Sat Sep 16 05:34:25 2006
@@ -21,7 +21,7 @@
 import org.apache.jackrabbit.core.lock.LockManager;
 import org.apache.jackrabbit.core.observation.EventStateCollection;
 import org.apache.jackrabbit.core.observation.EventStateCollectionFactory;
-import org.apache.jackrabbit.core.observation.ObservationManagerFactory;
+import org.apache.jackrabbit.core.observation.ObservationDispatcher;
 import org.apache.jackrabbit.core.observation.ObservationManagerImpl;
 import org.apache.jackrabbit.core.query.QueryManagerImpl;
 import org.apache.jackrabbit.core.state.LocalItemStateManager;
@@ -532,18 +532,22 @@
     }
 
     /**
-     * {@inheritDoc}
+     * Returns the observation manager of this session. The observation manager
+     * is lazily created if it does not exist yet.
+     *
+     * @return the observation manager of this session
+     * @throws RepositoryException if a repository error occurs
      */
     public ObservationManager getObservationManager()
-            throws UnsupportedRepositoryOperationException, RepositoryException {
+            throws RepositoryException {
         // check state of this instance
         sanityCheck();
 
         if (obsMgr == null) {
             try {
-                ObservationManagerFactory factory =
-                        rep.getObservationManagerFactory(wspConfig.getName());
-                obsMgr = factory.createObservationManager(session, session.getItemManager());
+                obsMgr = new ObservationManagerImpl(
+                        rep.getObservationDispatcher(wspConfig.getName()),
+                        session, session.getItemManager());
             } catch (NoSuchWorkspaceException nswe) {
                 // should never get here
                 String msg = "internal error: failed to instantiate observation manager";

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/DelegatingObservationDispatcher.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/DelegatingObservationDispatcher.java?view=diff&rev=446866&r1=446865&r2=446866
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/DelegatingObservationDispatcher.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/DelegatingObservationDispatcher.java
Sat Sep 16 05:34:25 2006
@@ -42,24 +42,24 @@
     private final HashSet dispatchers = new HashSet();
 
     /**
-     * Adds a new observation factory to the set of dispatchers
+     * Adds a new observation dispatcher to the set of dispatchers
      *
-     * @param disp
+     * @param dispatcher observation dispatcher
      */
-    public void addDispatcher(ObservationManagerFactory disp) {
+    public void addDispatcher(ObservationDispatcher dispatcher) {
         synchronized (dispatchers) {
-            dispatchers.add(disp);
+            dispatchers.add(dispatcher);
         }
     }
 
     /**
-     * Removes a observation factory from the set of dispatchers
+     * Removes a observation dispatcher from the set of dispatchers
      *
-     * @param disp
+     * @param dispatcher observation dispatcher
      */
-    public void removeDispatcher(ObservationManagerFactory disp) {
+    public void removeDispatcher(ObservationDispatcher dispatcher) {
         synchronized (dispatchers) {
-            dispatchers.remove(disp);
+            dispatchers.remove(dispatcher);
         }
     }
 
@@ -68,6 +68,7 @@
      * given as argument.
      *
      * @param session event source
+     * @param pathPrefix event path prefix
      * @return new <code>EventStateCollection</code> instance
      */
     public EventStateCollection createEventStateCollection(SessionImpl session,
@@ -103,16 +104,17 @@
      * {@link EventStateCollection} is created for every dispatcher, fille with
      * the given event list and then dispatched.
      *
-     * @param eventList
-     * @param session
+     * @param eventList list of events
+     * @param session current session
+     * @param pathPrefix event path prefix
      */
     public void dispatch(List eventList, SessionImpl session, Path pathPrefix) {
-        ObservationManagerFactory[] disp;
+        ObservationDispatcher[] disp;
         synchronized (dispatchers) {
-            disp = (ObservationManagerFactory[]) dispatchers.toArray(
-                    new ObservationManagerFactory[dispatchers.size()]);
+            disp = (ObservationDispatcher[]) dispatchers.toArray(
+                    new ObservationDispatcher[dispatchers.size()]);
         }
-        for (int i=0; i< disp.length; i++) {
+        for (int i = 0; i < disp.length; i++) {
             EventStateCollection events =
                     new EventStateCollection(disp[i], session, pathPrefix);
             try {

Copied: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ObservationDispatcher.java
(from r446799, jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerFactory.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ObservationDispatcher.java?view=diff&rev=446866&p1=jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerFactory.java&r1=446799&p2=jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ObservationDispatcher.java&r2=446866
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerFactory.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ObservationDispatcher.java
Sat Sep 16 05:34:25 2006
@@ -19,8 +19,6 @@
 import org.apache.commons.collections.Buffer;
 import org.apache.commons.collections.BufferUtils;
 import org.apache.commons.collections.buffer.UnboundedFifoBuffer;
-import org.apache.jackrabbit.core.ItemManager;
-import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.state.ChangeLog;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -31,19 +29,16 @@
 import java.util.Set;
 
 /**
- * The class <code>ObservationManagerFactory</code> creates new
- * <code>ObservationManager</code> instances for sessions. It also
- * creates new {@link EventStateCollection}s that can be dispatched
- * to registered {@link javax.jcr.observation.EventListener}s.
+ * Dispatcher for dispatching events to listeners within a single workspace.
  */
-public final class ObservationManagerFactory extends EventDispatcher
+public final class ObservationDispatcher extends EventDispatcher
         implements Runnable {
 
     /**
      * Logger instance for this class
      */
     private static final Logger log
-            = LoggerFactory.getLogger(ObservationManagerFactory.class);
+            = LoggerFactory.getLogger(ObservationDispatcher.class);
 
     /**
      * Dummy DispatchAction indicating the notification thread to end
@@ -87,10 +82,10 @@
     private Thread notificationThread;
 
     /**
-     * Creates a new <code>ObservationManagerFactory</code> instance
+     * Creates a new <code>ObservationDispatcher</code> instance
      * and starts the notification thread deamon.
      */
-    public ObservationManagerFactory() {
+    public ObservationDispatcher() {
         notificationThread = new Thread(this, "ObservationManager");
         notificationThread.setDaemon(true);
         notificationThread.start();
@@ -132,19 +127,6 @@
             }
             return synchronousReadOnlyConsumers;
         }
-    }
-
-    /**
-     * Creates a new <code>session</code> local <code>ObservationManager</code>
-     * with an associated <code>NamespaceResolver</code>.
-     *
-     * @param session the session.
-     * @param itemMgr the <code>ItemManager</code> of the <code>session</code>.
-     * @return an <code>ObservationManager</code>.
-     */
-    public ObservationManagerImpl createObservationManager(SessionImpl session,
-                                                           ItemManager itemMgr) {
-        return new ObservationManagerImpl(this, session, itemMgr);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java?view=diff&rev=446866&r1=446865&r2=446866
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java
Sat Sep 16 05:34:25 2006
@@ -53,9 +53,9 @@
     private final ItemManager itemMgr;
 
     /**
-     * The <code>ObservationManagerFactory</code>
+     * The <code>ObservationDispatcher</code>
      */
-    private final ObservationManagerFactory obsMgrFactory;
+    private final ObservationDispatcher dispatcher;
 
     static {
         // preload EventListenerIteratorImpl to prevent classloader issues during shutdown
@@ -65,6 +65,7 @@
     /**
      * Creates an <code>ObservationManager</code> instance.
      *
+     * @param dispatcher observation dispatcher
      * @param session the <code>Session</code> this ObservationManager
      *                belongs to.
      * @param itemMgr {@link org.apache.jackrabbit.core.ItemManager} of the passed
@@ -72,7 +73,7 @@
      * @throws NullPointerException if <code>session</code> or <code>itemMgr</code>
      *                              is <code>null</code>.
      */
-    ObservationManagerImpl(ObservationManagerFactory obsMgrFactory,
+    public ObservationManagerImpl(ObservationDispatcher dispatcher,
                            SessionImpl session,
                            ItemManager itemMgr) throws NullPointerException {
         if (session == null) {
@@ -82,7 +83,7 @@
             throw new NullPointerException("itemMgr");
         }
 
-        this.obsMgrFactory = obsMgrFactory;
+        this.dispatcher = dispatcher;
         this.session = session;
         this.itemMgr = itemMgr;
     }
@@ -136,9 +137,7 @@
                 nodeTypes,
                 noLocal);
 
-        EventConsumer consumer =
-                new EventConsumer(session, listener, filter);
-        obsMgrFactory.addConsumer(consumer);
+        dispatcher.addConsumer(new EventConsumer(session, listener, filter));
     }
 
     /**
@@ -146,9 +145,8 @@
      */
     public void removeEventListener(EventListener listener)
             throws RepositoryException {
-        EventConsumer consumer =
-                new EventConsumer(session, listener, EventFilter.BLOCK_ALL);
-        obsMgrFactory.removeConsumer(consumer);
+        dispatcher.removeConsumer(
+                new EventConsumer(session, listener, EventFilter.BLOCK_ALL));
 
     }
 
@@ -157,9 +155,10 @@
      */
     public EventListenerIterator getRegisteredEventListeners()
             throws RepositoryException {
-        return new EventListenerIteratorImpl(session,
-                obsMgrFactory.getSynchronousConsumers(),
-                obsMgrFactory.getAsynchronousConsumers());
+        return new EventListenerIteratorImpl(
+                session,
+                dispatcher.getSynchronousConsumers(),
+                dispatcher.getAsynchronousConsumers());
     }
 
     /**
@@ -188,6 +187,6 @@
      * which is attached to this <code>ObservationManager</code> instance.
      */
     public EventStateCollection createEventStateCollection() {
-        return new EventStateCollection(obsMgrFactory, session, null);
+        return new EventStateCollection(dispatcher, session, null);
     }
 }



Mime
View raw message