public class SharedItemStateManager extends Object implements ItemStateManager, ItemStateListener
ItemStateManager
(SISM). Caches objects returned from a
PersistenceManager
. Objects returned by this item state
manager are shared among all sessions.
A shared item state manager operates on a PersistenceManager
(PM) that is used to load and store the item states. Additionally, a SISM can
have VirtualItemStateProvider
s (VISP) that are used to provide
additional, non-persistent, read-only states. Examples of VISP are the
content representation of the NodeTypes (/jcr:system/jcr:nodeTypes) and the
version store (/jcr:system/jcr:versionStore). those 2 VISP are added to the
SISM during initialization of a workspace. i.e. they are 'mounted' to all
workspaces. we assume, that VISP cannot be added dynamically, neither during
runtime nor by configuration.
The states from the VISP are read-only. by the exception for node references.
remember that the referrers are stored in a NodeReferences
state,
having the ID of the target state.
there are 5 types of referential relations to be distinguished:
if VISP are not dynamic, there is not risk that NV-type references can dangle
(since a VISP cannot be 'unmounted', leaving eventual references dangling).
although multi-workspace-referrers are not explicitly supported, the
architecture of NodeReferences
support multiple referrers with
the same PropertyId. So the number of references can be tracked (an example
of multi-workspace-referrers is a version referenced by the jcr:baseVersion
of several (corresponding) nodes in multiple workspaces).
As mentioned, VN-type references should not impose any constraints on the referrers (e.g. a normal node referenced by a versioned reference property). In case of the version store, the VN-type references are not stored at all, but reinforced as NN-type references in the normal states in case of a checkout operation.
VV-type references should be handled by the respective VISP. they look as NN-type references in the scope if the VISP anyway...so no special treatment should be necessary.
VV'-type references are currently not possible, since the version store and virtual node type representation don't allow such references.
Constructor and Description |
---|
SharedItemStateManager(PersistenceManager persistMgr,
NodeId rootNodeId,
NodeTypeRegistry ntReg,
boolean usesReferences,
ItemStateCacheFactory cacheFactory,
ISMLocking locking,
NodeIdFactory nodeIdFactory)
Creates a new
SharedItemStateManager instance. |
Modifier and Type | Method and Description |
---|---|
void |
addListener(ItemStateListener listener)
Add an
ItemStateListener |
void |
addVirtualItemStateProvider(VirtualItemStateProvider prov)
Adds a new virtual item state provider.
|
org.apache.jackrabbit.core.state.SharedItemStateManager.Update |
beginUpdate(ChangeLog local,
EventStateCollectionFactory factory,
VirtualItemStateProvider virtualProvider)
Begin update operation.
|
void |
dispose()
Disposes this
SharedItemStateManager and frees resources. |
protected void |
doExternalUpdate(ChangeLog external)
Perform the external update.
|
void |
externalUpdate(ChangeLog external,
EventStateCollection events)
Handle an external update.
|
ItemState |
getItemState(ItemId id)
Return an item state, given its item id.
|
NodeIdFactory |
getNodeIdFactory() |
NodeReferences |
getNodeReferences(NodeId 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(NodeId id)
Return a flag indicating whether a node references object
for a given target id exists.
|
protected boolean |
hasNonVirtualItemState(ItemId id)
Checks if this item state manager has the given item state without
considering the virtual item state managers.
|
void |
removeListener(ItemStateListener listener)
Remove an
ItemStateListener |
void |
setCheckReferences(boolean checkReferences)
Enables or disables the referential integrity checking, this
should be used very carefully by experienced developers only.
|
void |
setEventChannel(UpdateEventChannel eventChannel)
Set an update event channel
|
void |
setISMLocking(ISMLocking ismLocking)
Sets a new locking strategy.
|
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. |
String |
toString() |
void |
update(ChangeLog local,
EventStateCollectionFactory factory)
Store modifications registered in a
ChangeLog . |
public SharedItemStateManager(PersistenceManager persistMgr, NodeId rootNodeId, NodeTypeRegistry ntReg, boolean usesReferences, ItemStateCacheFactory cacheFactory, ISMLocking locking, NodeIdFactory nodeIdFactory) throws ItemStateException
SharedItemStateManager
instance.persistMgr
- rootNodeId
- ntReg
- ItemStateException
public void setCheckReferences(boolean checkReferences)
checkReferences
- whether to do referential integrity checkspublic void setEventChannel(UpdateEventChannel eventChannel)
eventChannel
- update event channelpublic void setISMLocking(ISMLocking ismLocking)
ismLocking
- the locking strategy for this item state manager.public ItemState getItemState(ItemId id) throws NoSuchItemStateException, ItemStateException
getItemState
in interface ItemStateManager
id
- item idNoSuchItemStateException
- if the item does not existItemStateException
- if an error occurspublic boolean hasItemState(ItemId id)
hasItemState
in interface ItemStateManager
id
- item idtrue
if an item state exists,
otherwise false
public NodeReferences getNodeReferences(NodeId id) throws NoSuchItemStateException, ItemStateException
getNodeReferences
in interface ItemStateManager
id
- target idNoSuchItemStateException
- if the item does not existItemStateException
- if an error occurspublic boolean hasNodeReferences(NodeId id)
hasNodeReferences
in interface ItemStateManager
id
- target idtrue
if a node reference object exists for the given
id, otherwise false
.public void stateCreated(ItemState created)
ItemState
has successfully
been created (i.e. its underlying persistent state was created).
Notifications are received for items that this manager created itself or items that are managed by one of the virtual providers.
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).
Notifications are received for items that this manager created itself or items that are managed by one of the virtual providers.
stateModified
in interface ItemStateListener
modified
- the ItemState
that has been 'modified'public void stateDestroyed(ItemState destroyed)
ItemState
has successfully been
removed (i.e. its underlying persistent state has been destroyed).
Notifications are received for items that this manager created itself or items that are managed by one of the virtual providers.
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').
Notifications are received for items that this manager created itself or items that are managed by one of the virtual providers.
stateDiscarded
in interface ItemStateListener
discarded
- the ItemState
that has been discardedItemState.discard()
public void dispose()
SharedItemStateManager
and frees resources.public void addVirtualItemStateProvider(VirtualItemStateProvider prov)
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.
prov
- public org.apache.jackrabbit.core.state.SharedItemStateManager.Update beginUpdate(ChangeLog local, EventStateCollectionFactory factory, VirtualItemStateProvider virtualProvider) throws ReferentialIntegrityException, StaleItemStateException, ItemStateException
public void update(ChangeLog local, EventStateCollectionFactory factory) throws ReferentialIntegrityException, StaleItemStateException, ItemStateException
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.
local
- change log containing local itemsfactory
- event state collection factoryReferentialIntegrityException
- if a new or modified REFERENCE
property refers to a non-existent
target or if a removed node is still
being referencedStaleItemStateException
- if at least one of the affected item
states has become staleItemStateException
- if another error occurspublic void externalUpdate(ChangeLog external, EventStateCollection events)
external
- external change containing only node and property ids.events
- events to deliverprotected void doExternalUpdate(ChangeLog external)
writeLock
on this manager is held.external
- external change containing only node and property ids.public void addListener(ItemStateListener listener)
ItemStateListener
listener
- the new listener to be informed on modificationspublic void removeListener(ItemStateListener listener)
ItemStateListener
listener
- an existing listenerprotected boolean hasNonVirtualItemState(ItemId id)
public NodeIdFactory getNodeIdFactory()
Copyright © 2004–2021 The Apache Software Foundation. All rights reserved.