[jboss-cvs] JBossCache/src/org/jboss/cache ...
Manik Surtani
msurtani at jboss.com
Tue Jan 2 14:19:05 EST 2007
User: msurtani
Date: 07/01/02 14:19:05
Modified: src/org/jboss/cache CacheImpl.java VersionedNode.java
UnversionedNode.java
Log:
Optimised NodeFactory
Revision Changes Path
1.10 +14 -15 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.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- CacheImpl.java 2 Jan 2007 18:26:06 -0000 1.9
+++ CacheImpl.java 2 Jan 2007 19:19:05 -0000 1.10
@@ -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.9 2007/01/02 18:26:06 msurtani Exp $
+ * @version $Id: CacheImpl.java,v 1.10 2007/01/02 19:19:05 msurtani Exp $
* <p/>
* @see <a href="http://labs.jboss.com/portal/jbosscache/docs">JBossCache doc</a>
*/
@@ -107,18 +107,8 @@
private static final String CREATE_MUX_CHANNEL = "createMultiplexerChannel";
private static final String[] MUX_TYPES = {"java.lang.String", "java.lang.String"};
- // Quite poor, but for now, root may be re-initialised when setNodeLockingOptimistic() is called.
- // this is because if node locking is optimistic, we need to use OptimisticTreeNodes rather than TreeNodes.
- // - MANIK
- /**
- * Root DataNode.
- */
protected NodeSPI root;
- {
- root = NodeFactory.getInstance().createRootDataNode(NodeFactory.NodeType.UNVERSIONED_NODE, this);
- }
-
private RegionManager regionManager = null;
/**
@@ -589,11 +579,19 @@
*/
public void create() throws Exception
{
+ // initialise the node factory and set this in the runtime.
+ NodeFactory nf = new NodeFactory(this);
+ configuration.getRuntimeConfig().setNodeFactory(nf);
+
if (notifier == null) notifier = new Notifier(this);
stateFetchTimeout = configuration.getLockAcquisitionTimeout() + 5000;
if (configuration.isNodeLockingOptimistic())
{
- root = NodeFactory.getInstance().createRootDataNode(NodeFactory.NodeType.VERSIONED_NODE, this);
+ root = nf.createRootDataNode();
+ }
+ else
+ {
+ root = nf.createRootDataNode();
}
setUseReplQueue(configuration.isUseReplQueue());
@@ -1018,7 +1016,8 @@
NodeSPI child = null;
Object owner = getOwnerForLock();
Object name;
- NodeFactory factory = NodeFactory.getInstance();
+ NodeFactory factory = configuration.getRuntimeConfig().getNodeFactory();
+
NodeFactory.NodeType type = configuration.isNodeLockingOptimistic()
? NodeFactory.NodeType.VERSIONED_NODE
: NodeFactory.NodeType.UNVERSIONED_NODE;
@@ -1044,9 +1043,9 @@
try
{
- child = (NodeSPI) factory.createDataNode(type, name,
+ child = (NodeSPI) factory.createDataNode(name,
subtree.getFqnChild(i + 1),
- parent, null, true, null, this);
+ parent, null, true);
parent.addChild(name, child);
}
finally
1.3 +1 -11 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.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- VersionedNode.java 1 Jan 2007 22:12:19 -0000 1.2
+++ VersionedNode.java 2 Jan 2007 19:19:05 -0000 1.3
@@ -28,25 +28,15 @@
*/
private Node parent;
- public VersionedNode(Object childName, Fqn fqn, Node parent, Map data, DataVersion version, CacheSPI cache)
- {
- this(childName, fqn, parent, data, false, cache, DefaultDataVersion.ZERO);
- }
-
public VersionedNode(Object childName, Fqn fqn, Node parent, Map data, boolean mapSafe, CacheSPI cache)
{
- this(childName, fqn, parent, data, mapSafe, cache, DefaultDataVersion.ZERO);
- }
-
- public VersionedNode(Object childName, Fqn fqn, Node parent, Map data, boolean mapSafe, CacheSPI cache, DataVersion version)
- {
super(childName, fqn, data, mapSafe, cache);
if (version == null)
throw new NullPointerException("version");
if (parent == null && !fqn.isRoot())
throw new NullPointerException("parent");
this.parent = parent;
- this.version = version;
+ this.version = DefaultDataVersion.ZERO;
}
public VersionedNode(Object childName, Fqn fqn, Node parent, Map data, CacheSPI cache)
1.7 +1 -2 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.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- UnversionedNode.java 2 Jan 2007 18:26:06 -0000 1.6
+++ UnversionedNode.java 2 Jan 2007 19:19:05 -0000 1.7
@@ -8,7 +8,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.factories.NodeFactory;
import org.jboss.cache.lock.IdentityLock;
import org.jboss.cache.lock.LockingException;
import org.jboss.cache.lock.NodeLock;
@@ -340,7 +339,7 @@
// construct the new child outside the synchronized block to avoid
// spending any more time than necessary in the synchronized section
Fqn child_fqn = new Fqn(this.fqn, child_name);
- Node newChild = NodeFactory.getInstance().createNode(child_name, child_fqn, this, null, cache);
+ Node newChild = cache.getConfiguration().getRuntimeConfig().getNodeFactory().createNode(child_name, this, null);
if (newChild == null)
{
throw new IllegalStateException();
More information about the jboss-cvs-commits
mailing list