public class EventImpl extends Object implements Event
Modifier and Type | Field and Description |
---|---|
protected EventContext |
ctx |
protected int |
flags |
protected String |
name |
protected Exception |
rollbackException |
protected String |
rollbackMessage |
protected long |
time |
FLAG_BUBBLE_EXCEPTION, FLAG_CANCEL, FLAG_COMMIT, FLAG_IMMEDIATE, FLAG_INLINE, FLAG_LOCAL, FLAG_NONE, FLAG_ROLLBACK
Constructor and Description |
---|
EventImpl(String name,
EventContext ctx) |
EventImpl(String name,
EventContext ctx,
int flags) |
EventImpl(String name,
EventContext ctx,
int flags,
long creationTime) |
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancels this event.
|
EventContext |
getContext()
Gets the event context.
|
int |
getFlags()
Gets the set of event flags
|
String |
getName()
Gets the event name.
|
Exception |
getRollbackException()
Returns the Exception associated the RollBack if any
|
String |
getRollbackMessage()
Returns the message associated to the RollBack if any
|
long |
getTime()
The time stamp when the event was raised.
|
boolean |
isBubbleException()
Returns
true 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 Immediate
|
boolean |
isInline()
Whether this event must not be added to a bundle.
|
boolean |
isLocal()
Tests if this event is local.
|
boolean |
isMarkedForRollBack()
Checks whether the event was marked for RollBack
|
boolean |
isPublic()
Tests if this event is public.
|
void |
markBubbleException()
Marks the event to bubble the Exception thrown by a listener.
|
void |
markRollBack()
Marks transaction for RollBack
|
void |
markRollBack(String message,
Exception exception)
Marks transaction for RollBack
|
void |
setImmediate(boolean immediate)
Sets the immediate flag.
|
void |
setInline(boolean isInline)
Set the inline flag.
|
void |
setIsCommitEvent(boolean isCommit)
Set the commit flag.
|
void |
setLocal(boolean isLocal)
Sets the local flag.
|
void |
setPublic(boolean isPublic)
Set the public flag.
|
protected final long time
protected final EventContext ctx
protected int flags
protected Exception rollbackException
protected String rollbackMessage
public EventImpl(String name, EventContext ctx, int flags, long creationTime)
public EventImpl(String name, EventContext ctx, int flags)
public EventImpl(String name, EventContext ctx)
public EventContext getContext()
Event
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.
getContext
in interface Event
public String getName()
Event
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.
public long getTime()
Event
getTime
in interface Event
System.currentTimeMillis()
public void cancel()
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.
public void markRollBack()
Event
This will exit the event listeners loop and throw a RuntimeException In JTA container, this will make the global transaction rollback.
markRollBack
in interface Event
public void markRollBack(String message, Exception exception)
Event
This will exit the event listeners loop and throw a RuntimeException In JTA container, this will make the global transaction rollback.
markRollBack
in interface Event
message
- message that explains the reason of the Rollbackexception
- associated Exception that explains the Rollback if anypublic void markBubbleException()
Event
This will exit the event listeners loop. The transaction won't be rollbacked, but the Exception will be thrown by
the EventService
.
markBubbleException
in interface Event
public boolean isBubbleException()
Event
true
if the event was marked to bubble the Exception, false
otherwise.isBubbleException
in interface Event
public boolean isMarkedForRollBack()
Event
isMarkedForRollBack
in interface Event
public boolean isCanceled()
Event
isCanceled
in interface Event
public boolean isInline()
Event
public void setInline(boolean isInline)
Event
setInline
in interface Event
isInline
- true if the event must not be recorded as part of the transactionEvent.isInline()
public boolean isCommitEvent()
Event
isCommitEvent
in interface Event
public void setIsCommitEvent(boolean isCommit)
Event
setIsCommitEvent
in interface Event
Event.isCommitEvent()
public boolean isLocal()
Event
Local events events are of interest only on the local machine.
public void setLocal(boolean isLocal)
Event
setLocal
in interface Event
Event.isLocal()
public boolean isPublic()
Event
Public events are of interest to everyone.
public void setPublic(boolean isPublic)
Event
setPublic
in interface Event
Event.isPublic()
public boolean isImmediate()
Event
Immediate events are sent in bundle without waiting for a commit
isImmediate
in interface Event
public void setImmediate(boolean immediate)
Event
setImmediate
in interface Event
public Exception getRollbackException()
Event
getRollbackException
in interface Event
public String getRollbackMessage()
Event
getRollbackMessage
in interface Event
Copyright © 2018 Nuxeo. All rights reserved.