Author: manik.surtani(a)jboss.com
Date: 2008-01-28 10:00:27 -0500 (Mon, 28 Jan 2008)
New Revision: 5246
Modified:
core/trunk/src/main/java/org/jboss/cache/NodeSPI.java
core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
Log:
Cleaned up unused methods in UnversionedNode
Modified: core/trunk/src/main/java/org/jboss/cache/NodeSPI.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/NodeSPI.java 2008-01-28 11:47:58 UTC (rev
5245)
+++ core/trunk/src/main/java/org/jboss/cache/NodeSPI.java 2008-01-28 15:00:27 UTC (rev
5246)
@@ -162,7 +162,7 @@
* @param sb StringBuffer to print to
* @param indent depth of this node in the tree. Used to indent details by prepending
spaces.
*/
-
+ @Deprecated
void print(StringBuffer sb, int indent);
// versioning
Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-01-28 11:47:58 UTC
(rev 5245)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-01-28 15:00:27 UTC
(rev 5246)
@@ -31,15 +31,10 @@
* @author Manik Surtani (<a
href="mailto:manik@jboss.org">manik@jboss.org</a>)
* @since 2.0.0
*/
+@SuppressWarnings("unchecked")
public class UnversionedNode<K, V> extends AbstractNode<K, V>
{
-
/**
- * Default output indent for printing.
- */
- private static final int INDENT = 4;
-
- /**
* Debug log.
*/
protected static Log log = LogFactory.getLog(UnversionedNode.class);
@@ -64,13 +59,13 @@
/**
* A reference of the CacheImpl instance.
*/
- private transient CacheSPI<K, V> cache;
+ private transient CacheSPI cache;
private transient CacheImpl cacheImpl;
/**
* Map of general data keys to values.
*/
- private final Map<K, V> data = new HashMap<K, V>();
+ private final Map data = new HashMap();
private boolean lockForChildInsertRemove;
@@ -96,7 +91,7 @@
* {@link #data} field; <code>false</code> if param
<code>data</code>'s contents should be copied into
* this object's {@link #data} field.
*/
- protected UnversionedNode(Object child_name, Fqn fqn, Map<K, V> data, boolean
mapSafe, CacheSPI<K, V> cache)
+ protected UnversionedNode(Object child_name, Fqn fqn, Map data, boolean mapSafe,
CacheSPI cache)
{
init(child_name, fqn, cache);
setInternalState(data);
@@ -122,7 +117,7 @@
/**
* Initializes with a name and FQN and cache.
*/
- private void init(Object child_name, Fqn fqn, CacheSPI<K, V> cache)
+ private void init(Object child_name, Fqn fqn, CacheSPI cache)
{
if (cache == null)
{
@@ -140,7 +135,7 @@
/**
* Returns a parent by checking the TreeMap by name.
*/
- public NodeSPI<K, V> getParent()
+ public NodeSPI getParent()
{
if (fqn.isRoot())
{
@@ -174,7 +169,7 @@
return children;
}
- public CacheSPI<K, V> getCache()
+ public CacheSPI getCache()
{
return cache;
}
@@ -195,13 +190,13 @@
throw new NodeNotValidException("Node " + getFqn() + " is not
valid. Perhaps it has been moved or removed.");
}
- public V get(K key)
+ public Object get(Object key)
{
assertValid();
return cache.get(getFqn(), key);
}
- public V getDirect(K key)
+ public Object getDirect(Object key)
{
return data.get(key);
}
@@ -223,54 +218,45 @@
return lock_;
}
- public Map<K, V> getData()
+ public Map getDataDirect()
{
- // TODO: Fix this
- throw new RuntimeException("Should never get here - use
NodeInterceptorDelegate!");
-// assertValid();
-// if (cache == null) return Collections.emptyMap();
-// return cache.getData(getFqn());
- }
-
- public Map<K, V> getDataDirect()
- {
if (data == null) return Collections.emptyMap();
return Collections.unmodifiableMap(data);
}
- public V put(K key, V value)
+ public Object put(Object key, Object value)
{
assertValid();
return cache.put(getFqn(), key, value);
}
- public V putDirect(K key, V value)
+ public Object putDirect(Object key, Object value)
{
return data.put(key, value);
}
- public NodeSPI<K, V> getOrCreateChild(Object child_name, GlobalTransaction gtx,
boolean notify)
+ public NodeSPI getOrCreateChild(Object child_name, GlobalTransaction gtx, boolean
notify)
{
return getOrCreateChild(child_name, gtx, true, notify);
}
- private NodeSPI<K, V> getOrCreateChild(Object child_name, GlobalTransaction gtx,
boolean createIfNotExists, boolean notify)
+ private NodeSPI getOrCreateChild(Object child_name, GlobalTransaction gtx, boolean
createIfNotExists, boolean notify)
{
- NodeSPI<K, V> child;
+ NodeSPI child;
if (child_name == null)
{
throw new IllegalArgumentException("null child name");
}
- child = (NodeSPI<K, V>) children().get(child_name);
+ child = (NodeSPI) children().get(child_name);
InvocationContext ctx = cache.getInvocationContext();
if (createIfNotExists && child == null)
{
// 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);
- NodeSPI<K, V> newChild = (NodeSPI<K, V>)
cache.getConfiguration().getRuntimeConfig().getNodeFactory().createNode(child_name,
delegate, null);
+ NodeSPI newChild = (NodeSPI)
cache.getConfiguration().getRuntimeConfig().getNodeFactory().createNode(child_name,
delegate, null);
if (newChild == null)
{
throw new IllegalStateException();
@@ -279,7 +265,7 @@
{
// check again to see if the child exists
// after acquiring exclusive lock
- child = (NodeSPI<K, V>) children().get(child_name);
+ child = (NodeSPI) children().get(child_name);
if (child == null)
{
if (notify) cache.getNotifier().notifyNodeCreated(child_fqn, true, ctx);
@@ -311,13 +297,13 @@
}
- public V remove(K key)
+ public Object remove(Object key)
{
assertValid();
return cache.remove(getFqn(), key);
}
- public V removeDirect(K key)
+ public Object removeDirect(Object key)
{
if (data == null) return null;
return data.remove(key);
@@ -434,16 +420,8 @@
return sb.toString();
}
- public Node<K, V> addChild(Fqn f)
+ public void addChildDirect(NodeSPI child)
{
- assertValid();
- Fqn nf = new Fqn(getFqn(), f);
- cache.put(nf, null);
- return getChild(f);
- }
-
- public void addChildDirect(NodeSPI<K, V> child)
- {
if (child.getFqn().getParent().equals(getFqn()))
{
synchronized (this)
@@ -455,12 +433,12 @@
throw new CacheException("Attempting to add a child [" +
child.getFqn() + "] to [" + getFqn() + "]. Can only add direct
children.");
}
- public NodeSPI<K, V> addChildDirect(Fqn f)
+ public NodeSPI addChildDirect(Fqn f)
{
return addChildDirect(f, true);
}
- public NodeSPI<K, V> addChildDirect(Fqn f, boolean notify)
+ public NodeSPI addChildDirect(Fqn f, boolean notify)
{
if (f.size() == 1)
{
@@ -474,31 +452,13 @@
}
- public void clearData()
- {
- // TODO: Fix this
- throw new RuntimeException("Should never get here - use
NodeInterceptorDelegate!");
-
-// assertValid();
-// cache.removeData(getFqn());
- }
-
public void clearDataDirect()
{
if (data != null) data.clear();
}
- public Node<K, V> getChild(Fqn fqn)
+ public NodeSPI getChildDirect(Fqn fqn)
{
- // TODO: Fix this
- throw new RuntimeException("Should never get here - use
NodeInterceptorDelegate!");
-//
-// assertValid();
-// return cache.get(new Fqn(getFqn(), fqn));
- }
-
- public NodeSPI<K, V> getChildDirect(Fqn fqn)
- {
if (fqn.size() == 1)
{
return getChildDirect(fqn.getLastElement());
@@ -516,116 +476,20 @@
}
}
- public Set<Object> getChildrenNames()
- {
- // TODO: Fix this
- throw new RuntimeException("Should never get here - use
NodeInterceptorDelegate!");
-
-// assertValid();
-// return cache.getChildrenNames(getFqn());
- }
-
public Set<Object> getChildrenNamesDirect()
{
return children == null ? Collections.emptySet() : new
HashSet<Object>(children.keySet());
}
- public Set<K> getKeys()
+ public Set<Object> getKeysDirect()
{
- // TODO: Fix this
- throw new RuntimeException("Should never get here - use
NodeInterceptorDelegate!");
-
-// assertValid();
-// Set<K> keys = cache.getKeys(getFqn());
-// return keys == null ? Collections.<K>emptySet() :
Collections.<K>unmodifiableSet(keys);
- }
-
- public Set<K> getKeysDirect()
- {
if (data == null)
{
return Collections.emptySet();
}
- return Collections.unmodifiableSet(new HashSet<K>(data.keySet()));
+ return Collections.unmodifiableSet(new HashSet<Object>(data.keySet()));
}
- public boolean hasChild(Fqn f)
- {
- assertValid();
- return getChild(f) != null;
- }
-
- public boolean hasChild(Object o)
- {
- assertValid();
- return getChild(o) != null;
- }
-
- public V putIfAbsent(K k, V v)
- {
- assertValid();
- // make sure this is atomic. Not hugely performant at the moment (should use the
locking interceptors) but for now ...
- synchronized (this)
- {
- if (!getKeys().contains(k))
- return put(k, v);
- else
- return get(k);
- }
- }
-
- public V replace(K key, V value)
- {
- assertValid();
- // make sure this is atomic. Not hugely performant at the moment (should use the
locking interceptors) but for now ...
- synchronized (this)
- {
- if (getKeys().contains(key))
- {
- return put(key, value);
- }
- else
- return null;
- }
- }
-
- public boolean replace(K key, V oldValue, V newValue)
- {
- assertValid();
- // make sure this is atomic. Not hugely performant at the moment (should use the
locking interceptors) but for now ...
- synchronized (this)
- {
- if (oldValue.equals(get(key)))
- {
- put(key, newValue);
- return true;
- }
- else
- return false;
- }
- }
-
- public boolean removeChild(Fqn fqn)
- {
- assertValid();
- return cache.removeNode(new Fqn(getFqn(), fqn));
- }
-
- public int dataSize()
- {
- // TODO: Fix this
- throw new RuntimeException("Should never get here - use
NodeInterceptorDelegate!");
-//
-// assertValid();
-// return cache.getKeys(getFqn()).size();
- }
-
- public boolean removeChild(Object childName)
- {
- assertValid();
- return cache.removeNode(new Fqn(getFqn(), childName));
- }
-
public boolean removeChildDirect(Object childName)
{
return children != null && children.remove(childName) != null;
@@ -655,23 +519,14 @@
this.children.putAll(children);
}
- public void putAll(Map<K, V> data)
+ public void putAll(Map data)
{
assertValid();
cache.put(fqn, data);
}
- public void replaceAll(Map<K, V> data)
+ public void putAllDirect(Map data)
{
- // TODO: Fix this
- throw new RuntimeException("Should never get here - use
NodeInterceptorDelegate!");
-
-// assertValid();
-// cache.put(fqn, data, true);
- }
-
- public void putAllDirect(Map<K, V> data)
- {
if (data == null) return;
this.data.putAll(data);
}
@@ -685,20 +540,6 @@
children = null;
}
- public void print(StringBuffer sb, int indent)
- {
- printIndent(sb, indent);
- sb.append(Fqn.SEPARATOR).append(getName()).append("
").append(getDataDirect().size());
- if (children != null)
- {
- for (Node node : children.values())
- {
- sb.append("\n");
- ((NodeSPI) node).print(sb, indent + INDENT);
- }
- }
- }
-
// versioning
public void setVersion(DataVersion version)
@@ -722,7 +563,7 @@
}
}
- public void addChild(Object child_name, Node<K, V> n)
+ public void addChild(Object child_name, Node n)
{
if (child_name != null)
{
@@ -768,45 +609,21 @@
}
}
- public Node<K, V> getChild(Object childName)
+ public NodeSPI getChildDirect(Object childName)
{
- // TODO: Fix this
- throw new RuntimeException("Should never get here - use
NodeInterceptorDelegate!");
-//
-// return cache.get(new Fqn(getFqn(), childName));
- }
-
- public NodeSPI<K, V> getChildDirect(Object childName)
- {
if (childName == null) return null;
- return (NodeSPI<K, V>) (children == null ? null : children.get(childName));
+ return (NodeSPI) (children == null ? null : children.get(childName));
}
- public Set<Node<K, V>> getChildren()
+ public Set<NodeSPI> getChildrenDirect()
{
- // TODO: Fix this
- throw new RuntimeException("Should never get here - use
NodeInterceptorDelegate!");
-
-// assertValid();
-// if (cache == null) return Collections.emptySet();
-// Set<Node<K, V>> children = new HashSet<Node<K, V>>();
-// for (Object c : cache.getChildrenNames(getFqn()))
-// {
-// Node n = cache.get(new Fqn(getFqn(), c));
-// if (n != null) children.add(n);
-// }
-// return Collections.unmodifiableSet(children);
- }
-
- public Set<NodeSPI<K, V>> getChildrenDirect()
- {
// strip out deleted child nodes...
if (children == null || children.size() == 0) return Collections.emptySet();
- Set<NodeSPI<K, V>> exclDeleted = new HashSet<NodeSPI<K,
V>>();
- for (Node<K, V> n : children.values())
+ Set<NodeSPI> exclDeleted = new HashSet<NodeSPI>();
+ for (Node n : children.values())
{
- NodeSPI<K, V> spi = (NodeSPI<K, V>) n;
+ NodeSPI spi = (NodeSPI) n;
if (!spi.isDeleted()) exclDeleted.add(spi);
}
return Collections.unmodifiableSet(exclDeleted);
@@ -817,7 +634,7 @@
return children != null && children.size() != 0;
}
- public Set<NodeSPI<K, V>> getChildrenDirect(boolean
includeMarkedForRemoval)
+ public Set<NodeSPI> getChildrenDirect(boolean includeMarkedForRemoval)
{
if (includeMarkedForRemoval)
{
@@ -904,14 +721,12 @@
this.lockForChildInsertRemove = lockForChildInsertRemove;
}
- @SuppressWarnings("unchecked")
public void setInternalState(Map state)
{
// don't bother doing anything here
putAllDirect(state);
}
- @SuppressWarnings("unchecked")
public Map getInternalState(boolean onlyInternalState)
{
if (onlyInternalState)
@@ -925,7 +740,7 @@
{
if (recursive && children != null)
{
- for (Node child : children.values())
+ for (Node<?, ?> child : children.values())
{
child.releaseObjectReferences(recursive);
}
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2008-01-28
11:47:58 UTC (rev 5245)
+++
core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2008-01-28
15:00:27 UTC (rev 5246)
@@ -1,5 +1,6 @@
package org.jboss.cache.invocation;
+import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
@@ -118,7 +119,7 @@
public void print(StringBuffer sb, int indent)
{
- node.print(sb, indent);
+ throw new CacheException("This method is deprecated!");
}
public void setVersion(DataVersion version)