org.apache.jackrabbit.core.virtual
Class AbstractVISProvider

java.lang.Object
  extended byorg.apache.jackrabbit.core.virtual.AbstractVISProvider
All Implemented Interfaces:
ItemStateListener, ItemStateManager, VirtualItemStateProvider
Direct Known Subclasses:
VirtualNodeTypeStateProvider

public abstract class AbstractVISProvider
extends Object
implements VirtualItemStateProvider, ItemStateListener

This Class implements a virtual item state provider, in order to expose the versions to the version storage.


Field Summary
protected  NodeTypeRegistry ntReg
          the node type registry
protected  NodeId rootNodeId
          the root node id
 
Constructor Summary
AbstractVISProvider(NodeTypeRegistry ntReg, NodeId rootNodeId)
          Creates an abstract virtual item state provider
 
Method Summary
protected  NodeState cache(NodeState state)
          adds the node state to the cache
 VirtualNodeState createNodeState(VirtualNodeState parent, QName name, NodeId id, QName nodeTypeName)
          Creates a new virtual node state
 VirtualPropertyState createPropertyState(VirtualNodeState parent, QName name, int type, boolean multiValued)
          Creats a new virtual property state
protected abstract  VirtualNodeState createRootNodeState()
          Creates the root node state.
protected  void evict(NodeId id)
          removes the node state from the cache
protected  NodeDef getApplicableChildNodeDef(NodeState parent, QName nodeName, QName nodeTypeName)
          Retrieves the node definition for the given contraints.
protected  PropDef getApplicablePropertyDef(NodeState parent, QName propertyName, int type, boolean multiValued)
          retrieves the property definition for the given contraints
