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.
- Author:
- Bogdan Stefanescu
-
-
Field Summary
Fields Modifier and Type Field Description static int
FLAG_BUBBLE_EXCEPTION
static int
FLAG_CANCEL
static int
FLAG_COMMIT
static int
FLAG_IMMEDIATE
static int
FLAG_INLINE
static int
FLAG_NONE
static int
FLAG_ROLLBACK
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description void
cancel()
Cancels this event.EventContext
getContext()
Gets the event context.int
getFlags()
Gets the set of event flagsString
getName()
Gets the event name.Exception
getRollbackException()
Returns the Exception associated the RollBack if anyString
getRollbackMessage()
Returns the message associated to the RollBack if anylong
getTime()
The time stamp when the event was raised.boolean
isBubbleException()
Returnstrue
if the event was marked to bubble the Exception,false
otherwise.boolean
isCanceled()
Checks whether the event was canceled.boolean
isCommitEvent()
Tests whether or not this is a commit event.boolean
isImmediate()
Tests if event is Immediateboolean
isInline()
Whether this event must not be added to a bundle.default boolean
isLocal()
Deprecated.since 10.3boolean
isMarkedForRollBack()
Checks whether the event was marked for RollBackdefault boolean
isPublic()
Deprecated.since 10.3void
markBubbleException()
Marks the event to bubble the Exception thrown by a listener.void
markRollBack()
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 Detail
-
FLAG_NONE
static final int FLAG_NONE
- See Also:
- Constant Field Values
-
FLAG_CANCEL
static final int FLAG_CANCEL
- See Also:
- Constant Field Values
-
FLAG_ROLLBACK
static final int FLAG_ROLLBACK
- See Also:
- Constant Field Values
-
FLAG_COMMIT
static final int FLAG_COMMIT
- See Also:
- Constant Field Values
-
FLAG_INLINE
static final int FLAG_INLINE
- See Also:
- Constant Field Values
-
FLAG_IMMEDIATE
static final int FLAG_IMMEDIATE
- See Also:
- Constant Field Values
-
FLAG_BUBBLE_EXCEPTION
static final int FLAG_BUBBLE_EXCEPTION
- See Also:
- Constant Field Values
-
-
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.
-
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
void markRollBack(String message, Exception exception)
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:
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
-
setIsCommitEvent
void setIsCommitEvent(boolean isCommit)
Set the commit flag.- See Also:
isCommitEvent()
-
isLocal
@Deprecated default boolean isLocal()
Deprecated.since 10.3
-
setLocal
@Deprecated default void setLocal(boolean isLocal)
Deprecated.since 10.3
-
isPublic
@Deprecated default boolean isPublic()
Deprecated.since 10.3
-
setPublic
@Deprecated default void setPublic(boolean isPublic)
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.
-
-