Interface EventContext
-
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
AbstractEventContext
,BlobEventContext
,DocumentDomainEventContext
,DocumentEventContext
,EventContextImpl
,InlineEventContext
,UnboundEventContext
public interface EventContext extends Serializable
An event context is describing the context in which a core event was raised.You can subclass this class to implement more specialized event contexts like operations.
An event context is exposing information about the process the raised the event such as
- the current core session.
- the current principal.
- the event data exposed as a list of arguments.
- random properties that are associated with the event. These properties can be set by the event source or by any event listener that processes the event.
An event context also acts as an event factory. See
newEvent(String)
andnewEvent(String, int)
methods. Events created by an event context are automatically mapped to that context.- Author:
- Bogdan Stefanescu
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Object[]
getArguments()
Gets event data.CoreSession
getCoreSession()
Gets the current core session if any.NuxeoPrincipal
getPrincipal()
Gets the current principal.Map<String,Serializable>
getProperties()
Gets the events properties.Serializable
getProperty(String key)
Gets the named property from this context or null if not exists.String
getRepositoryName()
Returns the repository name associated to the event context, if any.boolean
hasProperty(String key)
Tests whether or not the given property exists.Event
newEvent(String name)
Creates a new event in that context given the event name.Event
newEvent(String name, int flags)
Creates a new event in that context given the event name.void
setCoreSession(CoreSession session)
Sets the core session.void
setPrincipal(NuxeoPrincipal principal)
Sets the principal.void
setProperties(Map<String,Serializable> properties)
Replaces all properties with the given ones.void
setProperty(String key, Serializable value)
Sets a event context propertyvoid
setRepositoryName(String repositoryName)
Sets the repository name.
-
-
-
Method Detail
-
getArguments
Object[] getArguments()
Gets event data. More objects can be associated with an event.For this reason an array of objects is returned. This array is usually representing the arguments of the operation that raised the event.
- Returns:
- the event data
-
getProperties
Map<String,Serializable> getProperties()
Gets the events properties.Event properties are used to attach random information to an event context and can be set by the event source or by any listener that is processing the event. These properties usually serves to share data between the source and the listeners.
- Returns:
- the event properties
-
setProperties
void setProperties(Map<String,Serializable> properties)
Replaces all properties with the given ones. The given map is set as is - no copy occurs.- Parameters:
properties
- the properties to use
-
setProperty
void setProperty(String key, Serializable value)
Sets a event context property- Parameters:
key
- the property keyvalue
- the property value
-
getProperty
Serializable getProperty(String key)
Gets the named property from this context or null if not exists.- Parameters:
key
- the property key- Returns:
- the property, or null if it does not exist
-
hasProperty
boolean hasProperty(String key)
Tests whether or not the given property exists.- Parameters:
key
- the property to test- Returns:
- true if the named property was set, false otherwise
-
getCoreSession
CoreSession getCoreSession()
Gets the current core session if any.- Returns:
- the core session, or null if none
-
getPrincipal
NuxeoPrincipal getPrincipal()
Gets the current principal.- Returns:
- the principal. Cannot be null.
-
setCoreSession
void setCoreSession(CoreSession session)
Sets the core session.
-
setPrincipal
void setPrincipal(NuxeoPrincipal principal)
Sets the principal.
-
newEvent
Event newEvent(String name)
Creates a new event in that context given the event name. The default flags for the event will be used.- Parameters:
name
- the event name- Returns:
- the event
- See Also:
newEvent(String, int)
-
newEvent
Event newEvent(String name, int flags)
Creates a new event in that context given the event name. The given flags will be applied on the event.- Parameters:
name
- the event nameflags
- the event flags to use- Returns:
- the event
-
getRepositoryName
String getRepositoryName()
Returns the repository name associated to the event context, if any.- Returns:
- the repository name
-
setRepositoryName
void setRepositoryName(String repositoryName)
Sets the repository name. Only used if no CoreSession is available.- Parameters:
repositoryName
- the repository name, ornull
-
-