Interface EventContext

  • All Superinterfaces:
    All Known Implementing Classes:
    AbstractEventContext, 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.
    To add more information you need to implement more specialized event contexts.

    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.

    Bogdan Stefanescu
    • 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.

        the event data
      • 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.

        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.
        properties - the properties to use
      • setProperty

        void setProperty​(String key,
                         Serializable value)
        Sets a event context property
        key - the property key
        value - the property value
      • getProperty

        Serializable getProperty​(String key)
        Gets the named property from this context or null if not exists.
        key - the property key
        the property, or null if it does not exist
      • hasProperty

        boolean hasProperty​(String key)
        Tests whether or not the given property exists.
        key - the property to test
        true if the named property was set, false otherwise
      • getCoreSession

        CoreSession getCoreSession()
        Gets the current core session if any.
        the core session, or null if none
      • 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.
        name - the event name
        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.
        name - the event name
        flags - the event flags to use
        the event
      • getRepositoryName

        String getRepositoryName()
        Returns the repository name associated to the event context, if any.
        the repository name
      • setRepositoryName

        void setRepositoryName​(String repositoryName)
        Sets the repository name. Only used if no CoreSession is available.
        repositoryName - the repository name, or null