Interface EventContext
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
AbstractEventContext
,BlobEventContext
,DocumentDomainEventContext
,DocumentEventContext
,EventContextImpl
,InlineEventContext
,UnboundEventContext
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)
and newEvent(String, int)
methods. Events created by an event context are automatically mapped to that context.
- Author:
- Bogdan Stefanescu
-
Method Summary
Modifier and TypeMethodDescriptionObject[]
Gets event data.Gets the current core session if any.Gets the current principal.Gets the events properties.getProperty
(String key) Gets the named property from this context or null if not exists.Returns the repository name associated to the event context, if any.boolean
hasProperty
(String key) Tests whether or not the given property exists.Creates a new event in that context given the event name.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 Details
-
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
Replaces all properties with the given ones. The given map is set as is - no copy occurs.- Parameters:
properties
- the properties to use
-
setProperty
Sets a event context property- Parameters:
key
- the property keyvalue
- the property value
-
getProperty
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
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
Sets the core session. -
setPrincipal
Sets the principal. -
newEvent
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
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
Sets the repository name. Only used if no CoreSession is available.- Parameters:
repositoryName
- the repository name, ornull
-