Interface EventContext

  • All Superinterfaces:
    Serializable
    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.

    Author:
    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.

        Returns:
        the event data
      • getProperties

        Map<String,​SerializablegetProperties()
        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 key
        value - 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
      • 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 name
        flags - 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, or null