Package org.nuxeo.ecm.core.event.impl
Class EventServiceImpl
java.lang.Object
org.nuxeo.ecm.core.event.impl.EventServiceImpl
- All Implemented Interfaces:
javax.transaction.Synchronization
,EventProducer
,EventService
,EventServiceAdmin
public class EventServiceImpl
extends Object
implements EventService, EventServiceAdmin, javax.transaction.Synchronization
Implementation of the event service.
-
Field Summary
Modifier and TypeFieldDescriptionprotected AsyncEventExecutor
protected final List<AsyncWaitHook>
protected boolean
protected boolean
protected boolean
protected EventDispatcherRegistry
protected DescriptorRegistry
protected final EventListenerList
protected EventBundleDispatcher
protected PostCommitEventExecutor
protected EventPipeRegistry
protected static final String
protected static final ThreadLocal<org.nuxeo.ecm.core.event.impl.EventServiceImpl.CompositeEventBundle>
static final VMID
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addDomainEventProducer
(DomainEventProducerDescriptor descriptor) void
addEventDispatcher
(EventDispatcherDescriptor dispatcherDescriptor) void
addEventListener
(EventListenerDescriptor listener) Adds a new event listener.void
addEventPipe
(EventPipeDescriptor pipeDescriptor) void
afterCompletion
(int status) void
Creates the registered domain event producers.void
fireEvent
(String name, EventContext context) Fires an event given its name and a context.void
Fires an event.void
fireEventBundle
(EventBundle event) Fires all recorded events in a transaction.void
fireEventBundleSync
(EventBundle event) Fires an event bundle in synchronous mode.int
getEventListener
(String name) Gets the event listener descriptor corresponding to the give name.Gets the list of the registered event listeners.int
Get the list of the registered post commit event listeners.protected void
protected void
void
init()
protected void
boolean
boolean
boolean
protected void
recordEvent
(Event event) void
registerForAsyncWait
(AsyncWaitHook callback) void
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) protected void
traceAddAnnotation
(Event event, io.opencensus.trace.Tracer tracer, long elapsed, String listener) void
unregisterForAsyncWait
(AsyncWaitHook callback) void
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.
-
Field Details
-
VMID
-
threadBundles
protected static final ThreadLocal<org.nuxeo.ecm.core.event.impl.EventServiceImpl.CompositeEventBundle> threadBundles -
listenerDescriptors
-
postCommitExec
-
asyncExec
-
asyncWaitHooks
-
blockAsyncProcessing
protected boolean blockAsyncProcessing -
blockSyncPostCommitProcessing
protected boolean blockSyncPostCommitProcessing -
bulkModeEnabled
protected boolean bulkModeEnabled -
registeredPipes
-
dispatchers
-
pipeDispatcher
-
domainEventProducers
-
REGISTRY_TARGET_NAME
- See Also:
-
-
Constructor Details
-
EventServiceImpl
public EventServiceImpl()
-
-
Method Details
-
init
public void init() -
getEventBundleDispatcher
-
addDomainEventProducer
-
removeDomainEventProducer
-
shutdown
- Throws:
InterruptedException
-
registerForAsyncWait
-
unregisterForAsyncWait
-
waitForAsyncCompletion
public void waitForAsyncCompletion()Description copied from interface:EventService
Waits until all asynchronous tasks are finished.- Specified by:
waitForAsyncCompletion
in interfaceEventService
-
waitForAsyncCompletion
public void waitForAsyncCompletion(long timeout) Description copied from interface:EventService
Waits until all asynchronous tasks are finished, but waits no longer than the given number of milliseconds.- Specified by:
waitForAsyncCompletion
in interfaceEventService
- Parameters:
timeout
- the maximum time to wait for, in milliseconds
-
addEventListener
Description copied from interface:EventService
Adds a new event listener. Used by the framework.The event listener is described by a
EventListenerDescriptor
that may specify a priority. Both types of listeners (immediate and post-commit) are registered.- Specified by:
addEventListener
in interfaceEventService
- Parameters:
listener
- the listener to add
-
addEventPipe
-
addEventDispatcher
-
removeEventListener
Description copied from interface:EventService
Removes an event listener. Used by the framework.- Specified by:
removeEventListener
in interfaceEventService
- Parameters:
listener
- the listener to remove
-
removeEventPipe
-
removeEventDispatcher
-
fireEvent
Description copied from interface:EventService
Fires an event given its name and a context.- Specified by:
fireEvent
in interfaceEventService
- Parameters:
name
- the event namecontext
- the event context
-
fireEvent
Description copied from interface:EventService
Fires an event.If a transaction was started, the event is registered if needed to be sent after the transaction commit.
- Specified by:
fireEvent
in interfaceEventProducer
- Specified by:
fireEvent
in interfaceEventService
- Parameters:
event
- the event to fire
-
traceAddAnnotation
-
fireEventBundle
Description copied from interface:EventService
Fires all recorded events in a transaction. Used by the framework.The events are fired to
PostCommitEventListener
listeners. Events are fired in the form of an event bundle.- Specified by:
fireEventBundle
in interfaceEventProducer
- Specified by:
fireEventBundle
in interfaceEventService
- Parameters:
event
- the event bundle
-
fireEventBundleSync
Description copied from interface:EventService
Fires an event bundle in synchronous mode. Used by the framework.This means that asynchronous listeners will be run synchronously.
- Specified by:
fireEventBundleSync
in interfaceEventService
-
getEventListeners
Description copied from interface:EventService
Gets the list of the registered event listeners.Modification on this list will not modify the internal lists in this
EventService
.- Specified by:
getEventListeners
in interfaceEventService
- Returns:
- the event listeners
-
getPostCommitEventListeners
Description copied from interface:EventService
Get the list of the registered post commit event listeners.Modification on this list will not modify the internal lists in this
EventService
.- Specified by:
getPostCommitEventListeners
in interfaceEventService
- Returns:
- the post commit event listeners
-
getEventListenerList
-
getEventListener
Description copied from interface:EventService
Gets the event listener descriptor corresponding to the give name.- Specified by:
getEventListener
in interfaceEventService
- Parameters:
name
- the event listener name- Returns:
- the descriptor, or
null
if not found
-
getListenerList
- Specified by:
getListenerList
in interfaceEventServiceAdmin
-
setListenerEnabledFlag
- Specified by:
setListenerEnabledFlag
in interfaceEventServiceAdmin
-
getActiveThreadsCount
public int getActiveThreadsCount()- Specified by:
getActiveThreadsCount
in interfaceEventServiceAdmin
-
getEventsInQueueCount
public int getEventsInQueueCount()- Specified by:
getEventsInQueueCount
in interfaceEventServiceAdmin
-
isBlockAsyncHandlers
public boolean isBlockAsyncHandlers()- Specified by:
isBlockAsyncHandlers
in interfaceEventServiceAdmin
-
isBlockSyncPostCommitHandlers
public boolean isBlockSyncPostCommitHandlers()- Specified by:
isBlockSyncPostCommitHandlers
in interfaceEventServiceAdmin
-
setBlockAsyncHandlers
public void setBlockAsyncHandlers(boolean blockAsyncHandlers) - Specified by:
setBlockAsyncHandlers
in interfaceEventServiceAdmin
-
setBlockSyncPostCommitHandlers
public void setBlockSyncPostCommitHandlers(boolean blockSyncPostComitHandlers) - Specified by:
setBlockSyncPostCommitHandlers
in interfaceEventServiceAdmin
-
isBulkModeEnabled
public boolean isBulkModeEnabled()- Specified by:
isBulkModeEnabled
in interfaceEventServiceAdmin
-
setBulkModeEnabled
public void setBulkModeEnabled(boolean bulkModeEnabled) - Specified by:
setBulkModeEnabled
in interfaceEventServiceAdmin
-
recordEvent
-
beforeCompletion
public void beforeCompletion()- Specified by:
beforeCompletion
in interfacejavax.transaction.Synchronization
-
afterCompletion
public void afterCompletion(int status) - Specified by:
afterCompletion
in interfacejavax.transaction.Synchronization
-
handleTxRollbacked
protected void handleTxRollbacked() -
handleTxCommited
protected void handleTxCommited() -
createDomainEventProducers
Description copied from interface:EventService
Creates the registered domain event producers.- Specified by:
createDomainEventProducers
in interfaceEventService
-
initDomainEventStreams
protected void initDomainEventStreams()
-