|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.dellroad.stuff.vaadin.VaadinApplicationListener<E>
public abstract class VaadinApplicationListener<E extends ApplicationEvent>
A Spring ApplicationListener support superclass customized for use by
listeners that are part of a Vaadin application when listening to non-Vaadin application event sources.
Listeners that are part of a Vaadin application should use this superclass if they are going to be registered with non-Vaadin event sources. This will ensure that events are delivered in the proper Vaadin application context.
Note: to avoid memory leaks, listeners must be explicitly unregistered when the associated Vaadin application closes.
This can be done by explicitly registering for an application close notification
in which the listener is unregistered, or by unregistering the listener in the Spring
destroy-method associated with a
bean that has scope="vaadinApplication" or lives in a SpringContextApplication
application context (so that the bean's destroy method will be invoked when the Vaadin application closes).
Note: when listening to event sources that are scoped to specific Vaadin application instances and originate events within the proper Vaadin application context, then the use of this listener superclass is not necessary.
ContextApplication.invoke(java.lang.Runnable),
VaadinApplicationScope,
SpringContextApplication| Field Summary |
|---|
| Fields inherited from interface org.springframework.core.Ordered |
|---|
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE |
| Constructor Summary | |
|---|---|
VaadinApplicationListener(Class<E> eventType)
Convenience constructor. |
|
VaadinApplicationListener(Class<E> eventType,
ContextApplication application)
Primary constructor. |
|
| Method Summary | |
|---|---|
ContextApplication |
getApplication()
|
Class<E> |
getEventType()
|
int |
getOrder()
Get ordering value. |
void |
onApplicationEvent(ApplicationEvent event)
|
protected abstract void |
onApplicationEventInternal(E event)
Handle a listener event within the context of the ContextApplication with which this listener is associated. |
boolean |
supportsEventType(Class<? extends ApplicationEvent> eventType)
Determine whether this listener actually supports the given event type. |
boolean |
supportsSourceType(Class<?> sourceType)
Determine whether this listener actually supports the given source type. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public VaadinApplicationListener(Class<E> eventType)
VaadinApplicationListener(eventType, ContextApplication.get())
IllegalArgumentException - if eventType is null
IllegalStateException - if there is no ContextApplication associated with the current thread
public VaadinApplicationListener(Class<E> eventType,
ContextApplication application)
eventType - type of events this instance should receive (others will be ignored)application - the associated Vaadin application
IllegalArgumentException - if either parameter is null| Method Detail |
|---|
public final Class<E> getEventType()
public final ContextApplication getApplication()
public final void onApplicationEvent(ApplicationEvent event)
onApplicationEvent in interface ApplicationListener<ApplicationEvent>protected abstract void onApplicationEventInternal(E event)
ContextApplication with which this listener is associated.
The current ContextApplication is also available via ContextApplication.get().
ContextApplication.get()public boolean supportsEventType(Class<? extends ApplicationEvent> eventType)
The implementation in VaadinApplicationListener tests whether eventType
is assignable to the type given in the constructor. Subclasses may override as desired.
supportsEventType in interface SmartApplicationListenerpublic boolean supportsSourceType(Class<?> sourceType)
The implementation in VaadinApplicationListener always returns true. Subclasses may override as desired.
supportsSourceType in interface SmartApplicationListenerpublic int getOrder()
The implementation in VaadinApplicationListener always returns zero. Subclasses may override as desired.
getOrder in interface Ordered
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||