Class EventStateCollection
- java.lang.Object
-
- org.apache.jackrabbit.core.observation.EventStateCollection
-
public final class EventStateCollection extends Object
TheEventStateCollection
class implements howEventState
objects are created based on theItemState
s passed to thecreateEventStates(org.apache.jackrabbit.core.id.NodeId, org.apache.jackrabbit.core.state.ChangeLog, org.apache.jackrabbit.core.state.ItemStateManager)
method.The basic sequence of method calls is:
createEventStates(org.apache.jackrabbit.core.id.NodeId, org.apache.jackrabbit.core.state.ChangeLog, org.apache.jackrabbit.core.state.ItemStateManager)
oraddAll(java.util.Collection<org.apache.jackrabbit.core.observation.EventState>)
to create or add event states to the collectionprepare()
orprepareDeleted(org.apache.jackrabbit.core.state.ChangeLog)
to prepare the events. If this step is omitted, EventListeners might see events of deleted item they are not allowed to see.dispatch()
to dispatch the events to the EventListeners.
-
-
Constructor Summary
Constructors Constructor Description EventStateCollection(org.apache.jackrabbit.core.observation.EventDispatcher dispatcher, SessionImpl session, Path pathPrefix)
Creates a new emptyEventStateCollection
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAll(Collection<EventState> c)
Adds all event states in the given collection to this collectionvoid
createEventStates(NodeId rootNodeId, ChangeLog changes, ItemStateManager stateMgr)
void
dispatch()
Dispatches the events to theEventListener
s.String
getCommonPath()
Get the longest common path of all event state paths.List<EventState>
getEvents()
Return the list of events.Path
getPathPrefix()
Returns the path prefix for this event state collection ornull
if no path prefix was set in the constructor of this collection.SessionImpl
getSession()
Return the session who is the origin of this events.long
getTimestamp()
String
getUserData()
void
prepare()
Prepares already added events for dispatching.void
prepareDeleted(ChangeLog changes)
Prepares deleted items fromchanges
.void
setTimestamp(long timestamp)
Sets a new timestamp for this collection.void
setUserData(String userData)
Sets the user data for this event state collection.int
size()
Get the number of events.
-
-
-
Constructor Detail
-
EventStateCollection
public EventStateCollection(org.apache.jackrabbit.core.observation.EventDispatcher dispatcher, SessionImpl session, Path pathPrefix)
Creates a new emptyEventStateCollection
.Because the item state manager in
createEventStates(org.apache.jackrabbit.core.id.NodeId, org.apache.jackrabbit.core.state.ChangeLog, org.apache.jackrabbit.core.state.ItemStateManager)
may represent only a subset of the over all item state hierarchy, this constructor also takes a path prefix argument. If nonnull
all events created by this collection are prefixed with this path.- Parameters:
dispatcher
- event dispatchersession
- the session that created these events.pathPrefix
- the path to prefix the event paths ornull
if no prefix should be used.
-
-
Method Detail
-
createEventStates
public void createEventStates(NodeId rootNodeId, ChangeLog changes, ItemStateManager stateMgr) throws ItemStateException
- Parameters:
rootNodeId
- the id of the root node.changes
- the changes onItemState
s.stateMgr
- anItemStateManager
to provideItemState
of items that are not contained in thechanges
collection.- Throws:
ItemStateException
- if an error occurs while creating events states for the item state changes.
-
addAll
public void addAll(Collection<EventState> c)
Adds all event states in the given collection to this collection- Parameters:
c
-
-
prepare
public void prepare()
Prepares already added events for dispatching.
-
prepareDeleted
public void prepareDeleted(ChangeLog changes)
Prepares deleted items fromchanges
.- Parameters:
changes
- the changes to prepare.
-
dispatch
public void dispatch()
Dispatches the events to theEventListener
s.
-
getPathPrefix
public Path getPathPrefix()
Returns the path prefix for this event state collection ornull
if no path prefix was set in the constructor of this collection. See alsoEventStateCollection(org.apache.jackrabbit.core.observation.EventDispatcher, org.apache.jackrabbit.core.SessionImpl, org.apache.jackrabbit.spi.Path)
.- Returns:
- the path prefix for this event state collection.
-
getTimestamp
public long getTimestamp()
- Returns:
- the timestamp when this collection was created.
-
setTimestamp
public void setTimestamp(long timestamp)
Sets a new timestamp for this collection.- Parameters:
timestamp
- the new timestamp value.
-
getEvents
public List<EventState> getEvents()
Return the list of events.- Returns:
- list of events
-
size
public int size()
Get the number of events.- Returns:
- the size
-
getSession
public SessionImpl getSession()
Return the session who is the origin of this events.- Returns:
- event source
-
getUserData
public String getUserData()
- Returns:
- the user data attached to this event state collection.
-
setUserData
public void setUserData(String userData)
Sets the user data for this event state collection.- Parameters:
userData
- the user data.
-
getCommonPath
public String getCommonPath()
Get the longest common path of all event state paths.- Returns:
- the longest common path
-
-