jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r388123 - in /jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core: ./ nodetype/virtual/ observation/ version/
Date Thu, 23 Mar 2006 09:40:05 GMT
Author: mreutegg
Date: Thu Mar 23 01:39:44 2006
New Revision: 388123

URL: http://svn.apache.org/viewcvs?rev=388123&view=rev
Log:
JCR-257: Use separate index for jcr:system tree

Removed:
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/SystemSearchManager.java
Modified:
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.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/EventStateCollection.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?rev=388123&r1=388122&r2=388123&view=diff
==============================================================================
--- 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
Thu Mar 23 01:39:44 2006
@@ -251,6 +251,9 @@
             throw e;
         }
 
+        // initialize system search manager
+        getSystemSearchManager(wspName);
+
         // amount of time in seconds before an idle workspace is automatically
         // shut down
         int maxIdleTime = repConfig.getWorkspaceMaxIdleTime();
@@ -558,8 +561,9 @@
             try {
                 if (repConfig.getSearchConfig() != null) {
                     SystemSession defSysSession = getSystemSession(wspName);
-                    systemSearchMgr = new SystemSearchManager(repConfig.getSearchConfig(),
-                            nsReg, ntReg, defSysSession.getItemStateManager(), SYSTEM_ROOT_NODE_ID);
+                    systemSearchMgr = new SearchManager(repConfig.getSearchConfig(),
+                            nsReg, ntReg, defSysSession.getItemStateManager(),
+                            SYSTEM_ROOT_NODE_ID, null, null);
                     ObservationManager obsMgr = defSysSession.getWorkspace().getObservationManager();
                     obsMgr.addEventListener(systemSearchMgr, Event.NODE_ADDED
                             | Event.NODE_REMOVED | Event.PROPERTY_ADDED

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java?rev=388123&r1=388122&r2=388123&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java
Thu Mar 23 01:39:44 2006
@@ -150,7 +150,7 @@
             throws RepositoryException {
 
         VersionManagerImpl vMgr = (VersionManagerImpl) rep.getVersionManager();
-        return new XAVersionManager(vMgr, rep.getNodeTypeRegistry(), wsp);
+        return new XAVersionManager(vMgr, rep.getNodeTypeRegistry(), this);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java?rev=388123&r1=388122&r2=388123&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java
Thu Mar 23 01:39:44 2006
@@ -27,6 +27,8 @@
 import org.apache.jackrabbit.core.observation.EventState;
 import org.apache.jackrabbit.core.virtual.VirtualItemStateProvider;
 import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.name.MalformedPathException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -48,6 +50,23 @@
      */
     private static Logger log = LoggerFactory.getLogger(VirtualNodeTypeStateManager.class);
 
+    /**
+     * Path: /jcr:system/jcr:nodeTypes
+     */
+    private static final Path NODE_TYPES_PATH;
+
+    static {
+        try {
+            Path.PathBuilder builder = new Path.PathBuilder();
+            builder.addRoot();
+            builder.addLast(QName.JCR_SYSTEM);
+            builder.addLast(QName.JCR_NODETYPES);
+            NODE_TYPES_PATH = builder.getPath();
+        } catch (MalformedPathException e) {
+            // will not happen. path is always valid
+            throw new InternalError("Cannot initialize path");
+        }
+    }
 
     /**
      * an item state provider for the virtual nodetype states
@@ -134,7 +153,7 @@
                 NodeImpl child = root.getNode(ntName);
                 List events = new ArrayList();
                 recursiveAdd(events, root, child);
-                obsDispatcher.dispatch(events, systemSession);
+                obsDispatcher.dispatch(events, systemSession, NODE_TYPES_PATH);
             }
         } catch (RepositoryException e) {
             log.error("Unable to index new nodetype: " + e.toString());
@@ -161,7 +180,7 @@
                 NodeImpl child = root.getNode(ntName);
                 List events = new ArrayList();
                 recursiveRemove(events, root, child);
-                obsDispatcher.dispatch(events, systemSession);
+                obsDispatcher.dispatch(events, systemSession, NODE_TYPES_PATH);
             }
             if (virtProvider != null) {
                 // allow provider to update

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/DelegatingObservationDispatcher.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/DelegatingObservationDispatcher.java?rev=388123&r1=388122&r2=388123&view=diff
==============================================================================
--- 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
Thu Mar 23 01:39:44 2006
@@ -18,6 +18,7 @@
 
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.state.ChangeLog;
+import org.apache.jackrabbit.name.Path;
 
 import java.util.HashSet;
 import java.util.Iterator;
@@ -59,8 +60,9 @@
      * @param session event source
      * @return new <code>EventStateCollection</code> instance
      */
-    public EventStateCollection createEventStateCollection(SessionImpl session) {
-        return new EventStateCollection(this, session);
+    public EventStateCollection createEventStateCollection(SessionImpl session,
+                                                           Path pathPrefix) {
+        return new EventStateCollection(this, session, pathPrefix);
     }
 
     //------------------------------------------------------< EventDispatcher >
@@ -83,7 +85,7 @@
      * {@inheritDoc}
      */
     void dispatchEvents(EventStateCollection events) {
-        dispatch(events.getEvents(), events.getSession());
+        dispatch(events.getEvents(), events.getSession(), events.getPathPrefix());
     }
 
     /**
@@ -94,11 +96,11 @@
      * @param eventList
      * @param session
      */
-    public void dispatch(List eventList, SessionImpl session) {
+    public void dispatch(List eventList, SessionImpl session, Path pathPrefix) {
         Iterator iter = dispatchers.iterator();
         while (iter.hasNext()) {
             ObservationManagerFactory fac = (ObservationManagerFactory) iter.next();
-            EventStateCollection events = new EventStateCollection(fac, session);
+            EventStateCollection events = new EventStateCollection(fac, session, pathPrefix);
             events.addAll(eventList);
             events.prepare();
             events.dispatch();

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java?rev=388123&r1=388122&r2=388123&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
Thu Mar 23 01:39:44 2006
@@ -82,15 +82,30 @@
     private final SessionImpl session;
 
     /**
+     * The prefix to use for the event paths or <code>null</code> if no prefix
+     * should be used.
+     */
+    private final Path pathPrefix;
+
+    /**
      * Creates a new empty <code>EventStateCollection</code>.
+     * <p/>
+     * Because the item state manager in {@link #createEventStates} may represent
+     * only a subset of the over all item state hierarchy, this constructor
+     * also takes a path prefix argument. If non <code>null</code> all events
+     * created by this collection are prefixed with this path.
      *
      * @param dispatcher event dispatcher
-     * @param session the session that created these events.
+     * @param session    the session that created these events.
+     * @param pathPrefix the path to prefix the event paths or <code>null</code>
+     *                   if no prefix should be used.
      */
     EventStateCollection(EventDispatcher dispatcher,
-                         SessionImpl session) {
+                         SessionImpl session,
+                         Path pathPrefix) {
         this.dispatcher = dispatcher;
         this.session = session;
+        this.pathPrefix = pathPrefix;
     }
 
     /**
@@ -99,17 +114,17 @@
      *
      * @param rootNodeId   the id of the root node.
      * @param changes      the changes on <code>ItemState</code>s.
-     * @param provider     an <code>ItemStateProvider</code> to provide <code>ItemState</code>
+     * @param stateMgr     an <code>ItemStateManager</code> to provide <code>ItemState</code>
      *                     of items that are not contained in the <code>changes</code>
collection.
      * @throws ItemStateException if an error occurs while creating events
      *                            states for the item state changes.
      */
-    public void createEventStates(NodeId rootNodeId, ChangeLog changes, ItemStateManager
provider) throws ItemStateException {
+    public void createEventStates(NodeId rootNodeId, ChangeLog changes, ItemStateManager
stateMgr) throws ItemStateException {
         // create a hierarchy manager, that is based on the ChangeLog and
         // the ItemStateProvider
         // todo use CachingHierarchyManager ?
         ChangeLogBasedHierarchyMgr hmgr =
-                new ChangeLogBasedHierarchyMgr(rootNodeId, provider, changes,
+                new ChangeLogBasedHierarchyMgr(rootNodeId, stateMgr, changes,
                         session.getNamespaceResolver());
 
         /**
@@ -158,7 +173,7 @@
                         } catch (NoSuchItemStateException e) {
                             // old parent has been deleted, retrieve from
                             // shared item state manager
-                            oldParent = (NodeState) provider.getItemState(oldParentId);
+                            oldParent = (NodeState) stateMgr.getItemState(oldParentId);
                         }
 
                         NodeTypeImpl oldParentNodeType = getNodeType(oldParent, session);
@@ -291,7 +306,7 @@
             } else {
                 // property changed
                 Path path = getPath(state.getId(), hmgr);
-                NodeState parent = (NodeState) provider.getItemState(state.getParentId());
+                NodeState parent = (NodeState) stateMgr.getItemState(state.getParentId());
                 NodeTypeImpl nodeType = getNodeType(parent, session);
                 Set mixins = parent.getMixinTypeNames();
                 events.add(EventState.propertyChanged(state.getParentId(),
@@ -310,7 +325,7 @@
             if (state.isNode()) {
                 // node deleted
                 NodeState n = (NodeState) state;
-                NodeState parent = (NodeState) provider.getItemState(n.getParentId());
+                NodeState parent = (NodeState) stateMgr.getItemState(n.getParentId());
                 NodeTypeImpl nodeType = getNodeType(parent, session);
                 Set mixins = parent.getMixinTypeNames();
                 Path path = getZombiePath(state.getId(), hmgr);
@@ -352,8 +367,8 @@
                 NodeId parentId = n.getParentId();
                 NodeState parent;
                 // unknown if parent node is also new
-                if (provider.hasItemState(parentId)) {
-                    parent = (NodeState) provider.getItemState(parentId);
+                if (stateMgr.hasItemState(parentId)) {
+                    parent = (NodeState) stateMgr.getItemState(parentId);
                 } else {
                     parent = (NodeState) changes.get(parentId);
                 }
@@ -416,6 +431,17 @@
     }
 
     /**
+     * Returns the path prefix for this event state collection or <code>null</code>
+     * if no path prefix was set in the constructor of this collection. See
+     * also {@link EventStateCollection#EventStateCollection}.
+     *
+     * @return the path prefix for this event state collection.
+     */
+    public Path getPathPrefix() {
+        return pathPrefix;
+    }
+
+    /**
      * Returns an iterator over {@link EventState} instance.
      *
      * @return an iterator over {@link EventState} instance.
@@ -491,7 +517,7 @@
     private Path getPath(ItemId itemId, HierarchyManager hmgr)
             throws ItemStateException {
         try {
-            return hmgr.getPath(itemId);
+            return prefixPath(hmgr.getPath(itemId));
         } catch (RepositoryException e) {
             // should never happen actually
             String msg = "Unable to resolve path for item: " + itemId;
@@ -511,12 +537,39 @@
     private Path getZombiePath(ItemId itemId, ChangeLogBasedHierarchyMgr hmgr)
             throws ItemStateException {
         try {
-            return hmgr.getZombiePath(itemId);
+            return prefixPath(hmgr.getZombiePath(itemId));
         } catch (RepositoryException e) {
             // should never happen actually
             String msg = "Unable to resolve zombie path for item: " + itemId;
             log.error(msg);
             throw new ItemStateException(msg, e);
+        }
+    }
+
+    /**
+     * Prefixes the Path <code>p</code> with {@link #pathPrefix}.
+     *
+     * @param p the Path to prefix.
+     * @return the prefixed path or <code>p</code> itself if {@link #pathPrefix}
+     *         is <code>null</code>.
+     * @throws RepositoryException if the path cannot be prefixed.
+     */
+    private Path prefixPath(Path p) throws RepositoryException {
+        if (pathPrefix == null) {
+            return p;
+        }
+        Path.PathBuilder builder = new Path.PathBuilder(pathPrefix.getElements());
+        Path.PathElement[] elements = p.getElements();
+        for (int i = 0; i < elements.length; i++) {
+            if (elements[i].denotesRoot()) {
+                continue;
+            }
+            builder.addLast(elements[i]);
+        }
+        try {
+            return builder.getPath();
+        } catch (MalformedPathException e) {
+            throw new RepositoryException(e);
         }
     }
 }

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java?rev=388123&r1=388122&r2=388123&view=diff
==============================================================================
--- 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
Thu Mar 23 01:39:44 2006
@@ -187,6 +187,6 @@
      * which is attached to this <code>ObservationManager</code> instance.
      */
     public EventStateCollection createEventStateCollection() {
-        return new EventStateCollection(obsMgrFactory, session);
+        return new EventStateCollection(obsMgrFactory, session, null);
     }
 }

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java?rev=388123&r1=388122&r2=388123&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
Thu Mar 23 01:39:44 2006
@@ -38,6 +38,8 @@
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.virtual.VirtualItemStateProvider;
 import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.name.MalformedPathException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -66,6 +68,24 @@
     private static Logger log = LoggerFactory.getLogger(VersionManager.class);
 
     /**
+     * The path to the version storage: /jcr:system/jcr:versionStorage
+     */
+    private static final Path VERSION_STORAGE_PATH;
+
+    static {
+        try {
+            Path.PathBuilder builder = new Path.PathBuilder();
+            builder.addRoot();
+            builder.addLast(QName.JCR_SYSTEM);
+            builder.addLast(QName.JCR_VERSIONSTORAGE);
+            VERSION_STORAGE_PATH = builder.getPath();
+        } catch (MalformedPathException e) {
+            // will not happen. path is always valid
+            throw new InternalError("Cannot initialize path");
+        }
+    }
+
+    /**
      * The persistence manager for the versions
      */
     private final PersistenceManager pMgr;
@@ -454,7 +474,16 @@
         if (eventSource == null) {
             throw new RepositoryException("Unknown event source.");
         }
-        return obsMgr.createEventStateCollection(eventSource);
+        return createEventStateCollection(eventSource);
+    }
+
+    /**
+     * Creates an {@link EventStateCollection} using the given <code>source</code>.
+     * @param source the Session that did the changes.
+     * @return <code>EventStateCollection</code>.
+     */
+    EventStateCollection createEventStateCollection(SessionImpl source) {
+        return obsMgr.createEventStateCollection(source, VERSION_STORAGE_PATH);
     }
 
     //--------------------------------------------------------< inner classes >

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java?rev=388123&r1=388122&r2=388123&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
Thu Mar 23 01:39:44 2006
@@ -25,6 +25,7 @@
 import org.apache.jackrabbit.core.TransactionException;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.observation.EventStateCollectionFactory;
+import org.apache.jackrabbit.core.observation.EventStateCollection;
 import org.apache.jackrabbit.core.state.ChangeLog;
 import org.apache.jackrabbit.core.state.ItemState;
 import org.apache.jackrabbit.core.state.ItemStateException;
@@ -53,7 +54,7 @@
  * manager.
  */
 public class XAVersionManager extends AbstractVersionManager
-        implements VirtualItemStateProvider, InternalXAResource {
+        implements EventStateCollectionFactory, VirtualItemStateProvider, InternalXAResource
{
 
     /**
      * Attribute name for associated change log.
@@ -76,6 +77,11 @@
     private NodeTypeRegistry ntReg;
 
     /**
+     * The session that uses this version manager.
+     */
+    private SessionImpl session;
+
+    /**
      * Items that have been modified and are part of the XA environment.
      */
     private Map xaItems;
@@ -84,13 +90,14 @@
      * Creates a new instance of this class.
      */
     public XAVersionManager(VersionManagerImpl vMgr, NodeTypeRegistry ntReg,
-                            EventStateCollectionFactory factory)
+                            SessionImpl session)
             throws RepositoryException {
 
         this.vMgr = vMgr;
         this.ntReg = ntReg;
+        this.session = session;
         this.stateMgr = new XAItemStateManager(vMgr.getSharedStateMgr(),
-                factory, CHANGE_LOG_ATTRIBUTE_NAME);
+                this, CHANGE_LOG_ATTRIBUTE_NAME);
 
         NodeState state;
         try {
@@ -99,6 +106,16 @@
             throw new RepositoryException("Unable to retrieve history root", e);
         }
         this.historyRoot = new NodeStateEx(stateMgr, ntReg, state, QName.JCR_VERSIONSTORAGE);
+    }
+
+    //------------------------------------------< EventStateCollectionFactory >
+
+    /**
+     * @inheritDoc
+     */
+    public EventStateCollection createEventStateCollection()
+            throws RepositoryException {
+        return vMgr.createEventStateCollection(session);
     }
 
     //-------------------------------------------------------< VersionManager >



Mime
View raw message