jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpfis...@apache.org
Subject svn commit: r486534 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: CachingHierarchyManager.java lock/AbstractLockInfo.java lock/LockManagerImpl.java
Date Wed, 13 Dec 2006 07:41:55 GMT
Author: dpfister
Date: Tue Dec 12 23:41:55 2006
New Revision: 486534

URL: http://svn.apache.org/viewvc?view=rev&rev=486534
Log:
Make CachingHierarchyManager and LockManager dumpable to print layout of internal path maps

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/CachingHierarchyManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/AbstractLockInfo.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/CachingHierarchyManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/CachingHierarchyManager.java?view=diff&rev=486534&r1=486533&r2=486534
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/CachingHierarchyManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/CachingHierarchyManager.java
Tue Dec 12 23:41:55 2006
@@ -22,6 +22,7 @@
 import org.apache.jackrabbit.core.state.ItemStateManager;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.NodeStateListener;
+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;
@@ -34,6 +35,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
+import java.io.PrintStream;
 
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.PathNotFoundException;
@@ -44,7 +46,7 @@
  * items.
  */
 public class CachingHierarchyManager extends HierarchyManagerImpl
-        implements NodeStateListener {
+        implements NodeStateListener, Dumpable {
 
     /**
      * Default upper limit of cached states
@@ -661,6 +663,32 @@
                 }
             }
         }
+    }
+
+    /**
+     * Dump contents of path map and elements included to <code>PrintStream</code>
given.
+     *
+     * @param ps print stream to dump to
+     */
+    public void dump(final PrintStream ps) {
+        pathCache.traverse(new PathMap.ElementVisitor() {
+            public void elementVisited(PathMap.Element element) {
+                StringBuffer line = new StringBuffer();
+                for (int i = 0; i < element.getDepth(); i++) {
+                    line.append("--");
+                }
+                line.append(element.getName());
+                int index = element.getIndex();
+                if (index != 0 && index != 1) {
+                    line.append('[');
+                    line.append(index);
+                    line.append(']');
+                }
+                line.append("  ");
+                line.append(element.get());
+                ps.println(line.toString());
+            }
+        }, true);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/AbstractLockInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/AbstractLockInfo.java?view=diff&rev=486534&r1=486533&r2=486534
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/AbstractLockInfo.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/AbstractLockInfo.java
Tue Dec 12 23:41:55 2006
@@ -143,4 +143,26 @@
     public boolean isSessionScoped() {
         return sessionScoped;
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String toString() {
+        StringBuffer buffer = new StringBuffer();
+        buffer.append('(');
+        if (deep) {
+            buffer.append("deep ");
+        }
+        if (sessionScoped) {
+            buffer.append("session ");
+        }
+        buffer.append("holder:");
+        if (lockHolder != null) {
+            buffer.append(lockHolder.getUserID());
+        } else {
+            buffer.append("none");
+        }
+        buffer.append(')');
+        return buffer.toString();
+    }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java?view=diff&rev=486534&r1=486533&r2=486534
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
Tue Dec 12 23:41:55 2006
@@ -24,6 +24,7 @@
 import org.apache.jackrabbit.util.PathMap;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.SessionListener;
+import org.apache.jackrabbit.core.util.Dumpable;
 import org.apache.jackrabbit.core.cluster.LockEventChannel;
 import org.apache.jackrabbit.core.cluster.LockEventListener;
 import org.apache.jackrabbit.core.fs.FileSystem;
@@ -53,13 +54,15 @@
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
+import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.Iterator;
 
 /**
  * Provides the functionality needed for locking and unlocking nodes.
  */
-public class LockManagerImpl implements LockManager, SynchronousEventListener, LockEventListener
{
+public class LockManagerImpl implements LockManager, SynchronousEventListener,
+        LockEventListener, Dumpable {
 
     /**
      * Logger
@@ -1005,5 +1008,31 @@
         } finally {
             release();
         }
+    }
+
+    /**
+     * Dump contents of path map and elements included to <code>PrintStream</code>
given.
+     *
+     * @param ps print stream to dump to
+     */
+    public void dump(final PrintStream ps) {
+        lockMap.traverse(new PathMap.ElementVisitor() {
+            public void elementVisited(PathMap.Element element) {
+                StringBuffer line = new StringBuffer();
+                for (int i = 0; i < element.getDepth(); i++) {
+                    line.append("--");
+                }
+                line.append(element.getName());
+                int index = element.getIndex();
+                if (index != 0 && index != 1) {
+                    line.append('[');
+                    line.append(index);
+                    line.append(']');
+                }
+                line.append("  ");
+                line.append(element.get());
+                ps.println(line.toString());
+            }
+        }, true);
     }
 }



Mime
View raw message