[jboss-cvs] JBossCache/src/org/jboss/cache ...
Manik Surtani
msurtani at jboss.com
Mon Jan 1 17:12:19 EST 2007
User: msurtani
Date: 07/01/01 17:12:19
Modified: src/org/jboss/cache Fqn.java CacheImpl.java
VersionedNode.java AbstractNode.java
UnversionedNode.java
Added: src/org/jboss/cache FqnComparator.java
Log:
- FqnComparator should not be in the optimistic subpackage
- Fixed move() related issues
Revision Changes Path
1.46 +1 -2 JBossCache/src/org/jboss/cache/Fqn.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Fqn.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/Fqn.java,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -b -r1.45 -r1.46
--- Fqn.java 31 Dec 2006 02:08:41 -0000 1.45
+++ Fqn.java 1 Jan 2007 22:12:19 -0000 1.46
@@ -9,7 +9,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.optimistic.FqnComparator;
import java.io.Externalizable;
import java.io.IOException;
@@ -42,7 +41,7 @@
* <p/>
* Another way to look at it is that the "/" separarator is only parsed when it form sa part of a String passed in to Fqn.fromString() and not otherwise.
*
- * @version $Revision: 1.45 $
+ * @version $Revision: 1.46 $
*/
public class Fqn implements Cloneable, Externalizable, Comparable<Fqn>
{
1.5 +4 -2 JBossCache/src/org/jboss/cache/CacheImpl.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CacheImpl.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/CacheImpl.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- CacheImpl.java 31 Dec 2006 03:01:20 -0000 1.4
+++ CacheImpl.java 1 Jan 2007 22:12:19 -0000 1.5
@@ -98,7 +98,7 @@
* @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
* @author Brian Stansberry
* @author Daniel Huang (dhuang at jboss.org)
- * @version $Id: CacheImpl.java,v 1.4 2006/12/31 03:01:20 msurtani Exp $
+ * @version $Id: CacheImpl.java,v 1.5 2007/01/01 22:12:19 msurtani Exp $
* <p/>
* @see <a href="http://labs.jboss.com/portal/jbosscache/docs">JBossCache doc</a>
*/
@@ -3178,7 +3178,9 @@
// now that we have the parent and target nodes:
// first correct the pointers at the pruning point
+ getInvocationContext().getOptionOverrides().setBypassInterceptorChain(true);
oldParent.removeChild(new Fqn(nodeName));
+ getInvocationContext().getOptionOverrides().setBypassInterceptorChain(false);
newParent.addChild(nodeName, node);
// parent pointer is calculated on the fly using Fqns.
@@ -3189,7 +3191,7 @@
// now register an undo op
if (getInvocationContext().getTransaction() != null)
{
- MethodCall undo = MethodCallFactory.create(MethodDeclarations.moveMethodLocal, oldParent.getFqn(), new Fqn(newParentFqn, nodeToMoveFqn.getLastElement()));
+ MethodCall undo = MethodCallFactory.create(MethodDeclarations.moveMethodLocal, new Fqn(newParentFqn, nodeToMoveFqn.getLastElement()), oldParent.getFqn());
tx_table.addUndoOperation(getInvocationContext().getGlobalTransaction(), undo);
}
}
1.2 +0 -6 JBossCache/src/org/jboss/cache/VersionedNode.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: VersionedNode.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/VersionedNode.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- VersionedNode.java 30 Dec 2006 17:49:54 -0000 1.1
+++ VersionedNode.java 1 Jan 2007 22:12:19 -0000 1.2
@@ -81,10 +81,4 @@
{
this.version = version;
}
-
- public String toString()
- {
- return "Opt" + super.toString();
- }
-
}
1.25 +11 -0 JBossCache/src/org/jboss/cache/AbstractNode.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: AbstractNode.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/AbstractNode.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- AbstractNode.java 30 Dec 2006 17:49:54 -0000 1.24
+++ AbstractNode.java 1 Jan 2007 22:12:19 -0000 1.25
@@ -14,6 +14,7 @@
{
protected boolean deleted;
protected Map<Object, Node> children;
+ protected Fqn fqn;
public boolean isDeleted()
{
@@ -36,4 +37,14 @@
}
}
}
+
+ public boolean equals(Object another)
+ {
+ return another instanceof AbstractNode && fqn.equals(((AbstractNode) another).fqn);
+ }
+
+ public int hashCode()
+ {
+ return fqn.hashCode();
+ }
}
1.4 +4 -8 JBossCache/src/org/jboss/cache/UnversionedNode.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UnversionedNode.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/UnversionedNode.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- UnversionedNode.java 31 Dec 2006 03:01:20 -0000 1.3
+++ UnversionedNode.java 1 Jan 2007 22:12:19 -0000 1.4
@@ -67,11 +67,6 @@
private transient CacheSPI cache;
/**
- * Name of the node.
- */
- private Fqn fqn;
-
- /**
* Map of general data keys to values.
*/
private Map data;
@@ -442,10 +437,11 @@
public String toString()
{
StringBuffer sb = new StringBuffer();
+ sb.append(getClass().getSimpleName());
if (deleted)
- sb.append("Node (deleted) [ ").append(fqn);
+ sb.append(" (deleted) [ ").append(fqn);
else
- sb.append("Node[ ").append(fqn);
+ sb.append("[ ").append(fqn);
synchronized (this)
{
if (data != null)
@@ -455,7 +451,7 @@
}
if (children != null && !children.isEmpty())
{
- sb.append(" child=").append(children.keySet());
+ sb.append(" child=").append(getChildren(false));
}
if (lock_ != null)
{
1.1 date: 2007/01/01 22:12:19; author: msurtani; state: Exp;JBossCache/src/org/jboss/cache/FqnComparator.java
Index: FqnComparator.java
===================================================================
/*
* JBoss, Home of Professional Open Source
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.cache;
import java.util.Comparator;
/**
* Compares the order of two FQN.
* Sorts by name, then by depth, e.g.
* <pre>
* aaa/bbb
* xxx
* xxx/ccc
* </pre>
*
* @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
* @author Steve Woodcock (<a href="mailto:stevew at jofti.com">stevew at jofti.com</a>)
*/
public class FqnComparator implements Comparator<Fqn>
{
public static final FqnComparator INSTANCE = new FqnComparator();
/**
* Sorts by name, then depth.
*/
public FqnComparator()
{
}
/**
* Returns -1 if the first comes before; 0 if they are the same; 1 if the
* second Fqn comes before. <code>null</code> always comes first.
*/
public int compare(Fqn fqn1, Fqn fqn2)
{
int s1 = fqn1.size();
int s2 = fqn2.size();
if (s1 == 0)
{
return (s2 == 0) ? 0 : -1;
}
if (s2 == 0)
{
return 1;
}
int size = Math.min(s1, s2);
for (int i = 0; i < size; i++)
{
Object e1 = fqn1.get(i);
Object e2 = fqn2.get(i);
if (e1 == e2)
continue;
if (e1 == null)
return 0;
if (e2 == null)
return 1;
if (!e1.equals(e2))
{
int c = compareElements(e1, e2);
if (c != 0)
return c;
}
}
return s1 - s2;
}
/**
* Compares two Fqn elements.
* If e1 and e2 are the same class and e1 implements Comparable,
* returns e1.compareTo(e2).
* Otherwise, returns e1.toString().compareTo(e2.toString()).
*/
private int compareElements(Object e1, Object e2)
{
if (e1.getClass() == e2.getClass() && e1 instanceof Comparable)
{
return ((Comparable) e1).compareTo(e2);
}
else
{
return e1.toString().compareTo(e2.toString());
}
}
}
More information about the jboss-cvs-commits
mailing list