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
FieldsModifier and TypeFieldDescriptionprotected AsyncEventExecutorprotected final List<AsyncWaitHook>protected booleanprotected booleanprotected booleanprotected EventDispatcherRegistryprotected DescriptorRegistryprotected final EventListenerListprotected EventBundleDispatcherprotected PostCommitEventExecutorprotected EventPipeRegistryprotected static final Stringprotected static final ThreadLocal<org.nuxeo.ecm.core.event.impl.EventServiceImpl.CompositeEventBundle>static final VMID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDomainEventProducer(DomainEventProducerDescriptor descriptor) voidaddEventDispatcher(EventDispatcherDescriptor dispatcherDescriptor) voidaddEventListener(EventListenerDescriptor listener) Adds a new event listener.voidaddEventPipe(EventPipeDescriptor pipeDescriptor) voidafterCompletion(int status) voidCreates the registered domain event producers.voidfireEvent(String name, EventContext context) Fires an event given its name and a context.voidFires an event.voidfireEventBundle(EventBundle event) Fires all recorded events in a transaction.voidfireEventBundleSync(EventBundle event) Fires an event bundle in synchronous mode.intgetEventListener(String name) Gets the event listener descriptor corresponding to the give name.Gets the list of the registered event listeners.intGet the list of the registered post commit event listeners.protected voidprotected voidvoidinit()protected voidbooleanbooleanbooleanprotected voidrecordEvent(Event event) voidregisterForAsyncWait(AsyncWaitHook callback) voidvoidremoveEventDispatcher(EventDispatcherDescriptor dispatcherDescriptor) voidremoveEventListener(EventListenerDescriptor listener) Removes an event listener.voidremoveEventPipe(EventPipeDescriptor pipeDescriptor) voidsetBlockAsyncHandlers(boolean blockAsyncHandlers) voidsetBlockSyncPostCommitHandlers(boolean blockSyncPostComitHandlers) voidsetBulkModeEnabled(boolean bulkModeEnabled) voidsetListenerEnabledFlag(String listenerName, boolean enabled) voidshutdown(long timeoutMillis) protected voidtraceAddAnnotation(Event event, io.opencensus.trace.Tracer tracer, long elapsed, String listener) voidunregisterForAsyncWait(AsyncWaitHook callback) voidWaits until all asynchronous tasks are finished.voidwaitForAsyncCompletion(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:EventServiceWaits until all asynchronous tasks are finished.- Specified by:
waitForAsyncCompletionin interfaceEventService
-
waitForAsyncCompletion
public void waitForAsyncCompletion(long timeout) Description copied from interface:EventServiceWaits until all asynchronous tasks are finished, but waits no longer than the given number of milliseconds.- Specified by:
waitForAsyncCompletionin interfaceEventService- Parameters:
timeout- the maximum time to wait for, in milliseconds
-
addEventListener
Description copied from interface:EventServiceAdds a new event listener. Used by the framework.The event listener is described by a
EventListenerDescriptorthat may specify a priority. Both types of listeners (immediate and post-commit) are registered.- Specified by:
addEventListenerin interfaceEventService- Parameters:
listener- the listener to add
-
addEventPipe
-
addEventDispatcher
-
removeEventListener
Description copied from interface:EventServiceRemoves an event listener. Used by the framework.- Specified by:
removeEventListenerin interfaceEventService- Parameters:
listener- the listener to remove
-
removeEventPipe
-
removeEventDispatcher
-
fireEvent
Description copied from interface:EventServiceFires an event given its name and a context.- Specified by:
fireEventin interfaceEventService- Parameters:
name- the event namecontext- the event context
-
fireEvent
Description copied from interface:EventServiceFires an event.If a transaction was started, the event is registered if needed to be sent after the transaction commit.
- Specified by:
fireEventin interfaceEventProducer- Specified by:
fireEventin interfaceEventService- Parameters:
event- the event to fire
-
traceAddAnnotation
-
fireEventBundle
Description copied from interface:EventServiceFires all recorded events in a transaction. Used by the framework.The events are fired to
PostCommitEventListenerlisteners. Events are fired in the form of an event bundle.- Specified by:
fireEventBundlein interfaceEventProducer- Specified by:
fireEventBundlein interfaceEventService- Parameters:
event- the event bundle
-
fireEventBundleSync
Description copied from interface:EventServiceFires an event bundle in synchronous mode. Used by the framework.This means that asynchronous listeners will be run synchronously.
- Specified by:
fireEventBundleSyncin interfaceEventService
-
getEventListeners
Description copied from interface:EventServiceGets the list of the registered event listeners.Modification on this list will not modify the internal lists in this
EventService.- Specified by:
getEventListenersin interfaceEventService- Returns:
- the event listeners
-
getPostCommitEventListeners
Description copied from interface:EventServiceGet the list of the registered post commit event listeners.Modification on this list will not modify the internal lists in this
EventService.- Specified by:
getPostCommitEventListenersin interfaceEventService- Returns:
- the post commit event listeners
-
getEventListenerList
-
getEventListener
Description copied from interface:EventServiceGets the event listener descriptor corresponding to the give name.- Specified by:
getEventListenerin interfaceEventService- Parameters:
name- the event listener name- Returns:
- the descriptor, or
nullif not found
-
getListenerList
- Specified by:
getListenerListin interfaceEventServiceAdmin
-
setListenerEnabledFlag
- Specified by:
setListenerEnabledFlagin interfaceEventServiceAdmin
-
getActiveThreadsCount
public int getActiveThreadsCount()- Specified by:
getActiveThreadsCountin interfaceEventServiceAdmin
-
getEventsInQueueCount
public int getEventsInQueueCount()- Specified by:
getEventsInQueueCountin interfaceEventServiceAdmin
-
isBlockAsyncHandlers
public boolean isBlockAsyncHandlers()- Specified by:
isBlockAsyncHandlersin interfaceEventServiceAdmin
-
isBlockSyncPostCommitHandlers
public boolean isBlockSyncPostCommitHandlers()- Specified by:
isBlockSyncPostCommitHandlersin interfaceEventServiceAdmin
-
setBlockAsyncHandlers
public void setBlockAsyncHandlers(boolean blockAsyncHandlers) - Specified by:
setBlockAsyncHandlersin interfaceEventServiceAdmin
-
setBlockSyncPostCommitHandlers
public void setBlockSyncPostCommitHandlers(boolean blockSyncPostComitHandlers) - Specified by:
setBlockSyncPostCommitHandlersin interfaceEventServiceAdmin
-
isBulkModeEnabled
public boolean isBulkModeEnabled()- Specified by:
isBulkModeEnabledin interfaceEventServiceAdmin
-
setBulkModeEnabled
public void setBulkModeEnabled(boolean bulkModeEnabled) - Specified by:
setBulkModeEnabledin interfaceEventServiceAdmin
-
recordEvent
-
beforeCompletion
public void beforeCompletion()- Specified by:
beforeCompletionin interfacejavax.transaction.Synchronization
-
afterCompletion
public void afterCompletion(int status) - Specified by:
afterCompletionin interfacejavax.transaction.Synchronization
-
handleTxRollbacked
protected void handleTxRollbacked() -
handleTxCommited
protected void handleTxCommited() -
createDomainEventProducers
Description copied from interface:EventServiceCreates the registered domain event producers.- Specified by:
createDomainEventProducersin interfaceEventService
-
initDomainEventStreams
protected void initDomainEventStreams()
-