public class EventServiceImpl extends Object implements EventService, EventServiceAdmin, Synchronization
Modifier and Type | Field and Description |
---|---|
protected AsyncEventExecutor |
asyncExec |
protected List<AsyncWaitHook> |
asyncWaitHooks |
protected boolean |
blockAsyncProcessing |
protected boolean |
blockSyncPostCommitProcessing |
protected boolean |
bulkModeEnabled |
protected EventDispatcherRegistry |
dispatchers |
protected EventListenerList |
listenerDescriptors |
protected EventBundleDispatcher |
pipeDispatcher |
protected PostCommitEventExecutor |
postCommitExec |
protected EventPipeRegistry |
registeredPipes |
protected static ThreadLocal<org.nuxeo.ecm.core.event.impl.EventServiceImpl.CompositeEventBundle> |
threadBundles |
static VMID |
VMID |
Constructor and Description |
---|
EventServiceImpl() |
Modifier and Type | Method and Description |
---|---|
void |
addEventDispatcher(EventDispatcherDescriptor dispatcherDescriptor) |
void |
addEventListener(EventListenerDescriptor listener)
Adds a new event listener.
|
void |
addEventPipe(EventPipeDescriptor pipeDescriptor) |
void |
afterCompletion(int status) |
void |
beforeCompletion() |
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 |
getActiveThreadsCount() |
EventBundleDispatcher |
getEventBundleDispatcher() |
EventListenerDescriptor |
getEventListener(String name)
Gets the event listener descriptor corresponding to the give name.
|
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.
|
protected void |
handleTxCommited() |
protected void |
handleTxRollbacked() |
void |
init() |
boolean |
isBlockAsyncHandlers() |
boolean |
isBlockSyncPostCommitHandlers() |
boolean |
isBulkModeEnabled() |
protected void |
recordEvent(Event event) |
void |
registerForAsyncWait(AsyncWaitHook callback) |
void |
removeEventDispatcher(EventDispatcherDescriptor dispatcherDescriptor) |
void |
removeEventListener(EventListenerDescriptor listener)
Removes an event listener.
|
void |
removeEventPipe(EventPipeDescriptor pipeDescriptor) |
void |
setBlockAsyncHandlers(boolean blockAsyncHandlers) |
void |
setBlockSyncPostCommitHandlers(boolean blockSyncPostComitHandlers) |
void |
setBulkModeEnabled(boolean bulkModeEnabled) |
void |
setListenerEnabledFlag(String listenerName,
boolean enabled) |
void |
shutdown(long timeoutMillis) |
void |
unregisterForAsyncWait(AsyncWaitHook callback) |
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.
|
protected static final ThreadLocal<org.nuxeo.ecm.core.event.impl.EventServiceImpl.CompositeEventBundle> threadBundles
protected final EventListenerList listenerDescriptors
protected PostCommitEventExecutor postCommitExec
protected volatile AsyncEventExecutor asyncExec
protected final List<AsyncWaitHook> asyncWaitHooks
protected boolean blockAsyncProcessing
protected boolean blockSyncPostCommitProcessing
protected boolean bulkModeEnabled
protected EventPipeRegistry registeredPipes
protected EventDispatcherRegistry dispatchers
protected EventBundleDispatcher pipeDispatcher
public EventServiceImpl()
public void init()
public EventBundleDispatcher getEventBundleDispatcher()
public void shutdown(long timeoutMillis) throws InterruptedException
InterruptedException
public void registerForAsyncWait(AsyncWaitHook callback)
public void unregisterForAsyncWait(AsyncWaitHook callback)
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 addEventPipe(EventPipeDescriptor pipeDescriptor)
public void addEventDispatcher(EventDispatcherDescriptor dispatcherDescriptor)
public void removeEventListener(EventListenerDescriptor listener)
EventService
removeEventListener
in interface EventService
listener
- the listener to removepublic void removeEventPipe(EventPipeDescriptor pipeDescriptor)
public void removeEventDispatcher(EventDispatcherDescriptor dispatcherDescriptor)
public void fireEvent(String name, EventContext context)
EventService
fireEvent
in interface EventService
name
- the event namecontext
- the event contextpublic void fireEvent(Event event)
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 firepublic void fireEventBundle(EventBundle event)
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 bundlepublic void fireEventBundleSync(EventBundle event)
EventService
This means that asynchronous listeners will be run synchronously.
fireEventBundleSync
in interface EventService
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 EventListenerList getEventListenerList()
public EventListenerDescriptor getEventListener(String name)
EventService
getEventListener
in interface EventService
name
- the event listener namenull
if not foundpublic 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
protected void recordEvent(Event event)
public void beforeCompletion()
beforeCompletion
in interface Synchronization
public void afterCompletion(int status)
afterCompletion
in interface Synchronization
protected void handleTxRollbacked()
protected void handleTxCommited()
Copyright © 2018 Nuxeo. All rights reserved.