Interface Event

  • All Superinterfaces:
    Serializable
    All Known Implementing Classes:
    EventImpl, ShallowEvent

    public interface Event
    extends Serializable
    A lightweight object used by core components to notify interested components about events in core.

    These events should be used by all core components not only by the repository.

    There are 2 post commit control flags:

    • INLINE - if true the event will not be recorded as part of the post commit event bundle. Defaults to false.
    • COMMIT - the event will simulate a commit so that the post commit event bundle will be fired. TYhe COMMIT flag is ignored while in a transaction.
    More flags may be added in the future.
    Author:
    Bogdan Stefanescu
    • Method Detail

      • getName

        String getName()
        Gets the event name.

        The name must be unique. It is recommended to use prefixes in the style of java package names to differentiate between similar events that are sent by different components.

      • getContext

        EventContext getContext()
        Gets the event context.

        Event contexts give access to the context in which the the event was raised. Event contexts are usually identifying the operation that raised the event. The context is exposing data objects linked to the event like documents and also may give access to the operation that raised the event allowing thus to canceling the operation, to record time spent to set the result status etc.

        Returns:
        the event context
      • getFlags

        int getFlags()
        Gets the set of event flags
        Returns:
        the event flags
      • cancel

        void cancel()
        Cancels this event.

        This can be used by event listeners to exit the event notification. Remaining event listeners will no more be notified. Note that this is not canceling the underlying operation if any.

      • isCanceled

        boolean isCanceled()
        Checks whether the event was canceled.
        Returns:
        true if canceled, false otherwise.
      • markBubbleException

        void markBubbleException()
        Marks the event to bubble the Exception thrown by a listener.

        This will exit the event listeners loop. The transaction won't be rollbacked, but the Exception will be thrown by the EventService.

        Since:
        5.7
      • isBubbleException

        boolean isBubbleException()
        Returns true if the event was marked to bubble the Exception, false otherwise.
        Since:
        5.7
      • markRollBack

        void markRollBack()
        Marks transaction for RollBack

        This will exit the event listeners loop and throw a RuntimeException In JTA container, this will make the global transaction rollback.

      • markRollBack

        void markRollBack​(String message,
                          Exception exception)
        Marks transaction for RollBack

        This will exit the event listeners loop and throw a RuntimeException In JTA container, this will make the global transaction rollback.

        Parameters:
        message - message that explains the reason of the Rollback
        exception - associated Exception that explains the Rollback if any
        Since:
        5.6
      • isMarkedForRollBack

        boolean isMarkedForRollBack()
        Checks whether the event was marked for RollBack
        Returns:
        true if rolled back, false otherwise.
      • getRollbackException

        Exception getRollbackException()
        Returns the Exception associated the RollBack if any
        Returns:
        the Exception associated the RollBack if any
        Since:
        5.6
      • getRollbackMessage

        String getRollbackMessage()
        Returns the message associated to the RollBack if any
        Returns:
        the message associated to the RollBack if any
        Since:
        5.6
      • isInline

        boolean isInline()
        Whether this event must not be added to a bundle. An event is not inline by default.
        Returns:
        true if the event must be omitted from event bundles, false otherwise.
      • setInline

        void setInline​(boolean isInline)
        Set the inline flag.
        Parameters:
        isInline - true if the event must not be recorded as part of the transaction
        See Also:
        isInline()
      • isCommitEvent

        boolean isCommitEvent()
        Tests whether or not this is a commit event. A commit event is triggering the post commit notification and then is reseting the recorded events.
        Returns:
        true if a commit event false otherwise
      • isImmediate

        boolean isImmediate()
        Tests if event is Immediate

        Immediate events are sent in bundle without waiting for a commit

        Returns:
        true if event is immediate, false otherwise
      • setImmediate

        void setImmediate​(boolean immediate)
        Sets the immediate flag.