[prev in list] [next in list] [prev in thread] [next in thread]
List: jboss-cvs-commits
Subject: [jboss-cvs] JBossCache/src/org/jboss/cache ...
From: msurtani () jboss ! com (Manik Surtani)
Date: 2007-01-24 11:48:54
Message-ID: E1H4Sns-000845-84 () committer01 ! frg ! pub ! inap ! atl ! jboss ! com
[Download RAW message or body]
User: msurtani
Date: 07/01/09 21:03:00
Modified: src/org/jboss/cache NodeSPI.java CacheImpl.java
Node.java UnversionedNode.java
Log:
Bunch of API changes
Revision Changes Path
1.11 +26 -7 JBossCache/src/org/jboss/cache/NodeSPI.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: NodeSPI.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/NodeSPI.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- NodeSPI.java 5 Jan 2007 08:58:37 -0000 1.10
+++ NodeSPI.java 10 Jan 2007 02:03:00 -0000 1.11
@@ -34,6 +34,9 @@
* configuration's locking policy, an appropriate lock should be obtained prior to \
the call. These direct access methods will
* throw {@link org.jboss.cache.lock.LockingException}s if appropriate locks \
haven't been obtained by the caller.
* <p/>
+ * It is important to node that the direct <b>read</b> methods, such as \
getDataDirect(), return unmodifiable collections. + * In addition to being \
unmodifiable, they are also defensively copied from the underlying data map to ensure \
view consistency. + * <p/>
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik@jboss.org)</a>
* @see Node
@@ -68,20 +71,19 @@
/**
* Returns a map to access the raw children.
- * The data should only be modified by the cache itself.
- * This method should never return null.
+ * This method will never return null.
*
* @return Map, keyed by child name, values Nodes.
*/
- Map<Object, Node> getChildrenMap();
+ Map<Object, Node> getChildrenMapDirect();
/**
* Sets the node's children explictly.
- * The data should only be modified by the cache itself.
+ * This method will remove all children currently associated with this node and \
add all the children passed in.
*
* @param children cannot be null
*/
- void setChildrenMap(Map<Object, Node> children);
+ void setChildrenMapDirect(Map<Object, Node> children);
/**
* Returns an existing child or creates a new one using a global transaction.
@@ -124,9 +126,20 @@
void addChild(Object nodeName, Node nodeToAdd);
- void printDetails(StringBuffer sb, int i);
+ /**
+ * Prints details of this node to the StringBuffer passed in.
+ *
+ * @param sb StringBuffer to print to
+ * @param indent depth of this node in the tree. Used to indent details by \
prepending spaces. + */
+ void printDetails(StringBuffer sb, int indent);
- void removeChildren();
+ /**
+ * Prints basic information of this node to the StringBuffer passed in.
+ *
+ * @param sb StringBuffer to print to
+ * @param indent depth of this node in the tree. Used to indent details by \
prepending spaces. + */
void print(StringBuffer sb, int indent);
@@ -161,6 +174,12 @@
Set<NodeSPI> getChildrenDirect();
/**
+ * Directly removes all children for this node. The only direct method that \
does not have a non-direct counterpart. + */
+ void removeChildrenDirect();
+
+
+ /**
* Retrieves children (directly), optionally including any marked as deleted.
* <p/>
* The caller needs to ensure a proper lock has been obtained prior to calling \
this method, otherwise a
1.20 +7 -7 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.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- CacheImpl.java 9 Jan 2007 22:26:39 -0000 1.19
+++ CacheImpl.java 10 Jan 2007 02:03:00 -0000 1.20
@@ -100,7 +100,7 @@
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik@jboss.org)</a>
* @author Brian Stansberry
* @author Daniel Huang (dhuang@jboss.org)
- * @version $Id: CacheImpl.java,v 1.19 2007/01/09 22:26:39 bstansberry Exp $
+ * @version $Id: CacheImpl.java,v 1.20 2007/01/10 02:03:00 msurtani Exp $
* <p/>
* @see <a href="http://labs.jboss.com/portal/jbosscache/docs">JBossCache doc</a>
*/
@@ -1789,7 +1789,7 @@
return false;
}
}
- return !n.getChildrenMap().isEmpty();
+ return !n.getChildrenMapDirect().isEmpty();
}
/**
@@ -2414,7 +2414,7 @@
// remove subtree from parent
if (eviction || configuration.isNodeLockingOptimistic())
{
- parent_node.getChildrenMap().remove(n.getFqn().getLastElement());
+ parent_node.getChildrenMapDirect().remove(n.getFqn().getLastElement());
}
else
{
@@ -2852,7 +2852,7 @@
NodeSPI backupSubtree = findNode(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
if (backupSubtree != null)
{
- Map children = backupSubtree.getChildrenMap();
+ Map children = backupSubtree.getChildrenMapDirect();
if (children != null)
{
Iterator childNames = children.keySet().iterator();
@@ -3855,7 +3855,7 @@
// do not actually delete; just remove deletion marker
n.markAsDeleted(false);
// but now remove all children, since the call has been to remove("/")
- n.removeChildren();
+ n.removeChildrenDirect();
}
else
{
1.56 +2 -4 JBossCache/src/org/jboss/cache/Node.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Node.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/Node.java,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -b -r1.55 -r1.56
--- Node.java 4 Jan 2007 14:36:00 -0000 1.55
+++ Node.java 10 Jan 2007 02:03:00 -0000 1.56
@@ -111,8 +111,7 @@
* @param k
* @param v
*/
- void putIfNull(Object k, Object v);
-
+ void putIfAbsent(Object k, Object v);
/**
* Puts an entire map of key-value pairs into the current node's data map. If \
any data exists, existing @@ -134,8 +133,7 @@
*
* @param m
*/
- void putIfNull(Map<Object, Object> m);
-
+ void putIfAbsent(Map<Object, Object> m);
/**
* Gets data stored in the current node under key k
1.14 +15 -43 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.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- UnversionedNode.java 5 Jan 2007 10:46:01 -0000 1.13
+++ UnversionedNode.java 10 Jan 2007 02:03:00 -0000 1.14
@@ -65,7 +65,7 @@
/**
* Map of general data keys to values.
*/
- private Map data;
+ private final Map data = new HashMap();
/**
* Constructs a new node with an FQN of Root.
@@ -91,7 +91,7 @@
init(child_name, fqn, cache);
if (data != null)
{
- this.data().putAll(data);
+ this.data.putAll(data);
}
}
@@ -107,14 +107,7 @@
init(child_name, fqn, cache);
if (data != null)
{
- if (mapSafe)
- {
- this.data = data;// ? is this safe
- }
- else
- {
- this.data = new HashMap(data);
- }
+ this.data.putAll(data);// ? is this safe
}
}
@@ -240,7 +233,7 @@
public synchronized Map<Object, Object> getDataDirect()
{
- return data();
+ return new MapCopy(data);
}
@@ -251,7 +244,7 @@
public synchronized Object putDirect(Object key, Object value)
{
- return data().put(key, value);
+ return data.put(key, value);
}
public NodeSPI getOrCreateChild(Object child_name, GlobalTransaction gtx)
@@ -435,7 +428,7 @@
public Set<Object> getChildrenNamesDirect()
{
- return new ChildrenNames();
+ return Collections.unmodifiableSet(new HashSet(new ChildrenNames()));
}
public Set<Object> getKeys()
@@ -450,7 +443,7 @@
{
return Collections.emptySet();
}
- return Collections.unmodifiableSet(data.keySet());
+ return Collections.unmodifiableSet(new HashSet(data.keySet()));
}
public boolean hasChild(Fqn f)
@@ -458,12 +451,12 @@
return cache.exists(new Fqn(getFqn(), f));
}
- public void putIfNull(Object k, Object v)
+ public void putIfAbsent(Object k, Object v)
{
throw new UnsupportedOperationException("This operation was only added in \
2.0.0 to finalise the API. This will not be implemented till 2.1.0."); }
- public void putIfNull(Map m)
+ public void putIfAbsent(Map m)
{
throw new UnsupportedOperationException("This operation was only added in \
2.0.0 to finalise the API. This will not be implemented till 2.1.0."); }
@@ -496,12 +489,12 @@
}
}
- public synchronized Map<Object, Node> getChildrenMap()
+ public synchronized Map<Object, Node> getChildrenMapDirect()
{
- return children();
+ return new MapCopy(children());
}
- public synchronized void setChildrenMap(Map<Object, Node> children)
+ public synchronized void setChildrenMapDirect(Map<Object, Node> children)
{
this.children = children;
}
@@ -514,10 +507,10 @@
public synchronized void putDirect(Map data)
{
if (data == null) return;
- data().putAll(data);
+ data.putAll(data);
}
- public synchronized void removeChildren()
+ public synchronized void removeChildrenDirect()
{
if (children != null)
{
@@ -666,18 +659,6 @@
}
/**
- * Returns null or the Map in use with the data.
- */
- private Map data()
- {
- if (data == null)
- {
- data = new HashMap<Object, Object>();
- }
- return data;
- }
-
- /**
* Adds details of the node into a map as strings.
*/
private void printDetailsInMap(StringBuffer sb, int indent)
@@ -690,7 +671,7 @@
}
sb.append(getName());
sb.append(" ");
- sb.append(data());
+ sb.append(data);
if (children != null)
{
for (Node n : children.values())
@@ -717,15 +698,6 @@
this.dataLoaded = dataLoaded;
}
- /**
- * Might be useful to expose; a debug feature for now.
- */
- void setReadOnly()
- {
- this.data = new MapCopy(data());
- this.children = new MapCopy(children());
- }
-
private class ChildrenNames extends AbstractSet implements Serializable
{
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic