public class ObservationManager extends AbstractLogEnabled implements Component, Serviceable, Contextualizable, Disposable
Modifier and Type | Class and Description |
---|---|
(package private) class |
ObservationManager.AbstractAsyncObserve
Runnable to be used for asynchronous calls
|
(package private) static class |
ObservationManager.AsyncObserveThreadFactory
Thread factory for async observers.
|
(package private) class |
ObservationManager.NonParallelAsyncObserve
Runnable for non parallel observers
|
(package private) class |
ObservationManager.ParallelAsyncObserve
Runnable for parallel observers
|
Modifier and Type | Field and Description |
---|---|
private static Logger |
__ALL_EVENTS_LOGGER |
private static ExecutorService |
__PARALLEL_THREAD_EXECUTOR
The executor service managing the thread pool of asynchronous observers
allowed to run in parallel.
|
private static ExecutorService |
__SINGLE_THREAD_EXECUTOR
The executor service managing the single thread pool.
|
protected Context |
_context
Cocoon context
|
protected ServiceManager |
_manager
Service manager
|
private ObserverExtensionPoint |
_observerExtPt |
private Collection<Observer> |
_registeredObservers |
static String |
ROLE
Avalon ROLE.
|
Constructor and Description |
---|
ObservationManager() |
Modifier and Type | Method and Description |
---|---|
private void |
_asyncObserve(Collection<AsyncObserver> parallelObservers,
List<AsyncObserver> nonParallelObservers,
Event event,
Map<String,Object> transientVars,
List<Future> result)
Async observe through a thread pool
|
protected void |
_observesEvent(Event event,
List<Observer> supportedObservers,
List<Future> result)
Observes the event
|
void |
contextualize(Context context) |
void |
dispose() |
List<Future> |
notify(Event event)
Notify of a event which will be dispatch to registered
observers.
|
void |
registerObserver(Observer observer)
Registers an
Observer . |
void |
service(ServiceManager manager) |
void |
unregisterObserver(Observer observer)
Unregisters an
Observer . |
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
private static final Logger __ALL_EVENTS_LOGGER
private static ExecutorService __SINGLE_THREAD_EXECUTOR
private static ExecutorService __PARALLEL_THREAD_EXECUTOR
protected ServiceManager _manager
private ObserverExtensionPoint _observerExtPt
private Collection<Observer> _registeredObservers
public ObservationManager()
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public void contextualize(Context context) throws ContextException
contextualize
in interface Contextualizable
ContextException
public List<Future> notify(Event event)
event
- the event to notify.Future
objects of the asynchronous observersprotected void _observesEvent(Event event, List<Observer> supportedObservers, List<Future> result) throws Exception
event
- The eventsupportedObservers
- list of observersresult
- The result object to fillException
- on errorprivate void _asyncObserve(Collection<AsyncObserver> parallelObservers, List<AsyncObserver> nonParallelObservers, Event event, Map<String,Object> transientVars, List<Future> result)
parallelObservers
- parallelizable asynchronous observersnonParallelObservers
- non parallelizable asynchronous observersevent
- The event to observetransientVars
- The observer transient varsresult
- The future resultspublic void dispose()
dispose
in interface Disposable
public void registerObserver(Observer observer)
Observer
.observer
- the Observer
.public void unregisterObserver(Observer observer)
Observer
.observer
- the Observer
.