org.apache.jackrabbit.core.state
Class SharedItemStateManager

java.lang.Object
  extended byorg.apache.jackrabbit.core.state.SharedItemStateManager
All Implemented Interfaces:
Dumpable, ItemStateListener, ItemStateManager

public class SharedItemStateManager
extends Object
implements ItemStateManager, ItemStateListener, Dumpable

Shared ItemStateManager. Caches objects returned from a PersistenceManager. Objects returned by this item state manager are shared among all sessions.


Constructor Summary
SharedItemStateManager(PersistenceManager persistMgr, String rootNodeUUID, NodeTypeRegistry ntReg)
          Creates a new SharedItemStateManager instance.
 
Method Summary
 void addVirtualItemStateProvider(VirtualItemStateProvider prov)
          Adds a new virtual item state provider.

NOTE: This method is not synchronized, because it is called right after creation only by the same thread and therefore concurrency issues do not occur.

 void dispose()
          Disposes this SharedItemStateManager and frees resources.
 void dump(PrintStream ps)
          Dumps the state of this instance in a human readable format for diagnostic purposes.
 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
 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.
 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).
 void store(ChangeLog local, ObservationManagerImpl obsMgr)
          Store modifications registered in a ChangeLog.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SharedItemStateManager

public SharedItemStateManager(PersistenceManager persistMgr,
                              String rootNodeUUID,
                              NodeTypeRegistry ntReg)
                       throws ItemStateException
Creates a new SharedItemStateManager instance.

Parameters:
persistMgr -
rootNodeUUID -
ntReg -
Method Detail

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

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

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:
NoSuchItemStateException - if the item does not exist
ItemStateException - if an error occurs

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 an item state exists, otherwise false

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()

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

dispose

public void dispose()
Disposes this SharedItemStateManager and frees resources.


addVirtualItemStateProvider

public void addVirtualItemStateProvider(VirtualItemStateProvider prov)
Adds a new virtual item state provider.

NOTE: This method is not synchronized, because it is called right after creation only by the same thread and therefore concurrency issues do not occur. Should this ever change, the synchronization status has to be re-examined.

Parameters:
prov -

store

public void store(ChangeLog local,
                  ObservationManagerImpl obsMgr)
           throws StaleItemStateException,
                  ItemStateException
Store modifications registered in a ChangeLog. The items contained in the ChangeLog are not states returned by this item state manager but rather must be reconnected to items provided by this state manager.

After successfully storing the states the observation manager is informed about the changes, if an observation manager is passed to this method.

NOTE: This method is not synchronized, because all methods it invokes on instance members (such as PersistenceManager.store(org.apache.jackrabbit.core.state.ChangeLog) are considered to be thread-safe. Should this ever change, the synchronization status has to be re-examined.

Parameters:
local - change log containing local items
obsMgr - the observation manager to inform, or null if no observation manager should be informed.
Throws:
StaleItemStateException - if at least one of the affected item states has become stale
ItemStateException - if another error occurs


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