|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.alfresco.repo.management.SafeApplicationEventMulticaster
public class SafeApplicationEventMulticaster
Abstract implementation of the ApplicationEventMulticaster
interface,
providing the basic listener registration facility.
Doesn't permit multiple instances of the same listener by default, as it keeps listeners in a linked Set. The collection class used to hold ApplicationListener objects can be overridden through the "collectionClass" bean property.
Implementing ApplicationEventMulticaster's actual SafeApplicationEventMulticaster.multicastEvent(org.springframework.context.ApplicationEvent)
method is left to subclasses. SimpleApplicationEventMulticaster
simply multicasts all events to all registered listeners, invoking them in
the calling thread. Alternative implementations could be more sophisticated
in those respects.
SafeApplicationEventMulticaster.getApplicationListeners(ApplicationEvent)
,
SimpleApplicationEventMulticaster
Constructor Summary | |
---|---|
SafeApplicationEventMulticaster()
|
Method Summary | |
---|---|
void |
addApplicationListener(org.springframework.context.ApplicationListener listener)
|
void |
addApplicationListenerBean(java.lang.String listenerBeanName)
|
protected java.util.Collection |
getApplicationListeners()
Return a Collection containing all ApplicationListeners. |
protected java.util.Collection |
getApplicationListeners(org.springframework.context.ApplicationEvent event)
Return a Collection of ApplicationListeners matching the given event type. |
protected java.util.concurrent.Executor |
getTaskExecutor()
Return the current TaskExecutor for this multicaster. |
void |
multicastEvent(org.springframework.context.ApplicationEvent event)
|
protected void |
multicastEventInternal(org.springframework.context.ApplicationEvent event)
|
void |
removeAllListeners()
|
void |
removeApplicationListener(org.springframework.context.ApplicationListener listener)
|
void |
removeApplicationListenerBean(java.lang.String listenerBeanName)
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
|
void |
setTaskExecutor(java.util.concurrent.Executor taskExecutor)
Set the TaskExecutor to execute application listeners with. |
protected boolean |
supportsEvent(org.springframework.context.ApplicationListener listener,
java.lang.Class eventType,
java.lang.Class sourceType)
Determine whether the given listener supports the given event. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SafeApplicationEventMulticaster()
Method Detail |
---|
public void setTaskExecutor(java.util.concurrent.Executor taskExecutor)
Default is a SyncTaskExecutor, executing the listeners synchronously in the calling thread.
Consider specifying an asynchronous TaskExecutor here to not block the caller until all listeners have been executed. However, note that asynchronous execution will not participate in the caller's thread context (class loader, transaction association) unless the TaskExecutor explicitly supports this.
org.springframework.core.task.SyncTaskExecutor
,
org.springframework.core.task.SimpleAsyncTaskExecutor
protected java.util.concurrent.Executor getTaskExecutor()
public void addApplicationListener(org.springframework.context.ApplicationListener listener)
addApplicationListener
in interface org.springframework.context.event.ApplicationEventMulticaster
public void addApplicationListenerBean(java.lang.String listenerBeanName)
addApplicationListenerBean
in interface org.springframework.context.event.ApplicationEventMulticaster
public void removeApplicationListener(org.springframework.context.ApplicationListener listener)
removeApplicationListener
in interface org.springframework.context.event.ApplicationEventMulticaster
public void removeApplicationListenerBean(java.lang.String listenerBeanName)
removeApplicationListenerBean
in interface org.springframework.context.event.ApplicationEventMulticaster
public void removeAllListeners()
removeAllListeners
in interface org.springframework.context.event.ApplicationEventMulticaster
public void multicastEvent(org.springframework.context.ApplicationEvent event)
multicastEvent
in interface org.springframework.context.event.ApplicationEventMulticaster
protected void multicastEventInternal(org.springframework.context.ApplicationEvent event)
protected java.util.Collection getApplicationListeners()
ApplicationListener
protected java.util.Collection getApplicationListeners(org.springframework.context.ApplicationEvent event)
event
- the event to be propagated. Allows for excluding non-matching
listeners early, based on cached matching information.
ApplicationListener
protected boolean supportsEvent(org.springframework.context.ApplicationListener listener, java.lang.Class eventType, java.lang.Class sourceType)
The default implementation detects the SmartApplicationListener
interface. In case of a standard ApplicationListener
, a
GenericApplicationListenerAdapter
will be used to introspect the
generically declared type of the target listener.
listener
- the target listener to checkeventType
- the event type to check againstsourceType
- the source type to check against
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
org.springframework.beans.BeansException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |