public class EventServiceImpl extends Object implements EventService, EventServiceAdmin
Constructor and Description |
---|
EventServiceImpl() |
Modifier and Type | Method and Description |
---|---|
void |
addEventListener(EventListenerDescriptor listener)
Adds a new event listener.
|
void |
addTransactionListener(EventTransactionListener listener)
Adds an event transaction listener.
|
void |
fireEvent(Event event)
Fires an event.
|
void |
fireEvent(String name,
EventContext context)
Fires an event given its name and a context.
|
void |
fireEventBundle(EventBundle event)
Fires all recorded events in a transaction.
|
void |
fireEventBundleSync(EventBundle event)
Fires an event bundle in synchronous mode.
|
int |
getActiveAsyncTaskCount()
Deprecated.
use
waitForAsyncCompletion() instead. |
int |
getActiveThreadsCount() |
EventListenerList |
getEventListenerList() |
List<EventListener> |
getEventListeners()
Gets the list of the registered event listeners.
|
int |
getEventsInQueueCount() |
EventListenerList |
getListenerList() |
List<PostCommitEventListener> |
getPostCommitEventListeners()
Get the list of the registered post commit event listeners.
|
boolean |
isBlockAsyncHandlers() |
boolean |
isBlockSyncPostCommitHandlers() |
boolean |
isBulkModeEnabled() |
boolean |
isTransactionStarted()
Tests whether or not a transaction was started.
|
void |
removeEventListener(EventListenerDescriptor listener)
Removes an event listener.
|
void |
removeTransactionListener(EventTransactionListener listener)
Removes the given event transaction listener.
|
void |
setBlockAsyncHandlers(boolean blockAsyncHandlers) |
void |
setBlockSyncPostCommitHandlers(boolean blockSyncPostComitHandlers) |
void |
setBulkModeEnabled(boolean bulkModeEnabled) |
void |
setListenerEnabledFlag(String listenerName,
boolean enabled) |
void |
shutdown() |
void |
shutdown(long timeout) |
void |
transactionCommitted()
Notifies that the transaction was committed.
|
void |
transactionRolledback()
Notifies that transaction was rolled back.
|
void |
transactionStarted()
Notifies that a transaction was started.
|
void |
waitForAsyncCompletion()
Waits until all asynchronous tasks are finished.
|
void |
waitForAsyncCompletion(long timeout)
Waits until all asynchronous tasks are finished, but waits no longer than
the given number of milliseconds.
|
public static final VMID VMID
public void shutdown()
public void shutdown(long timeout)
@Deprecated public int getActiveAsyncTaskCount()
waitForAsyncCompletion()
instead.public void waitForAsyncCompletion()
EventService
waitForAsyncCompletion
in interface EventService
public void waitForAsyncCompletion(long timeout)
EventService
waitForAsyncCompletion
in interface EventService
timeout
- the maximum time to wait for, in millisecondspublic void addEventListener(EventListenerDescriptor listener)
EventService
The event listener is described by a EventListenerDescriptor
that
may specify a priority. Both types of listeners (immediate and
post-commit) are registered.
addEventListener
in interface EventService
listener
- the listener to addpublic void removeEventListener(EventListenerDescriptor listener)
EventService
removeEventListener
in interface EventService
listener
- the listener to removepublic void fireEvent(String name, EventContext context) throws ClientException
EventService
fireEvent
in interface EventService
name
- the event namecontext
- the event contextClientException
public void fireEvent(Event event) throws ClientException
EventService
If a transaction was started, the event is registered if needed to be sent after the transaction commit.
fireEvent
in interface EventProducer
fireEvent
in interface EventService
event
- the event to fireClientException
public void fireEventBundle(EventBundle event) throws ClientException
EventService
The events are fired to PostCommitEventListener
listeners. Events
are fired in the form of an event bundle.
fireEventBundle
in interface EventProducer
fireEventBundle
in interface EventService
event
- the event bundleClientException
public void fireEventBundleSync(EventBundle event) throws ClientException
EventService
This means that asynchronous listeners will be run synchronously.
fireEventBundleSync
in interface EventService
ClientException
public List<EventListener> getEventListeners()
EventService
Modification on this list will not modify the internal lists in this
EventService
.
getEventListeners
in interface EventService
public List<PostCommitEventListener> getPostCommitEventListeners()
EventService
Modification on this list will not modify the internal lists in this
EventService
.
getPostCommitEventListeners
in interface EventService
public void transactionStarted()
EventService
Any fired events will be recorded until the transaction is terminated
either by calling EventService.transactionRolledback()
either
EventService.transactionCommitted()
.
transactionStarted
in interface EventService
public void transactionCommitted() throws ClientException
EventService
This will fire the events collected during the transaction in the form of
a EventBundle
. After this the recording will stop and recorded
events discarded.
transactionCommitted
in interface EventService
ClientException
public void transactionRolledback()
EventService
This will discard any recorded event.
transactionRolledback
in interface EventService
public boolean isTransactionStarted()
EventService
isTransactionStarted
in interface EventService
public EventListenerList getEventListenerList()
public EventListenerList getListenerList()
getListenerList
in interface EventServiceAdmin
public void setListenerEnabledFlag(String listenerName, boolean enabled)
setListenerEnabledFlag
in interface EventServiceAdmin
public int getActiveThreadsCount()
getActiveThreadsCount
in interface EventServiceAdmin
public int getEventsInQueueCount()
getEventsInQueueCount
in interface EventServiceAdmin
public boolean isBlockAsyncHandlers()
isBlockAsyncHandlers
in interface EventServiceAdmin
public boolean isBlockSyncPostCommitHandlers()
isBlockSyncPostCommitHandlers
in interface EventServiceAdmin
public void setBlockAsyncHandlers(boolean blockAsyncHandlers)
setBlockAsyncHandlers
in interface EventServiceAdmin
public void setBlockSyncPostCommitHandlers(boolean blockSyncPostComitHandlers)
setBlockSyncPostCommitHandlers
in interface EventServiceAdmin
public boolean isBulkModeEnabled()
isBulkModeEnabled
in interface EventServiceAdmin
public void setBulkModeEnabled(boolean bulkModeEnabled)
setBulkModeEnabled
in interface EventServiceAdmin
public void addTransactionListener(EventTransactionListener listener)
EventService
addTransactionListener
in interface EventService
public void removeTransactionListener(EventTransactionListener listener)
EventService
removeTransactionListener
in interface EventService
Copyright © 2011 Nuxeo SA. All Rights Reserved.