[jboss-cvs] JBossCache/src/org/jboss/cache ...
Manik Surtani
msurtani at jboss.com
Thu Jan 11 07:07:29 EST 2007
User: msurtani
Date: 07/01/11 07:07:29
Modified: src/org/jboss/cache CacheImpl.java VersionedNode.java
UnversionedNode.java
Added: src/org/jboss/cache NodeFactory.java
Log:
Force node construction thru factory
Revision Changes Path
1.23 +1 -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.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- CacheImpl.java 10 Jan 2007 11:32:39 -0000 1.22
+++ CacheImpl.java 11 Jan 2007 12:07:28 -0000 1.23
@@ -17,7 +17,6 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.RuntimeConfig;
import org.jboss.cache.factories.InterceptorChainFactory;
-import org.jboss.cache.factories.NodeFactory;
import org.jboss.cache.interceptors.Interceptor;
import org.jboss.cache.jmx.CacheJmxWrapper;
import org.jboss.cache.jmx.CacheJmxWrapperMBean;
@@ -99,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.22 2007/01/10 11:32:39 msurtani Exp $
+ * @version $Id: CacheImpl.java,v 1.23 2007/01/11 12:07:28 msurtani Exp $
* <p/>
* @see <a href="http://labs.jboss.com/portal/jbosscache/docs">JBossCache doc</a>
*/
1.7 +2 -2 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.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- VersionedNode.java 10 Jan 2007 20:09:05 -0000 1.6
+++ VersionedNode.java 11 Jan 2007 12:07:29 -0000 1.7
@@ -26,9 +26,9 @@
*/
private NodeSPI parent;
- public VersionedNode(Object childName, Fqn fqn, NodeSPI parent, Map data, CacheSPI cache)
+ protected VersionedNode(Fqn fqn, NodeSPI parent, Map data, CacheSPI cache)
{
- super(childName, fqn, data, false, cache);
+ super(fqn.getLastElement(), fqn, data, false, cache);
if (parent == null && !fqn.isRoot()) throw new NullPointerException("parent");
this.parent = parent;
this.version = DefaultDataVersion.ZERO;
1.19 +1 -1 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.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- UnversionedNode.java 10 Jan 2007 20:09:05 -0000 1.18
+++ UnversionedNode.java 11 Jan 2007 12:07:29 -0000 1.19
@@ -82,7 +82,7 @@
* {@link #data} field; <code>false</code> if param <code>data</code>'s contents should be copied into
* this object's {@link #data} field.
*/
- public UnversionedNode(Object child_name, Fqn fqn, Map data, boolean mapSafe, CacheSPI cache)
+ protected UnversionedNode(Object child_name, Fqn fqn, Map data, boolean mapSafe, CacheSPI cache)
{
init(child_name, fqn, cache);
if (data != null)
1.1 date: 2007/01/11 12:07:29; author: msurtani; state: Exp;JBossCache/src/org/jboss/cache/NodeFactory.java
Index: NodeFactory.java
===================================================================
/*
* JBoss, Home of Professional Open Source
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.cache;
import org.jboss.cache.optimistic.TransactionWorkspace;
import org.jboss.cache.optimistic.WorkspaceNode;
import org.jboss.cache.optimistic.WorkspaceNodeImpl;
import java.util.Map;
/**
* A factory that generates nodes.
*
* @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
*/
public class NodeFactory
{
public enum NodeType
{
UNVERSIONED_NODE, VERSIONED_NODE, WORKSPACE_NODE
}
private CacheSPI cache;
private boolean optimistic;
/**
* Constructs an instance of the factory
*/
public NodeFactory(CacheSPI cache)
{
this.cache = cache;
init();
}
/**
* Initialises the node factory with the configuration from the cache.
*/
public void init()
{
optimistic = cache.getConfiguration().isNodeLockingOptimistic();
}
/**
* Creates a new {@link Node} instance.
*
* @param childName the new node's name
* @param fqn the new node's Fqn
* @param parent the new node's parent
* @param data the new node's attribute map
* @param mapSafe <code>true</code> if param <code>data</code> can safely
* be directly assigned to the new node's data field;
* <code>false</code> if param <code>data</code>'s contents
* should be copied into the new node's data field.
* @return the new node
*/
public NodeSPI createDataNode(Object childName, Fqn fqn, NodeSPI parent, Map data, boolean mapSafe)
{
return optimistic ? new VersionedNode(fqn, parent, data, cache) : new UnversionedNode(childName, fqn, data, mapSafe, cache);
}
public Node createNode(Object childName, Node parent, Map data)
{
return createNodeOfType(parent, childName, parent, data);
}
public Node createNodeOfType(Node template, Object childName, Node parent, Map data)
{
if (template instanceof WorkspaceNode)
{
NodeSPI dataNodeParent = ((WorkspaceNode) parent).getNode();
TransactionWorkspace workspace = ((WorkspaceNode) template).getTransactionWorkspace();
return createWorkspaceNode(dataNodeParent, workspace);
}
// not a workspace node.
return createDataNode(childName, new Fqn(parent.getFqn(), childName), (NodeSPI) parent, data, false);
}
public WorkspaceNode createWorkspaceNode(NodeSPI dataNode, TransactionWorkspace workspace)
{
return new WorkspaceNodeImpl(dataNode, workspace);
}
public NodeSPI createRootDataNode()
{
return createDataNode(null, Fqn.ROOT, null, null, false);
}
}
More information about the jboss-cvs-commits
mailing list