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 String |
__ADDITIONAL_ARGS_TO_PASS_BY_EVENT_ID_REQUEST_ATTR_NAME |
private static Logger |
__ALL_EVENTS_LOGGER |
private static String |
__CURRENT_FUTURES_REQUEST_ATTR_NAME |
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.
|
private Context |
_avalonContext |
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
|
private List<Future> |
_getFuturesForRequest() |
protected void |
_observesEvent(Event event,
List<Observer> supportedObservers,
List<Future> result)
Observes the event
|
private void |
_putAdditionalArgs(Event event) |
void |
addArgumentForEvents(String[] eventIds,
String argName,
Object argValue)
For all events of the given event id which will be notified during the current request, add an additional argument
|
void |
contextualize(Context context) |
void |
dispose() |
List<Future> |
getFuturesForRequest()
Gets all the
Future s of all the AsyncObserver s notified by the call to notify(Event) during the current request. |
List<Future> |
notify(Event event)
Notify of a event which will be dispatch to registered
observers.
|
void |
registerObserver(Observer observer)
Registers an
Observer . |
void |
removeArgumentForEvents(String[] eventIds,
String argName)
For all events of the given event id which will be notified during the current request, removes the additional argument
with the given name which was added with the
addArgumentForEvents(String[], String, Object) method. |
void |
service(ServiceManager manager) |
void |
unregisterObserver(Observer observer)
Unregisters an
Observer . |
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
private static final String __CURRENT_FUTURES_REQUEST_ATTR_NAME
private static final String __ADDITIONAL_ARGS_TO_PASS_BY_EVENT_ID_REQUEST_ATTR_NAME
private static final Logger __ALL_EVENTS_LOGGER
private static ExecutorService __SINGLE_THREAD_EXECUTOR
private static ExecutorService __PARALLEL_THREAD_EXECUTOR
protected ServiceManager _manager
private Context _avalonContext
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 observerspublic List<Future> getFuturesForRequest()
Future
s of all the AsyncObserver
s notified by the call to notify(Event)
during the current request.
Future.get()
in order to ensure all AsyncObserver
s notified by the current request have finished to work.Future
s of the notified observers during the current request.private List<Future> _getFuturesForRequest() throws CascadingRuntimeException
CascadingRuntimeException
public void addArgumentForEvents(String[] eventIds, String argName, Object argValue)
eventIds
- The event idsargName
- The name of the additional argumentargValue
- The value of the additional argumentpublic void removeArgumentForEvents(String[] eventIds, String argName)
addArgumentForEvents(String[], String, Object)
method.eventIds
- The event idsargName
- The name of the additional argument to removeprivate void _putAdditionalArgs(Event event)
protected 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
.