protected  EffectiveNodeType getEffectiveNodeType(NodeState parent)
          Returns the effective (i.e.
 ItemState getItemState(ItemId id)
          Return an item state, given its item id.
 NodeReferences getNodeReferences(NodeReferencesId id)
          Return a node references object, given its target id
protected  NodeTypeRegistry getNodeTypeRegistry()
          returns the node type manager
 NodeState getRootState()
          Returns the root state
 NodeId getVirtualRootId()
          Returns the id of the root node of the virtual tree.
 boolean hasItemState(ItemId id)
          Return a flag indicating whether an item state for a given item id exists.
 boolean hasNodeReferences(NodeReferencesId id)
          Return a flag indicating whether a node references object for a given target id exists.
protected abstract  VirtualNodeState internalGetNodeState(NodeId id)
          Retrieves the node state with the given node id
protected  VirtualPropertyState internalGetPropertyState(PropertyId id)
          Retrieces the property state for the given id
protected abstract  boolean internalHasNodeState(NodeId id)
          Checks if this provide has the node state of the given node id
protected  boolean internalHasPropertyState(PropertyId id)
          Checks if this provider has the property state of the given id.
 void invalidateItem(ItemId id, boolean recursive)
          invalidates the item
 boolean isVirtualRoot(ItemId id)
          Checks if the id refers to the root of a virtual tree.
 void stateCreated(ItemState created)
          Called when an ItemState has successfully been created (i.e. its underlying persistent state was created).
 void stateDestroyed(ItemState destroyed)
          Called when an ItemState has successfully been removed (i.e. its underlying persistent state has been destroyed).
 void stateDiscarded(ItemState discarded)
          Called when an ItemState has been discarded (i.e. it has been rendered 'invalid').
 void stateModified(ItemState modified)
          Called when an ItemState has successfully been modified (i.e. its underlying persistent state has changed).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.jackrabbit.core.virtual.VirtualItemStateProvider
setNodeReferences
 

Field Detail

rootNodeId

protected final NodeId rootNodeId
the root node id


ntReg

protected final NodeTypeRegistry ntReg
the node type registry

Constructor Detail

AbstractVISProvider

public AbstractVISProvider(NodeTypeRegistry ntReg,
                           NodeId rootNodeId)
Creates an abstract virtual item state provider

Parameters:
ntReg -
rootNodeId -
Method Detail

createRootNodeState

protected abstract VirtualNodeState createRootNodeState()
                                                 throws RepositoryException
Creates the root node state.

Returns:
Throws:
RepositoryException

hasItemState

public boolean hasItemState(ItemId id)
Return a flag indicating whether an item state for a given item id exists.

Specified by:
hasItemState in interface ItemStateManager
Parameters:
id - item id
Returns:
true if an item state exists, otherwise false

getItemState

public ItemState getItemState(ItemId id)
                       throws NoSuchItemStateException,
                              ItemStateException
Return an item state, given its item id.

Specified by:
getItemState in interface ItemStateManager
Parameters:
id - item id
Returns:
item state
Throws:
NoSuchItemStateException - if the item does not exist
ItemStateException - if an error occurs

getNodeReferences

public NodeReferences getNodeReferences(NodeReferencesId id)
                                 throws NoSuchItemStateException,
                                        ItemStateException
Return a node references object, given its target id

Specified by:
getNodeReferences in interface ItemStateManager
Parameters:
id - target id
Returns:
node references object
Throws:
ItemStateException - if an error occurs
NoSuchItemStateException - if the item does not exist

hasNodeReferences

public boolean hasNodeReferences(NodeReferencesId id)
Return a flag indicating whether a node references object for a given target id exists.

Specified by:
hasNodeReferences in interface ItemStateManager
Parameters:
id - target id
Returns:
true if a node reference object exists for the given id, otherwise false.

isVirtualRoot

public boolean isVirtualRoot(ItemId id)
Checks if the id refers to the root of a virtual tree.

Specified by:
isVirtualRoot in interface VirtualItemStateProvider
Parameters:
id -
Returns:
true if it is the root

getVirtualRootId

public NodeId getVirtualRootId()
Returns the id of the root node of the virtual tree.

Specified by:
getVirtualRootId in interface VirtualItemStateProvider
Returns:
the id of the root node of the virtual tree.

getRootState

public NodeState getRootState()
                       throws ItemStateException
Returns the root state

Returns:
the root state
Throws:
ItemStateException

internalHasNodeState

protected abstract boolean internalHasNodeState(NodeId id)
Checks if this provide has the node state of the given node id

Parameters:
id -
Returns:
true if it has the node state

internalGetNodeState

protected abstract VirtualNodeState internalGetNodeState(NodeId id)
                                                  throws NoSuchItemStateException,
                                                         ItemStateException
Retrieves the node state with the given node id

Parameters:
id -
Returns:
Throws:
NoSuchItemStateException
ItemStateException

internalHasPropertyState

protected boolean internalHasPropertyState(PropertyId id)
Checks if this provider has the property state of the given id.

Parameters:
id -
Returns:
true if it has the property state

internalGetPropertyState

protected VirtualPropertyState internalGetPropertyState(PropertyId id)
                                                 throws NoSuchItemStateException,
                                                        ItemStateException
Retrieces the property state for the given id

Parameters:
id -
Returns:
Throws:
NoSuchItemStateException
ItemStateException

createPropertyState

public VirtualPropertyState createPropertyState(VirtualNodeState parent,
                                                QName name,
                                                int type,
                                                boolean multiValued)
                                         throws RepositoryException
Creats a new virtual property state

Specified by:
createPropertyState in interface VirtualItemStateProvider
Parameters:
parent -
name -
type -
multiValued -
Returns:
Throws:
RepositoryException

createNodeState

public VirtualNodeState createNodeState(VirtualNodeState parent,
                                        QName name,
                                        NodeId id,
                                        QName nodeTypeName)
                                 throws RepositoryException
Creates a new virtual node state

Specified by:
createNodeState in interface VirtualItemStateProvider
Parameters:
parent -
name -
id -
nodeTypeName -
Returns:
Throws:
RepositoryException

getNodeTypeRegistry

protected NodeTypeRegistry getNodeTypeRegistry()
returns the node type manager

Returns:
the node type manager

cache

protected NodeState cache(NodeState state)
adds the node state to the cache

Parameters:
state -

evict

protected void evict(NodeId id)
removes the node state from the cache

Parameters:
id -

invalidateItem

public void invalidateItem(ItemId id,
                           boolean recursive)
invalidates the item

Parameters:
id -

getApplicablePropertyDef

protected PropDef getApplicablePropertyDef(NodeState parent,
                                           QName propertyName,
                                           int type,
                                           boolean multiValued)
                                    throws RepositoryException
retrieves the property definition for the given contraints

Parameters:
propertyName -
type -
multiValued -
Returns:
Throws:
RepositoryException

getApplicableChildNodeDef

protected NodeDef getApplicableChildNodeDef(NodeState parent,
                                            QName nodeName,
                                            QName nodeTypeName)
                                     throws RepositoryException
Retrieves the node definition for the given contraints.

Parameters:
nodeName -
nodeTypeName -
Returns:
Throws:
RepositoryException

getEffectiveNodeType

protected EffectiveNodeType getEffectiveNodeType(NodeState parent)
                                          throws RepositoryException
Returns the effective (i.e. merged and resolved) node type representation of this node's primary and mixin node types.

Returns:
the effective node type
Throws:
RepositoryException

stateCreated

public void stateCreated(ItemState created)
Called when an ItemState has successfully been created (i.e. its underlying persistent state was created).

Specified by:
stateCreated in interface ItemStateListener
Parameters:
created - the ItemState that has been 'created'

stateModified

public void stateModified(ItemState modified)
Called when an ItemState has successfully been modified (i.e. its underlying persistent state has changed).

Specified by:
stateModified in interface ItemStateListener
Parameters:
modified - the ItemState that has been 'modified'

stateDestroyed

public void stateDestroyed(ItemState destroyed)
Called when an ItemState has successfully been removed (i.e. its underlying persistent state has been destroyed).

Specified by:
stateDestroyed in interface ItemStateListener
Parameters:
destroyed - the ItemState that has been 'destroyed'

stateDiscarded

public void stateDiscarded(ItemState discarded)
Called when an ItemState has been discarded (i.e. it has been rendered 'invalid').

Specified by:
stateDiscarded in interface ItemStateListener
Parameters:
discarded - the ItemState that has been discarded
See Also:
ItemState.discard()


Copyright © 2004-2006 The Apache Software Foundation. All Rights Reserved.