Package org.ametys.core.observation
Class ObservationManager
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.core.observation.ObservationManager
-
- All Implemented Interfaces:
Disposable
,Component
,Contextualizable
,LogEnabled
,Serviceable
public class ObservationManager extends AbstractLogEnabled implements Component, Serviceable, Contextualizable, Disposable
-
-
Constructor Summary
Constructors Constructor Description ObservationManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_observesEvent(Event event, List<Observer> supportedObservers, List<Future> result)
Observes the eventvoid
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 argumentvoid
contextualize(Context context)
void
dispose()
List<Future>
getFuturesForRequest()
Gets all theFuture
s of all theAsyncObserver
s notified by the call tonotify(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 anObserver
.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 theaddArgumentForEvents(String[], String, Object)
method.void
service(ServiceManager manager)
void
unregisterObserver(Observer observer)
Unregisters anObserver
.-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Constructor Detail
-
ObservationManager
public ObservationManager()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
notify
public List<Future> notify(Event event)
Notify of a event which will be dispatch to registered observers.- Parameters:
event
- the event to notify.- Returns:
- The
Future
objects of the asynchronous observers
-
getFuturesForRequest
public List<Future> getFuturesForRequest()
Gets all theFuture
s of all theAsyncObserver
s notified by the call tonotify(Event)
during the current request.
This can be useful to callFuture.get()
in order to ensure allAsyncObserver
s notified by the current request have finished to work.- Returns:
- the
Future
s of the notified observers during the current request.
-
addArgumentForEvents
public 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- Parameters:
eventIds
- The event idsargName
- The name of the additional argumentargValue
- The value of the additional argument
-
removeArgumentForEvents
public 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 theaddArgumentForEvents(String[], String, Object)
method.- Parameters:
eventIds
- The event idsargName
- The name of the additional argument to remove
-
_observesEvent
protected void _observesEvent(Event event, List<Observer> supportedObservers, List<Future> result) throws Exception
Observes the event- Parameters:
event
- The eventsupportedObservers
- list of observersresult
- The result object to fill- Throws:
Exception
- on error
-
dispose
public void dispose()
- Specified by:
dispose
in interfaceDisposable
-
registerObserver
public void registerObserver(Observer observer)
Registers anObserver
.- Parameters:
observer
- theObserver
.
-
unregisterObserver
public void unregisterObserver(Observer observer)
Unregisters anObserver
.- Parameters:
observer
- theObserver
.
-
-