|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.jackrabbit.core.HierarchyManagerImpl org.apache.jackrabbit.core.CachingHierarchyManager
public class CachingHierarchyManager
Implementation of a HierarchyManager
that caches paths of
items.
Field Summary | |
---|---|
static int |
DEFAULT_UPPER_LIMIT
Default upper limit of cached states |
Fields inherited from class org.apache.jackrabbit.core.HierarchyManagerImpl |
---|
provider, resolver, rootNodeId |
Constructor Summary | |
---|---|
CachingHierarchyManager(NodeId rootNodeId,
ItemStateManager provider,
PathResolver resolver)
Create a new instance of this class. |
Method Summary | |
---|---|
protected void |
beforeResolvePath(Path path,
ItemState state,
int next)
Called by recursively invoked method HierarchyManagerImpl.resolvePath(Path, ItemState, int, boolean) ;
May be overridden by some subclass to process/cache intermediate state.
Cache the intermediate item inside our cache. |
protected void |
buildPath(PathBuilder builder,
ItemState state)
Adds the path element of an item id to the path currently being built. Overridden method tries to find a mapping for the intermediate item state and add its path elements to the builder currently
being used. |
void |
dump(PrintStream ps)
Dump contents of path map and elements included to PrintStream given. |
int |
getDepth(ItemId id)
Returns the depth of the specified item which is equivalent to getPath(id).getAncestorCount() . The depth reflects the
absolute hierarchy level. |
Name |
getName(ItemId id)
Returns the name of the specified item. |
Path |
getPath(ItemId id)
Returns the path to the given item. Overridden method simply checks whether we have an item matching the id and returns its path, otherwise calls base implementation. |
boolean |
isAncestor(NodeId nodeId,
ItemId itemId)
Determines whether the node with the specified nodeId
is an ancestor of the item denoted by the given itemId .
This is equivalent to
getPath(nodeId).isAncestorOf(getPath(itemId)) . |
void |
nodeAdded(NodeState state,
Name name,
int index,
NodeId id)
Called when a child node has been added |
void |
nodeModified(NodeState modified)
Called when a node has been modified, typically as a result of removal or addition of a child node. Evict moved or renamed items from the cache. |
void |
nodeRemoved(NodeState state,
Name name,
int index,
NodeId id)
Called when a child node has been removed |
void |
nodesReplaced(NodeState state)
Called when the children nodes were replaced by other nodes, typically as result of a reorder operation. Iterate over all cached children of this state and verify each child's position. |
NodeId |
resolveNodePath(Path path)
Resolves a path into a node id. Note that, for performance reasons, this method returns null
rather than throwing a PathNotFoundException if there's no
node to be found at path .
Check the path indicated inside our cache first. |
ItemId |
resolvePath(Path path)
Resolves a path into an item id. If there is both a node and a property at the specified path, this method will return the id of the node. Note that, for performance reasons, this method returns null
rather than throwing a PathNotFoundException if there's no
item to be found at path .
Check the path indicated inside our cache first. |
PropertyId |
resolvePropertyPath(Path path)
Resolves a path into a property id. Note that, for performance reasons, this method returns null
rather than throwing a PathNotFoundException if there's no
property to be found at path .
Check the path indicated inside our cache first. |
void |
stateCreated(ItemState created)
Called when an ItemState has successfully
been created (i.e. |
void |
stateDestroyed(ItemState destroyed)
Called when an ItemState has successfully been
removed (i.e. |
void |
stateDiscarded(ItemState discarded)
Called when an ItemState has been discarded (i.e. |
void |
stateModified(ItemState modified)
Called when an ItemState has successfully
been modified (i.e. |
Methods inherited from class org.apache.jackrabbit.core.HierarchyManagerImpl |
---|
getChildNodeEntry, getChildNodeEntry, getItemState, getParentId, getRelativeDepth, getRootNodeId, hasItemState, resolvePath, safeGetJCRPath, safeGetJCRPath |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_UPPER_LIMIT
Constructor Detail |
---|
public CachingHierarchyManager(NodeId rootNodeId, ItemStateManager provider, PathResolver resolver)
rootNodeId
- root node idprovider
- item state managerresolver
- namespace resolverMethod Detail |
---|
protected void beforeResolvePath(Path path, ItemState state, int next)
HierarchyManagerImpl.resolvePath(Path, ItemState, int, boolean)
;
May be overridden by some subclass to process/cache intermediate state.
Cache the intermediate item inside our cache.
beforeResolvePath
in class HierarchyManagerImpl
path
- full path of item to resolvestate
- intermediate statenext
- next path element index to resolveprotected void buildPath(PathBuilder builder, ItemState state) throws ItemStateException, RepositoryException
builder
contains the path of state
.
Overridden method tries to find a mapping for the intermediate item
state
and add its path elements to the builder currently
being used. If no mapping is found, the item is cached instead after
the base implementation has been invoked.
buildPath
in class HierarchyManagerImpl
builder
- builder currently being usedstate
- item to find path of
ItemStateException
RepositoryException
public ItemId resolvePath(Path path) throws RepositoryException
null
rather than throwing a PathNotFoundException
if there's no
item to be found at path
.
Check the path indicated inside our cache first.
resolvePath
in interface HierarchyManager
resolvePath
in class HierarchyManagerImpl
path
- path to resolve
path
or null
if there's no item at path
.
RepositoryException
- if an error occurspublic NodeId resolveNodePath(Path path) throws RepositoryException
null
rather than throwing a PathNotFoundException
if there's no
node to be found at path
.
Check the path indicated inside our cache first.
resolveNodePath
in interface HierarchyManager
resolveNodePath
in class HierarchyManagerImpl
path
- path to resolve
path
or null
if there's no node at path
.
RepositoryException
- if an error occurspublic PropertyId resolvePropertyPath(Path path) throws RepositoryException
null
rather than throwing a PathNotFoundException
if there's no
property to be found at path
.
Check the path indicated inside our cache first.
resolvePropertyPath
in interface HierarchyManager
resolvePropertyPath
in class HierarchyManagerImpl
path
- path to resolve
path
or null
if there's no property at path
.
RepositoryException
- if an error occurspublic Path getPath(ItemId id) throws ItemNotFoundException, RepositoryException
getPath
in interface HierarchyManager
getPath
in class HierarchyManagerImpl
ItemNotFoundException
RepositoryException
public Name getName(ItemId id) throws ItemNotFoundException, RepositoryException
getName
in interface HierarchyManager
getName
in class HierarchyManagerImpl
id
- id of item whose name should be returned
ItemNotFoundException
RepositoryException
public int getDepth(ItemId id) throws ItemNotFoundException, RepositoryException
getPath(id).getAncestorCount()
. The depth reflects the
absolute hierarchy level.
getDepth
in interface HierarchyManager
getDepth
in class HierarchyManagerImpl
id
- item id
ItemNotFoundException
- if the specified id
does not
denote an existing item.
RepositoryException
- if another error occurspublic boolean isAncestor(NodeId nodeId, ItemId itemId) throws ItemNotFoundException, RepositoryException
nodeId
is an ancestor of the item denoted by the given itemId
.
This is equivalent to
getPath(nodeId).isAncestorOf(getPath(itemId))
.
isAncestor
in interface HierarchyManager
isAncestor
in class HierarchyManagerImpl
nodeId
- node iditemId
- item id
true
if the node with the specified
nodeId
is an ancestor of the item denoted by the
given itemId
false otherwise
ItemNotFoundException
- if any of the specified id's does not
denote an existing item.
RepositoryException
- if another error occurspublic void stateCreated(ItemState created)
ItemState
has successfully
been created (i.e. its underlying persistent state was created).
stateCreated
in interface ItemStateListener
created
- the ItemState
that has been 'created'public void stateModified(ItemState modified)
ItemState
has successfully
been modified (i.e. its underlying persistent state has changed).
stateModified
in interface ItemStateListener
modified
- the ItemState
that has been 'modified'public void nodeModified(NodeState modified)
ItemStateListener.stateModified(ItemState)
was called.
Evict moved or renamed items from the cache.
nodeModified
in interface NodeStateListener
modified
- node state that changedpublic void stateDestroyed(ItemState destroyed)
ItemState
has successfully been
removed (i.e. its underlying persistent state has been destroyed).
stateDestroyed
in interface ItemStateListener
destroyed
- the ItemState
that has been 'destroyed'public void stateDiscarded(ItemState discarded)
ItemState
has been discarded (i.e. it has
been rendered 'invalid').
stateDiscarded
in interface ItemStateListener
discarded
- the ItemState
that has been discardedItemState.discard()
public void nodeAdded(NodeState state, Name name, int index, NodeId id)
nodeAdded
in interface NodeStateListener
state
- node state that changedname
- name of node that was addedindex
- index of new nodeid
- id of new nodepublic void nodesReplaced(NodeState state)
nodesReplaced
in interface NodeStateListener
state
- node state that changedpublic void nodeRemoved(NodeState state, Name name, int index, NodeId id)
nodeRemoved
in interface NodeStateListener
state
- node state that changedname
- name of node that was removedindex
- index of removed nodeid
- id of removed nodepublic void dump(PrintStream ps)
PrintStream
given.
dump
in interface Dumpable
ps
- print stream to dump to
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |