jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r230483 - in /incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core: ./ nodetype/ state/ util/
Date Fri, 05 Aug 2005 15:17:29 GMT
Author: stefan
Date: Fri Aug  5 08:17:15 2005
New Revision: 230483

URL: http://svn.apache.org/viewcvs?rev=230483&view=rev
Log:
- fixed Serializable support of ItemId, ItemState and derived classes
- new internal utility interface util.Dumpable providing diagnostic
  output
- added Dumpable support to several internal components
- extracted ItemStateStore interface from ItemStateMap concrete class

Added:
    incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/ItemStateStore.java
  (with props)
    incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/util/Dumpable.java
  (with props)
Modified:
    incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/ItemId.java
    incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/ItemManager.java
    incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/NodeId.java
    incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/SessionImpl.java
    incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
    incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
    incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/ItemStateMap.java
    incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/ItemStateReferenceCache.java
    incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/NodeState.java
    incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/NodeStateListener.java
    incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/PropertyState.java
    incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
    incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
    incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/TransientItemStateManager.java

Modified: incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/ItemId.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/ItemId.java?rev=230483&r1=230482&r2=230483&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/ItemId.java (original)
+++ incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/ItemId.java Fri Aug
 5 08:17:15 2005
@@ -21,7 +21,7 @@
 /**
  * <code>ItemId</code> serves as the base class for the concrete classes
  * <code>PropertyId</code> and <code>NodeId</code> who uniquely identify
- * nodes and properties in the repository.
+ * nodes and properties in a workspace.
  */
 public abstract class ItemId implements Serializable {
 

Modified: incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/ItemManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/ItemManager.java?rev=230483&r1=230482&r2=230483&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/ItemManager.java (original)
+++ incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/ItemManager.java Fri
Aug  5 08:17:15 2005
@@ -33,6 +33,7 @@
 import org.apache.jackrabbit.core.version.InternalVersionHistory;
 import org.apache.jackrabbit.core.version.VersionHistoryImpl;
 import org.apache.jackrabbit.core.version.VersionImpl;
+import org.apache.jackrabbit.core.util.Dumpable;
 import org.apache.jackrabbit.name.NoPrefixDeclaredException;
 import org.apache.jackrabbit.name.Path;
 import org.apache.jackrabbit.name.QName;
@@ -74,7 +75,7 @@
  * If the parent <code>Session</code> is an <code>XASession</code>,
there is
  * one <code>ItemManager</code> instance per started global transaction.
  */
-public class ItemManager implements ItemLifeCycleListener, Constants {
+public class ItemManager implements ItemLifeCycleListener, Dumpable, Constants {
 
     private static Logger log = Logger.getLogger(ItemManager.class);
 
@@ -138,36 +139,6 @@
     }
 
     /**
-     * Dumps the state of this <code>ItemManager</code> instance
-     * (used for diagnostic purposes).
-     *
-     * @param ps
-     * @throws RepositoryException
-     */
-    void dump(PrintStream ps) throws RepositoryException {
-        ps.println("ItemManager (" + this + ")");
-        ps.println();
-        ps.println("Items in cache:");
-        ps.println();
-        Iterator iter = itemCache.keySet().iterator();
-        while (iter.hasNext()) {
-            ItemId id = (ItemId) iter.next();
-            ItemImpl item = (ItemImpl) itemCache.get(id);
-            if (item.isNode()) {
-                ps.print("Node: ");
-            } else {
-                ps.print("Property: ");
-            }
-            if (item.isTransient()) {
-                ps.print("transient ");
-            } else {
-                ps.print("          ");
-            }
-            ps.println(id + "\t" + item.getPath() + " (" + item + ")");
-        }
-    }
-
-    /**
      * Disposes this <code>ItemManager</code> and frees resources.
      */
     void dispose() {
@@ -701,5 +672,32 @@
         item.removeLifeCycleListener(this);
         // remove instance from cache
         evictItem(id);
+    }
+
+    //-------------------------------------------------------------< Dumpable >
+    /**
+     * {@inheritDoc}
+     */
+    public void dump(PrintStream ps) {
+        ps.println("ItemManager (" + this + ")");
+        ps.println();
+        ps.println("Items in cache:");
+        ps.println();
+        Iterator iter = itemCache.keySet().iterator();
+        while (iter.hasNext()) {
+            ItemId id = (ItemId) iter.next();
+            ItemImpl item = (ItemImpl) itemCache.get(id);
+            if (item.isNode()) {
+                ps.print("Node: ");
+            } else {
+                ps.print("Property: ");
+            }
+            if (item.isTransient()) {
+                ps.print("transient ");
+            } else {
+                ps.print("          ");
+            }
+            ps.println(id + "\t" + item.safeGetJCRPath() + " (" + item + ")");
+        }
     }
 }

Modified: incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/NodeId.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/NodeId.java?rev=230483&r1=230482&r2=230483&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/NodeId.java (original)
+++ incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/NodeId.java Fri Aug
 5 08:17:15 2005
@@ -17,7 +17,8 @@
 package org.apache.jackrabbit.core;
 
 /**
- * <code>NodeId</code> uniquely identifies a node in the repository.
+ * Node identifier. An instance of this class identifies a node using its UUID.
+ * Once created a node identifier instance is immutable.
  */
 public class NodeId extends ItemId {
 

Modified: incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/SessionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/SessionImpl.java?rev=230483&r1=230482&r2=230483&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/SessionImpl.java (original)
+++ incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/SessionImpl.java Fri
Aug  5 08:17:15 2005
@@ -37,6 +37,7 @@
 import org.apache.jackrabbit.core.xml.ImportHandler;
 import org.apache.jackrabbit.core.xml.SessionImporter;
 import org.apache.jackrabbit.core.xml.SysViewSAXEventGenerator;
+import org.apache.jackrabbit.core.util.Dumpable;
 import org.apache.jackrabbit.name.MalformedPathException;
 import org.apache.jackrabbit.name.NamespaceResolver;
 import org.apache.jackrabbit.name.Path;
@@ -90,7 +91,7 @@
 /**
  * A <code>SessionImpl</code> ...
  */
-public class SessionImpl implements Session {
+public class SessionImpl implements Session, Dumpable {
 
     private static Logger log = Logger.getLogger(SessionImpl.class);
 
@@ -394,27 +395,6 @@
     }
 
     /**
-     * Dumps the state of this <code>Session</code> instance
-     * (used for diagnostic purposes).
-     *
-     * @param ps
-     * @throws RepositoryException
-     */
-    public void dump(PrintStream ps) throws RepositoryException {
-        ps.print("Session: ");
-        if (userId == null) {
-            ps.print("unknown");
-        } else {
-            ps.print(userId);
-        }
-        ps.println(" (" + this + ")");
-        ps.println();
-        itemMgr.dump(ps);
-        ps.println();
-        itemStateMgr.dump(ps);
-    }
-
-    /**
      * Returns the names of all workspaces of this repository with respect of the
      * access rights of this session.
      *
@@ -1280,5 +1260,23 @@
                 }
             }
         }
+    }
+
+    //-------------------------------------------------------------< Dumpable >
+    /**
+     * {@inheritDoc}
+     */
+    public void dump(PrintStream ps) {
+        ps.print("Session: ");
+        if (userId == null) {
+            ps.print("unknown");
+        } else {
+            ps.print(userId);
+        }
+        ps.println(" (" + this + ")");
+        ps.println();
+        itemMgr.dump(ps);
+        ps.println();
+        itemStateMgr.dump(ps);
     }
 }

Modified: incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java?rev=230483&r1=230482&r2=230483&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
(original)
+++ incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
Fri Aug  5 08:17:15 2005
@@ -22,6 +22,7 @@
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.name.UnknownPrefixException;
 import org.apache.jackrabbit.util.IteratorHelper;
+import org.apache.jackrabbit.core.util.Dumpable;
 import org.apache.log4j.Logger;
 
 import javax.jcr.RepositoryException;
@@ -39,7 +40,7 @@
  * A <code>NodeTypeManagerImpl</code> implements a session dependant
  * NodeTypeManager.
  */
-public class NodeTypeManagerImpl implements NodeTypeManager,
+public class NodeTypeManagerImpl implements NodeTypeManager, Dumpable,
         NodeTypeRegistryListener {
 
     /**
@@ -288,14 +289,11 @@
         }
     }
 
-    //----------------------------------------------------------< diagnostics >
+    //-------------------------------------------------------------< Dumpable >
     /**
-     * Dumps the state of this <code>NodeTypeManagerImpl</code> instance.
-     *
-     * @param ps
-     * @throws RepositoryException
+     * {@inheritDoc}
      */
-    public void dump(PrintStream ps) throws RepositoryException {
+    public void dump(PrintStream ps) {
         ps.println("NodeTypeManager (" + this + ")");
         ps.println();
         ntReg.dump(ps);

Modified: incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java?rev=230483&r1=230482&r2=230483&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
(original)
+++ incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
Fri Aug  5 08:17:15 2005
@@ -22,6 +22,7 @@
 import org.apache.jackrabbit.core.fs.FileSystemException;
 import org.apache.jackrabbit.core.fs.FileSystemResource;
 import org.apache.jackrabbit.core.value.InternalValue;
+import org.apache.jackrabbit.core.util.Dumpable;
 import org.apache.jackrabbit.name.QName;
 import org.apache.log4j.Logger;
 
@@ -49,7 +50,7 @@
 /**
  * A <code>NodeTypeRegistry</code> ...
  */
-public class NodeTypeRegistry implements Constants {
+public class NodeTypeRegistry implements Dumpable, Constants {
 
     private static Logger log = Logger.getLogger(NodeTypeRegistry.class);
 
@@ -1346,14 +1347,11 @@
         return (PropDef) propDefs.get(id);
     }
 
-    //----------------------------------------------------------< diagnostics >
+    //-------------------------------------------------------------< Dumpable >
     /**
-     * Dumps the state of this <code>NodeTypeRegistry</code> instance.
-     *
-     * @param ps
-     * @throws RepositoryException
+     * {@inheritDoc}
      */
-    void dump(PrintStream ps) throws RepositoryException {
+    public void dump(PrintStream ps) {
         ps.println("NodeTypeRegistry (" + this + ")");
         ps.println();
         ps.println("Registered NodeTypes:");
@@ -1883,14 +1881,11 @@
             return sortedKeys.iterator();
         }
 
-        //------------------------------------------------------< diagnostics >
+        //---------------------------------------------------------< Dumpable >
         /**
-         * Dumps the state of this <code>EffectiveNodeTypeCache</code> instance.
-         *
-         * @param ps
-         * @throws RepositoryException
+         * {@inheritDoc}
          */
-        void dump(PrintStream ps) throws RepositoryException {
+        public void dump(PrintStream ps) {
             ps.println("EffectiveNodeTypeCache (" + this + ")");
             ps.println();
             ps.println("EffectiveNodeTypes in cache:");

Modified: incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/ItemStateMap.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/ItemStateMap.java?rev=230483&r1=230482&r2=230483&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/ItemStateMap.java
(original)
+++ incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/ItemStateMap.java
Fri Aug  5 08:17:15 2005
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.core.state;
 
 import org.apache.jackrabbit.core.ItemId;
+import org.apache.jackrabbit.core.util.Dumpable;
 import org.apache.log4j.Logger;
 
 import java.io.PrintStream;
@@ -28,19 +29,18 @@
 import java.util.Set;
 
 /**
- * An <code>ItemStateMap</code> stores <code>ItemState</code> instances
using
- * their <code>ItemId</code>s as key.
+ * A {@link java.util.Map} based <code>ItemStateStore</code> implementation.
  */
-public class ItemStateMap {
+public class ItemStateMap implements ItemStateStore, Dumpable {
     private static Logger log = Logger.getLogger(ItemStateMap.class);
 
     /**
-     * the map backing this <code>ItemStateMap</code> instance
+     * the map backing this <code>ItemStateStore</code> implementation
      */
     protected final Map map;
 
     /**
-     * Creates a new HashMap-backed <code>ItemStateMap</code> instance.
+     * Creates a new HashMap-backed <code>ItemStateStore</code> implementation.
      */
     public ItemStateMap() {
         this(new HashMap());
@@ -55,39 +55,23 @@
         this.map = map;
     }
 
-    //-------------------------------------------------------< public methods >
+    //-------------------------------------------------------< ItemStateStore >
     /**
-     * Returns <code>true</code> if this map contains an <code>ItemState</code>
-     * object with the specified <code>id</code>.
-     *
-     * @param id id of <code>ItemState</code> object whose presence should be
-     *           tested.
-     * @return <code>true</code> if there's a corresponding map entry,
-     *         otherwise <code>false</code>.
+     * {@inheritDoc}
      */
     public boolean contains(ItemId id) {
         return map.containsKey(id);
     }
 
     /**
-     * Returns the <code>ItemState</code> object with the specified
-     * <code>id</code> if it is present or <code>null</code> if no
entry exists
-     * with that <code>id</code>.
-     *
-     * @param id the id of the <code>ItemState</code> object to be returned.
-     * @return the <code>ItemState</code> object with the specified
-     *         <code>id</code> or or <code>null</code> if no entry
exists
-     *         with that <code>id</code>
+     * {@inheritDoc}
      */
     public ItemState get(ItemId id) {
         return (ItemState) map.get(id);
     }
 
     /**
-     * Stores the specified <code>ItemState</code> object in the map
-     * using its <code>ItemId</code> as the key.
-     *
-     * @param state the <code>ItemState</code> object to store
+     * {@inheritDoc}
      */
     public void put(ItemState state) {
         ItemId id = state.getId();
@@ -98,69 +82,52 @@
     }
 
     /**
-     * Removes the <code>ItemState</code> object with the specified id from
-     * this map if it is present.
-     *
-     * @param id the id of the <code>ItemState</code> object which should be
-     *           removed from this map.
+     * {@inheritDoc}
      */
     public void remove(ItemId id) {
         map.remove(id);
     }
 
     /**
-     * Removes all entries from this map.
+     * {@inheritDoc}
      */
     public void clear() {
         map.clear();
     }
 
     /**
-     * Returns <code>true</code> if the map contains no entries.
-     *
-     * @return <code>true</code> if the map contains no entries.
+     * {@inheritDoc}
      */
     public boolean isEmpty() {
         return map.isEmpty();
     }
 
     /**
-     * Returns the number of entries in the map.
-     *
-     * @return number of entries in the map.
+     * {@inheritDoc}
      */
     public int size() {
         return map.size();
     }
 
     /**
-     * Returns an unmodifiable set view of the keys (i.e. <code>ItemId</code>
-     * objects) contained in this map.
-     *
-     * @return a set view of the keys contained in this map.
+     * {@inheritDoc}
      */
     public Set keySet() {
         return Collections.unmodifiableSet(map.keySet());
     }
 
     /**
-     * Returns an unmodifiable collection view of the values (i.e.
-     * <code>ItemState</code> objects) contained in this map.
-     *
-     * @return a collection view of the values contained in this map.
+     * {@inheritDoc}
      */
     public Collection values() {
         return Collections.unmodifiableCollection(map.values());
     }
 
-    //-------------------------------------------------------< implementation >
+    //-------------------------------------------------------------< Dumpable >
     /**
-     * Dumps the state of this <code>ItemStateMap</code> instance
-     * (used for diagnostic purposes).
-     *
-     * @param ps
+     * {@inheritDoc}
      */
-    protected void dump(PrintStream ps) {
+    public void dump(PrintStream ps) {
         ps.println("map entries:");
         ps.println();
         Iterator iter = keySet().iterator();

Modified: incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/ItemStateReferenceCache.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/ItemStateReferenceCache.java?rev=230483&r1=230482&r2=230483&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/ItemStateReferenceCache.java
(original)
+++ incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/ItemStateReferenceCache.java
Fri Aug  5 08:17:15 2005
@@ -17,11 +17,13 @@
 package org.apache.jackrabbit.core.state;
 
 import org.apache.jackrabbit.core.ItemId;
+import org.apache.jackrabbit.core.util.Dumpable;
 import org.apache.log4j.Logger;
 
 import java.util.Set;
 import java.util.Collections;
 import java.util.Collection;
+import java.io.PrintStream;
 
 /**
  * <code>ItemStateReferenceCache</code> internally consists of 2 components:
@@ -40,7 +42,7 @@
  * </li>
  * </ul>
  */
-public class ItemStateReferenceCache implements ItemStateCache {
+public class ItemStateReferenceCache implements ItemStateCache, Dumpable {
 
     /** Logger instance */
     private static Logger log = Logger.getLogger(LRUItemStateCache.class);
@@ -154,6 +156,7 @@
      * {@inheritDoc}
      */
     public Set keySet() {
+        // keys of primary cache
         return Collections.unmodifiableSet(refs.keySet());
     }
 
@@ -161,6 +164,18 @@
      * {@inheritDoc}
      */
     public Collection values() {
+        // values of primary cache
         return Collections.unmodifiableCollection(refs.values());
+    }
+
+    //-------------------------------------------------------------< Dumpable >
+    /**
+     * {@inheritDoc}
+     */
+    public void dump(PrintStream ps) {
+        ps.println("ItemStateReferenceCache (" + this + ")");
+        ps.println();
+        ps.print("[refs] ");
+        refs.dump(ps);
     }
 }

Added: incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/ItemStateStore.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/ItemStateStore.java?rev=230483&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/ItemStateStore.java
(added)
+++ incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/ItemStateStore.java
Fri Aug  5 08:17:15 2005
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.core.state;
+
+import org.apache.jackrabbit.core.ItemId;
+
+import java.util.Set;
+import java.util.Collection;
+
+/**
+ * <code>ItemStateStore</code> is similar to a typed <code>Map</code>:
+ * <p/>
+ * An <code>ItemStateStore</code> temporarily stores and retrieves
+ * <code>ItemState</code> instances using their <code>ItemId</code>s
as key.
+ */
+public interface ItemStateStore {
+    /**
+     * Returns <code>true</code> if this store contains an <code>ItemState</code>
+     * object with the specified <code>id</code>.
+     *
+     * @param id id of <code>ItemState</code> object whose presence should be
+     *           tested.
+     * @return <code>true</code> if this store contains a corresponding entry,
+     *         otherwise <code>false</code>.
+     */
+    boolean contains(ItemId id);
+
+    /**
+     * Returns the <code>ItemState</code> object with the specified
+     * <code>id</code> if it is present or <code>null</code> if no
entry exists
+     * with that <code>id</code>.
+     *
+     * @param id the id of the <code>ItemState</code> object to be returned.
+     * @return the <code>ItemState</code> object with the specified
+     *         <code>id</code> or or <code>null</code> if no entry
exists
+     *         with that <code>id</code>
+     */
+    ItemState get(ItemId id);
+
+    /**
+     * Stores the specified <code>ItemState</code> object in the store
+     * using its <code>ItemId</code> as the key.
+     *
+     * @param state the <code>ItemState</code> object to store
+     */
+    void put(ItemState state);
+
+    /**
+     * Removes the <code>ItemState</code> object with the specified id from
+     * this store if it is present.
+     *
+     * @param id the id of the <code>ItemState</code> object which should be
+     *           removed from this store.
+     */
+    void remove(ItemId id);
+
+    /**
+     * Removes all entries from this store.
+     */
+    void clear();
+
+    /**
+     * Returns <code>true</code> if this store contains no entries.
+     *
+     * @return <code>true</code> if this store contains no entries.
+     */
+    boolean isEmpty();
+
+    /**
+     * Returns the number of entries in this store.
+     *
+     * @return number of entries in this store.
+     */
+    int size();
+
+    /**
+     * Returns an unmodifiable set view of the keys (i.e. <code>ItemId</code>
+     * objects) contained in this store.
+     *
+     * @return a set view of the keys contained in this store.
+     */
+    Set keySet();
+
+    /**
+     * Returns an unmodifiable collection view of the values (i.e.
+     * <code>ItemState</code> objects) contained in this store.
+     *
+     * @return a collection view of the values contained in this store.
+     */
+    Collection values();
+}

Propchange: incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/ItemStateStore.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/NodeState.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/NodeState.java?rev=230483&r1=230482&r2=230483&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/NodeState.java
(original)
+++ incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/NodeState.java
Fri Aug  5 08:17:15 2005
@@ -1035,11 +1035,40 @@
             throw new UnsupportedOperationException();
         }
 
+        //---------------------------------------------< Serializable support >
+        private void writeObject(ObjectOutputStream out) throws IOException {
+            // important: fields must be written in same order as they are
+            // read in readObject(ObjectInputStream)
+            out.writeInt(size()); // count
+            for (Iterator iter = iterator(); iter.hasNext();) {
+                NodeState.ChildNodeEntry entry =
+                        (NodeState.ChildNodeEntry) iter.next();
+                //out.writeObject(entry.getName());   // name
+                out.writeUTF(entry.getName().toString());   // name
+                out.writeUTF(entry.getUUID());  // uuid
+            }
+        }
+
+        private void readObject(ObjectInputStream in)
+                throws IOException, ClassNotFoundException {
+            entries = new LinkedMap();
+            nameMap = new HashMap();
+            // important: fields must be read in same order as they are
+            // written in writeObject(ObjectOutputStream)
+            int count = in.readInt();   // count
+            for (int i = 0; i < count; i++) {
+                //QName name = (QName) in.readObject();    // name
+                QName name = QName.valueOf(in.readUTF());    // name
+                String s = in.readUTF();   // uuid
+                add(name, s);
+            }
+        }
+
         //----------------------------------------------------< inner classes >
         class OrderedMapIterator implements ListIterator {
 
             final ListIterator keyIter;
-            final Map entries;
+                final Map entries;
 
             OrderedMapIterator(ListIterator keyIter, Map entries) {
                 this.keyIter = keyIter;

Modified: incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/NodeStateListener.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/NodeStateListener.java?rev=230483&r1=230482&r2=230483&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/NodeStateListener.java
(original)
+++ incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/NodeStateListener.java
Fri Aug  5 08:17:15 2005
@@ -28,27 +28,30 @@
 
     /**
      * Called when a child node has been added
+     *
      * @param state node state that changed
-     * @param name name of node that was added
+     * @param name  name of node that was added
      * @param index index of new node
-     * @param uuid uuid of new node
+     * @param uuid  uuid of new node
      */
-    public void nodeAdded(NodeState state,
-                          QName name, int index, String uuid);
+    void nodeAdded(NodeState state,
+                   QName name, int index, String uuid);
 
     /**
      * Called when the children nodes were replaced by other nodes, typically
      * as result of a reorder operation.
+     *
      * @param state node state that changed
      */
-    public void nodesReplaced(NodeState state);
+    void nodesReplaced(NodeState state);
 
     /**
      * Called when a child node has been removed
+     *
      * @param state node state that changed
-     * @param name name of node that was removed
+     * @param name  name of node that was removed
      * @param index index of removed node
-     * @param uuid uuid of removed node
+     * @param uuid  uuid of removed node
      */
     public void nodeRemoved(NodeState state,
                             QName name, int index, String uuid);

Modified: incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/PropertyState.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/PropertyState.java?rev=230483&r1=230482&r2=230483&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/PropertyState.java
(original)
+++ incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/PropertyState.java
Fri Aug  5 08:17:15 2005
@@ -192,7 +192,8 @@
     private void writeObject(ObjectOutputStream out) throws IOException {
         // important: fields must be written in same order as they are
         // read in readObject(ObjectInputStream)
-        out.writeObject(name);
+        //out.writeObject(name);
+        out.writeUTF(name.toString());
         out.writeInt(type);
         out.writeBoolean(multiValued);
         if (values == null) {
@@ -229,10 +230,12 @@
         }
     }
 
-    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
{
+    private void readObject(ObjectInputStream in)
+            throws IOException, ClassNotFoundException {
         // important: fields must be read in same order as they are
         // written in writeObject(ObjectOutputStream)
-        name = (QName) in.readObject();
+        //name = (QName) in.readObject();
+        name = QName.valueOf(in.readUTF());
         type = in.readInt();
         multiValued = in.readBoolean();
         Object obj = in.readObject();

Modified: incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java?rev=230483&r1=230482&r2=230483&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
(original)
+++ incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
Fri Aug  5 08:17:15 2005
@@ -22,6 +22,7 @@
 import org.apache.jackrabbit.core.ItemId;
 import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.ZombieHierarchyManager;
+import org.apache.jackrabbit.core.util.Dumpable;
 import org.apache.jackrabbit.name.MalformedPathException;
 import org.apache.jackrabbit.name.NamespaceResolver;
 import org.apache.jackrabbit.name.Path;
@@ -41,7 +42,8 @@
 /**
  * <code>SessionItemStateManager</code> ...
  */
-public class SessionItemStateManager implements UpdatableItemStateManager {
+public class SessionItemStateManager
+        implements UpdatableItemStateManager, Dumpable {
 
     private static Logger log = Logger.getLogger(SessionItemStateManager.class);
 
@@ -85,25 +87,23 @@
     }
 
     /**
-     * Dumps the state of this <code>SessionItemStateManager</code> instance
-     * (used for diagnostic purposes).
+     * Returns the hierarchy manager
      *
-     * @param ps
+     * @return the hierarchy manager
+     */
+    public HierarchyManager getHierarchyMgr() {
+        return hierMgr;
+    }
+
+    //-------------------------------------------------------------< Dumpable >
+    /**
+     * {@inheritDoc}
      */
     public void dump(PrintStream ps) {
         ps.println("SessionItemStateManager (" + this + ")");
         ps.println();
         transientStateMgr.dump(ps);
         ps.println();
-    }
-
-    /**
-     * Returns the hierarchy manager
-     *
-     * @return the hierarchy manager
-     */
-    public HierarchyManager getHierarchyMgr() {
-        return hierMgr;
     }
 
     //-----------------------------------------------------< ItemStateManager >

Modified: incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?rev=230483&r1=230482&r2=230483&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
(original)
+++ incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
Fri Aug  5 08:17:15 2005
@@ -20,6 +20,7 @@
 import org.apache.jackrabbit.core.ItemId;
 import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.PropertyId;
+import org.apache.jackrabbit.core.util.Dumpable;
 import org.apache.jackrabbit.core.nodetype.EffectiveNodeType;
 import org.apache.jackrabbit.core.nodetype.NodeDefId;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
@@ -36,6 +37,7 @@
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import java.util.ArrayList;
 import java.util.Iterator;
+import java.io.PrintStream;
 
 import EDU.oswego.cs.dl.util.concurrent.ReadWriteLock;
 import EDU.oswego.cs.dl.util.concurrent.ReentrantWriterPreferenceReadWriteLock;
@@ -46,7 +48,7 @@
  * manager are shared among all sessions.
  */
 public class SharedItemStateManager
-        implements ItemStateManager, ItemStateListener {
+        implements ItemStateManager, ItemStateListener, Dumpable {
 
     /**
      * Logger instance
@@ -55,7 +57,7 @@
 
     /**
      * cache of weak references to ItemState objects issued by this
-     * ItemStateManager 
+     * ItemStateManager
      */
     private final ItemStateReferenceCache cache;
 
@@ -265,6 +267,17 @@
     public void stateDiscarded(ItemState discarded) {
         discarded.removeListener(this);
         cache.evict(discarded.getId());
+    }
+
+    //-------------------------------------------------------------< Dumpable >
+    /**
+     * {@inheritDoc}
+     */
+    public void dump(PrintStream ps) {
+        ps.println("SharedItemStateManager (" + this + ")");
+        ps.println();
+        ps.print("[referenceCache] ");
+        cache.dump(ps);
     }
 
     //-------------------------------------------------< misc. public methods >

Modified: incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/TransientItemStateManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/TransientItemStateManager.java?rev=230483&r1=230482&r2=230483&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/TransientItemStateManager.java
(original)
+++ incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/state/TransientItemStateManager.java
Fri Aug  5 08:17:15 2005
@@ -19,6 +19,7 @@
 import org.apache.jackrabbit.core.ItemId;
 import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.PropertyId;
+import org.apache.jackrabbit.core.util.Dumpable;
 import org.apache.jackrabbit.name.QName;
 import org.apache.log4j.Logger;
 
@@ -30,19 +31,19 @@
 /**
  * <code>TransientItemStateManager</code> ...
  */
-class TransientItemStateManager implements ItemStateManager {
+class TransientItemStateManager implements ItemStateManager, Dumpable {
 
     private static Logger log = Logger.getLogger(TransientItemStateManager.class);
 
     /**
      * map of those states that have been removed transiently
      */
-    private final ItemStateMap atticMap;
+    private final ItemStateStore atticStore;
 
     /**
      * map of new or modified transient states
      */
-    private final ItemStateMap transientMap;
+    private final ItemStateStore transientStore;
 
     /**
      * ItemStateManager view of the states in the attic; lazily instantiated
@@ -54,24 +55,30 @@
      * Creates a new <code>TransientItemStateManager</code> instance.
      */
     TransientItemStateManager() {
-        transientMap = new ItemStateMap();
-        atticMap = new ItemStateMap();
+        transientStore = new ItemStateMap();
+        atticStore = new ItemStateMap();
     }
 
+    //-------------------------------------------------------------< Dumpable >
     /**
-     * Dumps the state of this <code>TransientItemStateManager</code> instance
-     * (used for diagnostic purposes).
-     *
-     * @param ps
+     * {@inheritDoc}
      */
-    void dump(PrintStream ps) {
+    public void dump(PrintStream ps) {
         ps.println("TransientItemStateManager (" + this + ")");
         ps.println();
         ps.print("[transient] ");
-        transientMap.dump(ps);
+        if (transientStore instanceof Dumpable) {
+            ((Dumpable) transientStore).dump(ps);
+        } else {
+            ps.println(transientStore.toString());
+        }
         ps.println();
         ps.print("[attic]     ");
-        atticMap.dump(ps);
+        if (atticStore instanceof Dumpable) {
+            ((Dumpable) atticStore).dump(ps);
+        } else {
+            ps.println(atticStore.toString());
+        }
     }
 
     //----------------------------------------------------< ItemStateProvider >
@@ -81,7 +88,7 @@
     public ItemState getItemState(ItemId id)
             throws NoSuchItemStateException, ItemStateException {
 
-        ItemState state = transientMap.get(id);
+        ItemState state = transientStore.get(id);
         if (state != null) {
             return state;
         } else {
@@ -93,7 +100,7 @@
      * {@inheritDoc}
      */
     public boolean hasItemState(ItemId id) {
-        return transientMap.contains(id);
+        return transientStore.contains(id);
     }
 
     /**
@@ -118,42 +125,42 @@
      * @return
      */
     boolean hasAnyItemStates() {
-        return !transientMap.isEmpty();
+        return !transientStore.isEmpty();
     }
 
     /**
      * @return
      */
     boolean hasAnyItemStatesInAttic() {
-        return !atticMap.isEmpty();
+        return !atticStore.isEmpty();
     }
 
     /**
      * @return
      */
     int getEntriesCount() {
-        return transientMap.size();
+        return transientStore.size();
     }
 
     /**
      * @return
      */
     int getEntriesInAtticCount() {
-        return atticMap.size();
+        return atticStore.size();
     }
 
     /**
      * @return
      */
     Iterator getEntries() {
-        return transientMap.values().iterator();
+        return transientStore.values().iterator();
     }
 
     /**
      * @return
      */
     Iterator getEntriesInAttic() {
-        return atticMap.values().iterator();
+        return atticStore.values().iterator();
     }
 
     //----------------< methods for creating & discarding ItemState instances >
@@ -172,8 +179,8 @@
         NodeId id = new NodeId(uuid);
 
         // check map; synchronized to ensure an entry is not created twice.
-        synchronized (transientMap) {
-            if (transientMap.contains(id)) {
+        synchronized (transientStore) {
+            if (transientStore.contains(id)) {
                 String msg = "there's already a node state instance with id " + id;
                 log.debug(msg);
                 throw new ItemStateException(msg);
@@ -182,7 +189,7 @@
             NodeState state = new NodeState(uuid, nodeTypeName, parentUUID,
                     initialStatus, true);
             // put transient state in the map
-            transientMap.put(state);
+            transientStore.put(state);
             return state;
         }
     }
@@ -199,8 +206,8 @@
         ItemId id = overlayedState.getId();
 
         // check map; synchronized to ensure an entry is not created twice.
-        synchronized (transientMap) {
-            if (transientMap.contains(id)) {
+        synchronized (transientStore) {
+            if (transientStore.contains(id)) {
                 String msg = "there's already a node state instance with id " + id;
                 log.debug(msg);
                 throw new ItemStateException(msg);
@@ -208,7 +215,7 @@
 
             NodeState state = new NodeState(overlayedState, initialStatus, true);
             // put transient state in the map
-            transientMap.put(state);
+            transientStore.put(state);
             return state;
         }
     }
@@ -226,8 +233,8 @@
         PropertyId id = new PropertyId(parentUUID, propName);
 
         // check map; synchronized to ensure an entry is not created twice.
-        synchronized (transientMap) {
-            if (transientMap.contains(id)) {
+        synchronized (transientStore) {
+            if (transientStore.contains(id)) {
                 String msg = "there's already a property state instance with id " + id;
                 log.debug(msg);
                 throw new ItemStateException(msg);
@@ -235,7 +242,7 @@
 
             PropertyState state = new PropertyState(propName, parentUUID, initialStatus,
true);
             // put transient state in the map
-            transientMap.put(state);
+            transientStore.put(state);
             return state;
         }
     }
@@ -253,8 +260,8 @@
                 overlayedState.getName());
 
         // check map; synchronized to ensure an entry is not created twice.
-        synchronized (transientMap) {
-            if (transientMap.contains(id)) {
+        synchronized (transientStore) {
+            if (transientStore.contains(id)) {
                 String msg = "there's already a property state instance with id " + id;
                 log.debug(msg);
                 throw new ItemStateException(msg);
@@ -262,7 +269,7 @@
 
             PropertyState state = new PropertyState(overlayedState, initialStatus, true);
             // put transient state in the map
-            transientMap.put(state);
+            transientStore.put(state);
             return state;
         }
     }
@@ -279,7 +286,7 @@
         // instance of the transient state
         state.discard();
         // remove from map
-        transientMap.remove(state.getId());
+        transientStore.remove(state.getId());
         // give the instance a chance to prepare to get gc'ed
         state.onDisposed();
     }
@@ -292,9 +299,9 @@
      */
     void moveItemStateToAttic(ItemState state) {
         // remove from map
-        transientMap.remove(state.getId());
+        transientStore.remove(state.getId());
         // add to attic
-        atticMap.put(state);
+        atticStore.put(state);
     }
 
     /**
@@ -309,7 +316,7 @@
         // instance of the transient state
         state.discard();
         // remove from attic
-        atticMap.remove(state.getId());
+        atticStore.remove(state.getId());
         // give the instance a chance to prepare to get gc'ed
         state.onDisposed();
     }
@@ -320,13 +327,13 @@
     void disposeAllItemStates() {
         // dispose item states in transient map & attic
         // (use temp collection to avoid ConcurrentModificationException)
-        Collection tmp = new ArrayList(transientMap.values());
+        Collection tmp = new ArrayList(transientStore.values());
         Iterator iter = tmp.iterator();
         while (iter.hasNext()) {
             ItemState state = (ItemState) iter.next();
             disposeItemState(state);
         }
-        tmp = new ArrayList(atticMap.values());
+        tmp = new ArrayList(atticStore.values());
         iter = tmp.iterator();
         while (iter.hasNext()) {
             ItemState state = (ItemState) iter.next();
@@ -364,7 +371,7 @@
         public ItemState getItemState(ItemId id)
                 throws NoSuchItemStateException, ItemStateException {
 
-            ItemState state = atticMap.get(id);
+            ItemState state = atticStore.get(id);
             if (state != null) {
                 return state;
             } else {
@@ -376,7 +383,7 @@
          * {@inheritDoc}
          */
         public boolean hasItemState(ItemId id) {
-            return atticMap.contains(id);
+            return atticStore.contains(id);
         }
 
         /**

Added: incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/util/Dumpable.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/util/Dumpable.java?rev=230483&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/util/Dumpable.java
(added)
+++ incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/util/Dumpable.java
Fri Aug  5 08:17:15 2005
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.core.util;
+
+import java.io.PrintStream;
+
+/**
+ * Utility interface for internal use.
+ * <p/>
+ * A <code>Dumpable</code> object supports dumping its state in a human readable
+ * format for diagnostic/debug purposes.
+ */
+public interface Dumpable {
+    /**
+     * Dumps the state of this instance in a human readable format for
+     * diagnostic purposes.
+     *
+     * @param ps stream to dump state to
+     */
+    void dump(PrintStream ps);
+}

Propchange: incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/util/Dumpable.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message