|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jboss.cache.invocation.AbstractInvocationDelegate org.jboss.cache.invocation.NodeInvocationDelegate<K,V>
public class NodeInvocationDelegate<K,V>
The delegate that users (and interceptor authors) interact with when they obtain a node from the cache or another node. This wrapper delegates calls down the interceptor chain.
Field Summary |
---|
Fields inherited from class org.jboss.cache.invocation.AbstractInvocationDelegate |
---|
cache, configuration, interceptorChain, invocationContextContainer, log, originLocal |
Constructor Summary | |
---|---|
NodeInvocationDelegate(UnversionedNode node)
|
Method Summary | |
---|---|
Node<K,V> |
addChild(Fqn<?> f)
Adds a child node with the given Fqn under the current node. |
void |
addChild(Object nodeName,
Node<K,V> nodeToAdd)
Adds or replaces a child by name. |
NodeSPI<K,V> |
addChildDirect(Fqn childName)
Adds a child directly to a Node. |
NodeSPI<K,V> |
addChildDirect(Fqn f,
boolean notify)
Same as NodeSPI.addChildDirect(Fqn) except that it optionally allows you to suppress notification events for
the creation of this node. |
void |
addChildDirect(NodeSPI<K,V> child)
Directly adds the node passed in to the children map of the current node. |
NodeSPI<K,V> |
addChildDirect(Object childName,
boolean notify)
Same as NodeSPI.addChildDirect(Fqn, boolean) except that it just takes a child name |
protected void |
assertValid()
|
void |
clearData()
Removes all mappings from the node's data map. |
void |
clearDataDirect()
Functionally the same as Node.clearData() except that it operates directly on the node and bypasses the
interceptor chain. |
int |
dataSize()
|
V |
get(K key)
Returns the value to which this node maps the specified key. |
CacheSPI<K,V> |
getCache()
Retrieves a reference to the cache in which this Node resides. |
Map<K,V> |
getData()
Returns a map containing the data in this Node . |
Map<K,V> |
getDataDirect()
Functionally the same as Node.getData() except that it operates directly on the node and bypasses the
interceptor chain. |
Object |
getDelegationTarget()
|
V |
getDirect(K key)
Functionally the same as Node.get(Object) except that it operates directly on the node and bypasses the
interceptor chain. |
Fqn |
getFqn()
Returns the Fqn which represents the location of this Node in the cache structure. |
Node<K,V> |
getChild(Fqn<?> f)
Returns the child node |
Node<K,V> |
getChild(Object name)
|
NodeSPI<K,V> |
getChildDirect(Fqn childName)
Retrives a child directly by fully qualified name. |
NodeSPI<K,V> |
getChildDirect(Object childName)
Retrives a child directly by name. |
Set<Node<K,V>> |
getChildren()
Returns an immutable set of children nodes. |
Set<NodeSPI<K,V>> |
getChildrenDirect()
Functionally the same as Node.getChildren() except that it operates directly on the node and bypasses the
interceptor chain. |
Set<NodeSPI<K,V>> |
getChildrenDirect(boolean includeMarkedAsDeleted)
Retrieves children (directly), optionally including any marked as deleted nodes. |
Map<Object,Node<K,V>> |
getChildrenMapDirect()
Returns a map to access the raw children. |
Set<Object> |
getChildrenNames()
Returns an immutable set of children node names. |
Set<Object> |
getChildrenNamesDirect()
Functionally the same as Node.getChildrenNames() except that it operates directly on the node and bypasses the
interceptor chain. |
Map |
getInternalState(boolean onlyInternalState)
Very similar to NodeSPI.getDataDirect() , except that this method may also encode some internal data as attributes in the map,
using special _JBOSS_INTERNAL_XXX Strings as keys. |
Set<K> |
getKeys()
Returns a Set containing the data in this Node . |
Set<K> |
getKeysDirect()
Functionally the same as Node.getKeys() except that it operates directly on the node and bypasses the
interceptor chain. |
NodeLock |
getLock()
Returns a lock for this node. |
NodeSPI<K,V> |
getOrCreateChild(Object name,
GlobalTransaction tx)
Returns an existing child or creates a new one using a global transaction. |
NodeSPI<K,V> |
getParent()
Returns the parent node. |
DataVersion |
getVersion()
Returns the data version of this node if versioning is supported. |
boolean |
hasChild(Fqn<?> f)
Returns true if the child node denoted by the relative Fqn passed in exists. |
boolean |
hasChild(Object o)
Returns true if the child node denoted by the Object name passed in exists. |
boolean |
hasChildrenDirect()
|
boolean |
isDataLoaded()
Returns true if the data was loaded from the cache loader. |
boolean |
isDeleted()
Returns true if the instance has been deleted in the current transaction. |
boolean |
isChildrenLoaded()
Returns true if the children of this node were loaded from a cache loader. |
boolean |
isLockForChildInsertRemove()
Tests whether this node is configured to be exclusively locked when inserting or removing children. |
boolean |
isResident()
Nodes marked resident would be ignored by the eviction algorithms. |
boolean |
isValid()
Tests if a node reference is still valid. |
void |
markAsDeleted(boolean marker)
Marks the node as being deleted (or not) in the current transaction. |
void |
markAsDeleted(boolean marker,
boolean recursive)
Same as NodeSPI.markAsDeleted(boolean) except that the option to recurse into children is provided. |
void |
print(StringBuffer sb,
int indent)
Prints basic information of this node to the StringBuffer passed in. |
void |
printDetails(StringBuffer sb,
int indent)
Prints details of this node to the StringBuffer passed in. |
V |
put(K key,
V value)
Associates the specified value with the specified key for this node. |
void |
putAll(Map<K,V> data)
Copies all of the mappings from the specified map to this node's map. |
void |
putAllDirect(Map<K,V> data)
Functionally the same as Node.putAll(Map) except that it operates directly on the node and bypasses the
interceptor chain. |
V |
putDirect(K key,
V value)
Functionally the same as Node.put(Object,Object) except that it operates directly on the node and bypasses the
interceptor chain. |
V |
putIfAbsent(K k,
V v)
If the specified key is not already associated with a value, associate it with the given value, and returns the Object (if any) that occupied the space, or null. |
void |
releaseObjectReferences(boolean recursive)
Method that releases object references of cached objects held in the cache by serializing them to byte buffers. |
V |
remove(K key)
Removes the mapping for this key from this node if it is present. |
V |
removeDirect(K key)
Removes a data key directly from a node. |
boolean |
removeChild(Fqn<?> f)
Removes a child node specified by the given relative Fqn . |
boolean |
removeChild(Object childName)
Removes a child node specified by the given name. |
boolean |
removeChildDirect(Fqn fqn)
Removes a child directly from a node. |
boolean |
removeChildDirect(Object childName)
Removes a child directly from a node. |
void |
removeChildrenDirect()
Directly removes all children for this node. |
V |
replace(K key,
V value)
Replace entry for key only if currently mapped to some value. |
boolean |
replace(K key,
V oldValue,
V newValue)
Replace entry for key only if currently mapped to given value. |
void |
replaceAll(Map<K,V> data)
Similar to Node.putAll(java.util.Map) except that it removes any entries that exists in
the data map first. |
void |
setDataLoaded(boolean dataLoaded)
Sets if the data was loaded from the cache loader. |
void |
setFqn(Fqn<?> f)
Sets the FQN of this node and resets the names of all children as well. |
void |
setChildrenLoaded(boolean loaded)
Sets if the children of this node were loaded from a cache loader. |
void |
setChildrenMapDirect(Map<Object,Node<K,V>> children)
Sets the node's children explictly. |
void |
setInternalState(Map state)
Very similar to NodeSPI.putAllDirect(java.util.Map) except that this method first scans the map for any internal attributes
using special _JBOSS_INTERNAL_XXX Strings as keys, and uses these to set internal attributes before passing
the remaining attributes to NodeSPI.putAllDirect(java.util.Map) . |
void |
setLockForChildInsertRemove(boolean lockForChildInsertRemove)
Configures the behaviour of how this node is locked when adding/removing children. |
void |
setResident(boolean resident)
|
void |
setValid(boolean valid,
boolean recursive)
Sets the validity of a node. |
void |
setVersion(DataVersion version)
Sets the data version of this node if versioning is supported. |
String |
toString()
|
Methods inherited from class org.jboss.cache.invocation.AbstractInvocationDelegate |
---|
assertIsConstructed, invoke, invoke |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public NodeInvocationDelegate(UnversionedNode node)
Method Detail |
---|
public Object getDelegationTarget()
public boolean isChildrenLoaded()
NodeSPI
isChildrenLoaded
in interface NodeSPI<K,V>
public void setChildrenLoaded(boolean loaded)
NodeSPI
setChildrenLoaded
in interface NodeSPI<K,V>
loaded
- true if loaded, false otherwisepublic boolean isDataLoaded()
NodeSPI
isDataLoaded
in interface NodeSPI<K,V>
public void setDataLoaded(boolean dataLoaded)
NodeSPI
setDataLoaded
in interface NodeSPI<K,V>
dataLoaded
- true if loaded, false otherwisepublic Map<Object,Node<K,V>> getChildrenMapDirect()
NodeSPI
getChildrenMapDirect
in interface NodeSPI<K,V>
public void setChildrenMapDirect(Map<Object,Node<K,V>> children)
NodeSPI
setChildrenMapDirect
in interface NodeSPI<K,V>
children
- cannot be nullpublic NodeSPI<K,V> getOrCreateChild(Object name, GlobalTransaction tx)
NodeSPI
getOrCreateChild
in interface NodeSPI<K,V>
name
- name of child to createtx
- transaction under which to create child
public NodeLock getLock()
NodeSPI
getLock
in interface NodeSPI<K,V>
public void setFqn(Fqn<?> f)
NodeSPI
setFqn
in interface NodeSPI<K,V>
f
- fqn to setpublic boolean isDeleted()
NodeSPI
isDeleted
in interface NodeSPI<K,V>
public void markAsDeleted(boolean marker)
NodeSPI
markAsDeleted
in interface NodeSPI<K,V>
marker
- true if the node has been deleted, false if not.public void markAsDeleted(boolean marker, boolean recursive)
NodeSPI
NodeSPI.markAsDeleted(boolean)
except that the option to recurse into children is provided.
markAsDeleted
in interface NodeSPI<K,V>
marker
- true if the node has been deleted, false if not.recursive
- if true, child nodes (and their children) are marked as well.public void addChild(Object nodeName, Node<K,V> nodeToAdd)
NodeSPI
addChild
in interface NodeSPI<K,V>
nodeName
- child node name (not an FQN)nodeToAdd
- child nodepublic void printDetails(StringBuffer sb, int indent)
NodeSPI
printDetails
in interface NodeSPI<K,V>
sb
- StringBuffer to print toindent
- depth of this node in the tree. Used to indent details by prepending spaces.public void print(StringBuffer sb, int indent)
NodeSPI
print
in interface NodeSPI<K,V>
sb
- StringBuffer to print toindent
- depth of this node in the tree. Used to indent details by prepending spaces.public void setVersion(DataVersion version)
NodeSPI
setVersion
in interface NodeSPI<K,V>
version
- data version to applypublic DataVersion getVersion()
NodeSPI
getVersion
in interface NodeSPI<K,V>
public Set<NodeSPI<K,V>> getChildrenDirect()
NodeSPI
Node.getChildren()
except that it operates directly on the node and bypasses the
interceptor chain.
The caller needs to ensure a proper lock has been obtained prior to calling this method, otherwise a
LockingException
will be thrown.
getChildrenDirect
in interface NodeSPI<K,V>
Node.getChildren()
public void removeChildrenDirect()
NodeSPI
removeChildrenDirect
in interface NodeSPI<K,V>
public Set<NodeSPI<K,V>> getChildrenDirect(boolean includeMarkedAsDeleted)
NodeSPI
getChildrenDirect
in interface NodeSPI<K,V>
includeMarkedAsDeleted
- if true, the returned set will include nodes marked as deleted
public NodeSPI<K,V> getChildDirect(Object childName)
NodeSPI
Node.getChild(Object)
except that it bypasses the
interceptor chain.
The caller needs to ensure a proper lock has been obtained prior to calling this method.
getChildDirect
in interface NodeSPI<K,V>
childName
- name of child
Node.getChild(Object)
public NodeSPI<K,V> addChildDirect(Fqn childName)
NodeSPI
Node.addChild(Fqn)
except that it bypasses the
interceptor chain.
The caller needs to ensure a proper lock has been obtained prior to calling this method.
addChildDirect
in interface NodeSPI<K,V>
childName
- name of child
Node.addChild(Fqn)
public NodeSPI<K,V> addChildDirect(Fqn f, boolean notify)
NodeSPI
NodeSPI.addChildDirect(Fqn)
except that it optionally allows you to suppress notification events for
the creation of this node.
addChildDirect
in interface NodeSPI<K,V>
f
- name of childnotify
- if true, notification events are sent; if false, they are not
Node.addChild(Fqn)
public NodeSPI<K,V> addChildDirect(Object childName, boolean notify)
NodeSPI
NodeSPI.addChildDirect(Fqn, boolean)
except that it just takes a child name
addChildDirect
in interface NodeSPI<K,V>
childName
- name of childnotify
- if true, notification events are sent; if false, they are not
Node.addChild(Fqn)
public void addChildDirect(NodeSPI<K,V> child)
NodeSPI
addChildDirect
in interface NodeSPI<K,V>
child
- child to addpublic NodeSPI<K,V> getChildDirect(Fqn childName)
NodeSPI
Node.getChild(Fqn)
except that it bypasses the
interceptor chain.
The caller needs to ensure a proper lock has been obtained prior to calling this method.
getChildDirect
in interface NodeSPI<K,V>
childName
- name of child
Node.getChild(Fqn)
public boolean removeChildDirect(Fqn fqn)
NodeSPI
Node.removeChild(Fqn)
except that it bypasses the
interceptor chain.
The caller needs to ensure a proper lock has been obtained prior to calling this method, otherwise a
removeChildDirect
in interface NodeSPI<K,V>
fqn
- of child.
Node.removeChild(Fqn)
public boolean removeChildDirect(Object childName)
NodeSPI
Node.removeChild(Object)
except that bypasses the
interceptor chain.
The caller needs to ensure a proper lock has been obtained prior to calling this method.
removeChildDirect
in interface NodeSPI<K,V>
childName
- of child.
Node.removeChild(Object)
public V removeDirect(K key)
NodeSPI
Node.remove(Object)
except that it bypasses the
interceptor chain.
The caller needs to ensure a proper lock has been obtained prior to calling this method.
removeDirect
in interface NodeSPI<K,V>
key
- to remove
Node.remove(Object)
public V putDirect(K key, V value)
NodeSPI
Node.put(Object,Object)
except that it operates directly on the node and bypasses the
interceptor chain.
The caller needs to ensure a proper lock has been obtained prior to calling this method, otherwise a
LockingException
will be thrown.
putDirect
in interface NodeSPI<K,V>
key
- of datavalue
- of data
Node.put(Object,Object)
public void putAllDirect(Map<K,V> data)
NodeSPI
Node.putAll(Map)
except that it operates directly on the node and bypasses the
interceptor chain.
The caller needs to ensure a proper lock has been obtained prior to calling this method, otherwise a
LockingException
will be thrown.
putAllDirect
in interface NodeSPI<K,V>
data
- to putNode.putAll(Map)
public Map<K,V> getDataDirect()
NodeSPI
Node.getData()
except that it operates directly on the node and bypasses the
interceptor chain.
Note that this returns a reference to access the node's data.
This data should only be modified by the cache itself.
This method should never return null.
Also note that this method returns an unmodifiable reference to the underlying data map.
The caller needs to ensure a proper lock has been obtained prior to calling this method, otherwise a
LockingException
will be thrown.
getDataDirect
in interface NodeSPI<K,V>
Node.getData()
public V getDirect(K key)
NodeSPI
Node.get(Object)
except that it operates directly on the node and bypasses the
interceptor chain.
The caller needs to ensure a proper lock has been obtained prior to calling this method, otherwise a
LockingException
will be thrown.
getDirect
in interface NodeSPI<K,V>
key
- data to get
Node.get(Object)
public void clearDataDirect()
NodeSPI
Node.clearData()
except that it operates directly on the node and bypasses the
interceptor chain.
The caller needs to ensure a proper lock has been obtained prior to calling this method, otherwise a
LockingException
will be thrown.
clearDataDirect
in interface NodeSPI<K,V>
Node.clearData()
public Set<K> getKeysDirect()
NodeSPI
Node.getKeys()
except that it operates directly on the node and bypasses the
interceptor chain.
The caller needs to ensure a proper lock has been obtained prior to calling this method, otherwise a
LockingException
will be thrown.
getKeysDirect
in interface NodeSPI<K,V>
Node.getKeys()
public Set<Object> getChildrenNamesDirect()
NodeSPI
Node.getChildrenNames()
except that it operates directly on the node and bypasses the
interceptor chain.
The caller needs to ensure a proper lock has been obtained prior to calling this method, otherwise a
LockingException
will be thrown.
getChildrenNamesDirect
in interface NodeSPI<K,V>
Node.getChildrenNames()
public CacheSPI<K,V> getCache()
NodeSPI
getCache
in interface NodeSPI<K,V>
public NodeSPI<K,V> getParent()
Node
null
.
getParent
in interface Node<K,V>
getParent
in interface NodeSPI<K,V>
Node.getParent()
public Set<Node<K,V>> getChildren()
Node
getChildren
in interface Node<K,V>
Set
of child nodes. Empty Set
if there aren't any children.public Set<Object> getChildrenNames()
Node
getChildrenNames
in interface Node<K,V>
Set
of child node names. Empty Set
if there aren't any children.public Map<K,V> getData()
Node
Node
.
getData
in interface Node<K,V>
Map
containing the data in this Node
. If there is no data, an empty Map
is returned. The Map
returned is always immutable.public Set<K> getKeys()
Node
Set
containing the data in this Node
.
getKeys
in interface Node<K,V>
Set
containing the data in this Node
. If there is no data, an empty Set
is returned. The Set
returned is always immutable.public Fqn getFqn()
Node
Fqn
which represents the location of this Node
in the cache structure. The Fqn
returned is absolute.
getFqn
in interface Node<K,V>
Fqn
which represents the location of this Node
in the cache structure. The Fqn
returned is absolute.public Node<K,V> addChild(Fqn<?> f)
Node
Fqn
under the current node. Returns the newly created node.
If the child exists returns the child node anyway. Guaranteed to return a non-null node.
The Fqn
passed in is relative to the current node. The new child node will have an absolute fqn
calculated as follows: new Fqn(getFqn(), f). See
Fqn
for the operation of this constructor.
addChild
in interface Node<K,V>
f
- Fqn
of the child node, relative to the current node.
public boolean removeChild(Fqn<?> f)
Node
Fqn
.
If you wish to remove children based on absolute Fqn
s, use the Cache
interface instead.
removeChild
in interface Node<K,V>
f
- Fqn
of the child node, relative to the current node.
public boolean removeChild(Object childName)
Node
removeChild
in interface Node<K,V>
childName
- name of the child node, directly under the current node.
public Node<K,V> getChild(Fqn<?> f)
Node
getChild
in interface Node<K,V>
f
- Fqn
of the child node
public Node<K,V> getChild(Object name)
getChild
in interface Node<K,V>
name
- name of the child
public V put(K key, V value)
Node
put
in interface Node<K,V>
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.
public V putIfAbsent(K k, V v)
Node
if (!node.getKeys().contains(key)) return node.put(key, value); else return node.get(key);except that this is atomic.
putIfAbsent
in interface Node<K,V>
k
- key with which the specified value is to be associated.v
- value to be associated with the specified key.
public V replace(K key, V value)
Node
if ((node.getKeys().contains(key)) { return node.put(key, value); } else return null;except that this is atomic.
replace
in interface Node<K,V>
key
- key with which the specified value is associated.value
- value to be associated with the specified key.
public boolean replace(K key, V oldValue, V newValue)
Node
if (node.get(key).equals(oldValue)) { node.putAll(key, newValue); return true; } else return false;except that this is atomic.
replace
in interface Node<K,V>
key
- key with which the specified value is associated.oldValue
- value expected to be associated with the specified key.newValue
- value to be associated with the specified key.
public void putAll(Map<K,V> data)
Node
Node node; for (Map.Entry me : map.entrySet()) node.put(me.getKey(), me.getValue());
putAll
in interface Node<K,V>
data
- map to copy frompublic void replaceAll(Map<K,V> data)
Node
Node.putAll(java.util.Map)
except that it removes any entries that exists in
the data map first. Note that this happens atomically, under a single lock. This is the analogous
to doing a Node.clearData()
followed by a Node.putAll(java.util.Map)
in the same transaction.
replaceAll
in interface Node<K,V>
data
- map to copy frompublic V get(K key)
Node
null
if the node contains no mapping for this key.
get
in interface Node<K,V>
key
- key of the data to return
null
if the map contains no mapping for this keypublic V remove(K key)
Node
null
if the node contained no mapping for this key
remove
in interface Node<K,V>
key
- key whose mapping is to be removed
null
if there was no mapping for keypublic void clearData()
Node
clearData
in interface Node<K,V>
public int dataSize()
dataSize
in interface Node<K,V>
public boolean hasChild(Fqn<?> f)
Node
Fqn
passed in exists.
hasChild
in interface Node<K,V>
f
- Fqn
relative to the current node of the child you are testing the existence of.
Fqn
passed in exists.public boolean hasChild(Object o)
Node
hasChild
in interface Node<K,V>
o
- name of the child, relative to the current node
public boolean isValid()
Node
NodeNotValidException
.
isValid
in interface Node<K,V>
public boolean isResident()
Node
isResident
in interface Node<K,V>
public void setResident(boolean resident)
setResident
in interface Node<K,V>
Node.isResident()
public boolean isLockForChildInsertRemove()
Node
Configuration.isLockParentForChildInsertRemove()
This can also be configured on a per-node basis using Node.setLockForChildInsertRemove(boolean)
isLockForChildInsertRemove
in interface Node<K,V>
public void setLockForChildInsertRemove(boolean lockForChildInsertRemove)
Node
setLockForChildInsertRemove
in interface Node<K,V>
lockForChildInsertRemove
- if true, exclusive locks will be obtained when children are added/removed. If
false, a shared "read lock" will be obtained instead.public void releaseObjectReferences(boolean recursive)
Node
releaseObjectReferences
in interface Node<K,V>
recursive
- if true, child nodes will have their object references released as well.public boolean hasChildrenDirect()
hasChildrenDirect
in interface NodeSPI<K,V>
public Map getInternalState(boolean onlyInternalState)
NodeSPI
NodeSPI.getDataDirect()
, except that this method may also encode some internal data as attributes in the map,
using special _JBOSS_INTERNAL_XXX Strings as keys. Designed to be used by StateTransferGenerator
and CacheStoreInterceptor
which attempt to serialize nodes into a stream for storage or transfer.
getInternalState
in interface NodeSPI<K,V>
onlyInternalState
- if true, the map will only contain internal state and no other data.
public void setInternalState(Map state)
NodeSPI
NodeSPI.putAllDirect(java.util.Map)
except that this method first scans the map for any internal attributes
using special _JBOSS_INTERNAL_XXX Strings as keys, and uses these to set internal attributes before passing
the remaining attributes to NodeSPI.putAllDirect(java.util.Map)
. Designed to be used by StateTransferIntegrator
and CacheLoaderInterceptor
classes which attempt to create nodes based on a data stream.
setInternalState
in interface NodeSPI<K,V>
state
- state to be appliedpublic void setValid(boolean valid, boolean recursive)
NodeSPI
Node.isValid()
.
setValid
in interface NodeSPI<K,V>
valid
- if true, the node is marked as valid; if false, the node is invalid.recursive
- if true, the validity flag passed in is applied to all children as well.protected void assertValid()
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |