Interface Event
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
EventImpl
,ShallowEvent
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.
- Author:
- Bogdan Stefanescu
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
static final int
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
Cancels this event.Gets the event context.int
getFlags()
Gets the set of event flagsgetName()
Gets the event name.Returns the Exception associated the RollBack if anyReturns the message associated to the RollBack if anylong
getTime()
The time stamp when the event was raised.boolean
Returnstrue
if the event was marked to bubble the Exception,false
otherwise.boolean
Checks whether the event was canceled.boolean
Tests whether or not this is a commit event.boolean
Tests if event is Immediateboolean
isInline()
Whether this event must not be added to a bundle.default boolean
isLocal()
Deprecated.since 10.3boolean
Checks whether the event was marked for RollBackdefault boolean
isPublic()
Deprecated.since 10.3void
Marks the event to bubble the Exception thrown by a listener.void
Marks transaction for RollBackvoid
markRollBack
(String message, Exception exception) Marks transaction for RollBackvoid
setImmediate
(boolean immediate) Sets the immediate flag.void
setInline
(boolean isInline) Set the inline flag.void
setIsCommitEvent
(boolean isCommit) Set the commit flag.default void
setLocal
(boolean isLocal) Deprecated.since 10.3default void
setPublic
(boolean isPublic) Deprecated.since 10.3
-
Field Details
-
FLAG_NONE
static final int FLAG_NONE- See Also:
-
FLAG_CANCEL
static final int FLAG_CANCEL- See Also:
-
FLAG_ROLLBACK
static final int FLAG_ROLLBACK- See Also:
-
FLAG_COMMIT
static final int FLAG_COMMIT- See Also:
-
FLAG_INLINE
static final int FLAG_INLINE- See Also:
-
FLAG_IMMEDIATE
static final int FLAG_IMMEDIATE- See Also:
-
FLAG_BUBBLE_EXCEPTION
static final int FLAG_BUBBLE_EXCEPTION- See Also:
-
-
Method Details
-
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.
-
getTime
long getTime()The time stamp when the event was raised.- Returns:
- the time stamp as returned by
System.currentTimeMillis()
-
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()Returnstrue
if the event was marked to bubble the Exception,false
otherwise.- Since:
- 5.7
-
markRollBack
void markRollBack()Marks transaction for RollBackThis will exit the event listeners loop and throw a RuntimeException In JTA container, this will make the global transaction rollback.
-
markRollBack
Marks transaction for RollBackThis 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 Rollbackexception
- 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:
-
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
-
setIsCommitEvent
void setIsCommitEvent(boolean isCommit) Set the commit flag.- See Also:
-
isLocal
Deprecated.since 10.3 -
setLocal
Deprecated.since 10.3 -
isPublic
Deprecated.since 10.3 -
setPublic
Deprecated.since 10.3 -
isImmediate
boolean isImmediate()Tests if event is ImmediateImmediate 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.
-