Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.core.event.impl
Class EventServiceImpl

java.lang.Object
  extended by org.nuxeo.ecm.core.event.impl.EventServiceImpl
All Implemented Interfaces:
EventProducer, EventService, EventServiceAdmin

public class EventServiceImpl
extends Object
implements EventService, EventServiceAdmin

Implementation of the event service.


Field Summary
static VMID VMID
           
 
Constructor Summary
EventServiceImpl()
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VMID

public static final VMID VMID
Constructor Detail

EventServiceImpl

public EventServiceImpl()
Method Detail

shutdown

public void shutdown()

shutdown

public void shutdown(long timeout)

getActiveAsyncTaskCount

@Deprecated
public int getActiveAsyncTaskCount()
Deprecated. use waitForAsyncCompletion() instead.


waitForAsyncCompletion

public void waitForAsyncCompletion()
Description copied from interface: EventService
Waits until all asynchronous tasks are finished.

Specified by:
waitForAsyncCompletion in interface EventService

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 interface EventService
Parameters:
timeout - the maximum time to wait for, in milliseconds

addEventListener

public void addEventListener(EventListenerDescriptor listener)
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 interface EventService
Parameters:
listener - the listener to add

removeEventListener

public void removeEventListener(EventListenerDescriptor listener)
Description copied from interface: EventService
Removes an event listener. Used by the framework.

Specified by:
removeEventListener in interface EventService
Parameters:
listener - the listener to remove

fireEvent

public void fireEvent(String name,
                      EventContext context)
               throws ClientException
Description copied from interface: EventService
Fires an event given its name and a context.

Specified by:
fireEvent in interface EventService
Parameters:
name - the event name
context - the event context
Throws:
ClientException

fireEvent

public void fireEvent(Event event)
               throws ClientException
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 interface EventProducer
Specified by:
fireEvent in interface EventService
Parameters:
event - the event to fire
Throws:
ClientException

fireEventBundle

public void fireEventBundle(EventBundle event)
                     throws ClientException
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 interface EventProducer
Specified by:
fireEventBundle in interface EventService
Parameters:
event - the event bundle
Throws:
ClientException

fireEventBundleSync

public void fireEventBundleSync(EventBundle event)
                         throws ClientException
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 interface EventService
Throws:
ClientException

getEventListeners

public List<EventListener> 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 interface EventService
Returns:
the event listeners

getPostCommitEventListeners

public List<PostCommitEventListener> 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 interface EventService
Returns:
the post commit event listeners

transactionStarted

public void transactionStarted()
Description copied from interface: EventService
Notifies that a transaction was started. Used by the framework.

Any fired events will be recorded until the transaction is terminated either by calling EventService.transactionRolledback() either EventService.transactionCommitted().

Specified by:
transactionStarted in interface EventService

transactionCommitted

public void transactionCommitted()
                          throws ClientException
Description copied from interface: EventService
Notifies that the transaction was committed. Used by the framework.

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.

Specified by:
transactionCommitted in interface EventService
Throws:
ClientException

transactionRolledback

public void transactionRolledback()
Description copied from interface: EventService
Notifies that transaction was rolled back. Used by the framework.

This will discard any recorded event.

Specified by:
transactionRolledback in interface EventService

isTransactionStarted

public boolean isTransactionStarted()
Description copied from interface: EventService
Tests whether or not a transaction was started.

Specified by:
isTransactionStarted in interface EventService
Returns:
true if a transaction was started, false otherwise

getEventListenerList

public EventListenerList getEventListenerList()

getListenerList

public EventListenerList getListenerList()
Specified by:
getListenerList in interface EventServiceAdmin

setListenerEnabledFlag

public void setListenerEnabledFlag(String listenerName,
                                   boolean enabled)
Specified by:
setListenerEnabledFlag in interface EventServiceAdmin

getActiveThreadsCount

public int getActiveThreadsCount()
Specified by:
getActiveThreadsCount in interface EventServiceAdmin

getEventsInQueueCount

public int getEventsInQueueCount()
Specified by:
getEventsInQueueCount in interface EventServiceAdmin

isBlockAsyncHandlers

public boolean isBlockAsyncHandlers()
Specified by:
isBlockAsyncHandlers in interface EventServiceAdmin

isBlockSyncPostCommitHandlers

public boolean isBlockSyncPostCommitHandlers()
Specified by:
isBlockSyncPostCommitHandlers in interface EventServiceAdmin

setBlockAsyncHandlers

public void setBlockAsyncHandlers(boolean blockAsyncHandlers)
Specified by:
setBlockAsyncHandlers in interface EventServiceAdmin

setBlockSyncPostCommitHandlers

public void setBlockSyncPostCommitHandlers(boolean blockSyncPostComitHandlers)
Specified by:
setBlockSyncPostCommitHandlers in interface EventServiceAdmin

isBulkModeEnabled

public boolean isBulkModeEnabled()
Specified by:
isBulkModeEnabled in interface EventServiceAdmin

setBulkModeEnabled

public void setBulkModeEnabled(boolean bulkModeEnabled)
Specified by:
setBulkModeEnabled in interface EventServiceAdmin

addTransactionListener

public void addTransactionListener(EventTransactionListener listener)
Description copied from interface: EventService
Adds an event transaction listener.

Specified by:
addTransactionListener in interface EventService

removeTransactionListener

public void removeTransactionListener(EventTransactionListener listener)
Description copied from interface: EventService
Removes the given event transaction listener.

Specified by:
removeTransactionListener in interface EventService

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.