org.apache.jackrabbit.core
Class ItemManager

java.lang.Object
  extended by org.apache.jackrabbit.core.ItemManager
All Implemented Interfaces:
ItemLifeCycleListener, ItemStateListener, Dumpable

public class ItemManager
extends Object
implements ItemLifeCycleListener, Dumpable, ItemStateListener

There's one ItemManager instance per Session instance. It is the factory for Node and Property instances.

The ItemManager's responsabilities are:

If the parent Session is an XASession, there is one ItemManager instance per started global transaction.


Field Summary
protected  SessionImpl session
           
 
Constructor Summary
protected ItemManager(SessionItemStateManager itemStateProvider, HierarchyManager hierMgr, SessionImpl session, NodeDefinition rootNodeDef, NodeId rootNodeId)
          Creates a new per-session instance ItemManager instance.
 
Method Summary
protected  VersionHistoryImpl createVersionHistoryInstance(NodeId id, NodeState state, NodeDefinition def, ItemLifeCycleListener[] listeners)
          Create a version history instance.
protected  VersionImpl createVersionInstance(NodeId id, NodeState state, NodeDefinition def, ItemLifeCycleListener[] listeners)
          Create a version instance.
 void dump(PrintStream ps)
          Dumps the state of this instance in a human readable format for diagnostic purposes.
 ItemImpl getItem(ItemId id)
           
 ItemImpl getItem(ItemState state)
          Returns the item instance for the given item state.
 ItemImpl getItem(Path path)
          Deprecated. As of JSR 283, a Path doesn't anymore uniquely identify an Item, therefore getNode(Path) and getProperty(Path) should be used instead.
 NodeImpl getNode(Path path)
           
 PropertyImpl getProperty(Path path)
           
 void itemCreated(ItemImpl item)
          Called when an ItemImpl instance has been created.
 void itemDestroyed(ItemId id, ItemImpl item)
          Called when an ItemImpl instance has been destroyed (i.e.
 boolean itemExists(ItemId id)
          Checks if the item with the given id exists.
 boolean itemExists(Path path)
          Deprecated. As of JSR 283, a Path doesn't anymore uniquely identify an Item, therefore nodeExists(Path) and propertyExists(Path) should be used instead.
 void itemInvalidated(ItemId id, ItemImpl item)
          Called when an ItemImpl instance has been invalidated (i.e.
 boolean nodeExists(Path path)
          Checks whether a node exists at the specified path.
 boolean propertyExists(Path path)
          Checks whether a property exists at the specified path.
 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

session

protected final SessionImpl session
Constructor Detail

ItemManager

protected ItemManager(SessionItemStateManager itemStateProvider,
                      HierarchyManager hierMgr,
                      SessionImpl session,
                      NodeDefinition rootNodeDef,
                      NodeId rootNodeId)
Creates a new per-session instance ItemManager instance.

Parameters:
itemStateProvider - the item state provider associated with the new instance
hierMgr - the hierarchy manager
session - the session associated with the new instance
rootNodeDef - the definition of the root node
rootNodeId - the id of the root node
Method Detail

itemExists

public boolean itemExists(Path path)
Deprecated. As of JSR 283, a Path doesn't anymore uniquely identify an Item, therefore nodeExists(Path) and propertyExists(Path) should be used instead.

Checks whether an item exists at the specified path.

Parameters:
path - path to the item to be checked
Returns:
true if the specified item exists

nodeExists

public boolean nodeExists(Path path)
Checks whether a node exists at the specified path.

Parameters:
path - path to the node to be checked
Returns:
true if a node exists at the specified path

propertyExists

public boolean propertyExists(Path path)
Checks whether a property exists at the specified path.

Parameters:
path - path to the property to be checked
Returns:
true if a property exists at the specified path

itemExists

public boolean itemExists(ItemId id)
Checks if the item with the given id exists.

Parameters:
id - id of the item to be checked
Returns:
true if the specified item exists

getItem

public ItemImpl getItem(Path path)
                 throws PathNotFoundException,
                        AccessDeniedException,
                        RepositoryException
Deprecated. As of JSR 283, a Path doesn't anymore uniquely identify an Item, therefore getNode(Path) and getProperty(Path) should be used instead.

Returns the node at the specified absolute path in the workspace. If no such node exists, then it returns the property at the specified path. If no such property exists a PathNotFoundException is thrown.

Parameters:
path -
Returns:
Throws:
PathNotFoundException
AccessDeniedException
RepositoryException

getNode

public NodeImpl getNode(Path path)
                 throws PathNotFoundException,
                        AccessDeniedException,
                        RepositoryException
Parameters:
path -
Returns:
Throws:
PathNotFoundException
AccessDeniedException
RepositoryException

getProperty

public PropertyImpl getProperty(Path path)
                         throws PathNotFoundException,
                                AccessDeniedException,
                                RepositoryException
Parameters:
path -
Returns:
Throws:
PathNotFoundException
AccessDeniedException
RepositoryException

getItem

public ItemImpl getItem(ItemId id)
                 throws ItemNotFoundException,
                        AccessDeniedException,
                        RepositoryException
Parameters:
id -
Returns:
Throws:
RepositoryException
ItemNotFoundException
AccessDeniedException

getItem

public ItemImpl getItem(ItemState state)
                 throws ItemNotFoundException,
                        AccessDeniedException,
                        RepositoryException
Returns the item instance for the given item state.

Parameters:
state - the item state
Returns:
the item instance for the given item state.
Throws:
RepositoryException
ItemNotFoundException
AccessDeniedException

createVersionInstance

protected VersionImpl createVersionInstance(NodeId id,
                                            NodeState state,
                                            NodeDefinition def,
                                            ItemLifeCycleListener[] listeners)
                                     throws RepositoryException
Create a version instance.

Parameters:
id - node id
state - node state
def - node definition
listeners - listeners
Returns:
version instance
Throws:
RepositoryException - if an error occurs

createVersionHistoryInstance

protected VersionHistoryImpl createVersionHistoryInstance(NodeId id,
                                                          NodeState state,
                                                          NodeDefinition def,
                                                          ItemLifeCycleListener[] listeners)
                                                   throws RepositoryException
Create a version history instance.

Parameters:
id - node id
state - node state
def - node definition
listeners - listeners
Returns:
version instance
Throws:
RepositoryException - if an error occurs

itemCreated

public void itemCreated(ItemImpl item)
Called when an ItemImpl instance has been created.

Specified by:
itemCreated in interface ItemLifeCycleListener
Parameters:
item - the instance which has been created

itemInvalidated

public void itemInvalidated(ItemId id,
                            ItemImpl item)
Called when an ItemImpl instance has been invalidated (i.e. it has been temporarily rendered 'invalid').

Note that most Item, Node and Property methods will throw an InvalidItemStateException when called on an 'invalidated' item.

Specified by:
itemInvalidated in interface ItemLifeCycleListener
Parameters:
id - the id of the instance that has been discarded
item - the instance which has been discarded

itemDestroyed

public void itemDestroyed(ItemId id,
                          ItemImpl item)
Called when an ItemImpl instance has been destroyed (i.e. it has been permanently rendered 'invalid').

Note that most Item, Node and Property methods will throw an InvalidItemStateException when called on a 'destroyed' item.

Specified by:
itemDestroyed in interface ItemLifeCycleListener
Parameters:
id - the id of the instance that has been destroyed
item - the instance which has been destroyed

dump

public void dump(PrintStream ps)
Dumps the state of this instance in a human readable format for diagnostic purposes.

Specified by:
dump in interface Dumpable
Parameters:
ps - stream to dump state to

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-2008 The Apache Software Foundation. All Rights Reserved.