Package org.dellroad.stuff.vaadin7
Class VaadinApplicationListener<E extends ApplicationEvent>
- java.lang.Object
-
- org.dellroad.stuff.vaadin7.VaadinExternalListener<ApplicationEventMulticaster>
-
- org.dellroad.stuff.vaadin7.VaadinApplicationListener<E>
-
- Type Parameters:
E- The type of the event
- All Implemented Interfaces:
EventListener,ApplicationListener<E>
public abstract class VaadinApplicationListener<E extends ApplicationEvent> extends VaadinExternalListener<ApplicationEventMulticaster> implements ApplicationListener<E>
A SpringApplicationListenersupport 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 and memory leaks are avoided when the session closes.
-
-
Constructor Summary
Constructors Constructor Description VaadinApplicationListener(ApplicationEventMulticaster multicaster)Convenience constructor.VaadinApplicationListener(ApplicationEventMulticaster multicaster, VaadinSession session)Primary constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidonApplicationEvent(E event)protected abstract voidonApplicationEventInternal(E event)Handle a listener event.protected voidregister(ApplicationEventMulticaster multicaster)Register as a listener on the given event source.protected voidunregister(ApplicationEventMulticaster multicaster)Register as a listener from the given event source.-
Methods inherited from class org.dellroad.stuff.vaadin7.VaadinExternalListener
getEventSource, getSession, handleEvent, isAsynchronous, register, setAsynchronous, unregister
-
-
-
-
Constructor Detail
-
VaadinApplicationListener
public VaadinApplicationListener(ApplicationEventMulticaster multicaster)
Convenience constructor. Equivalent to:VaadinApplicationListener(multicaster, VaadinUtil.getCurrentSession())- Parameters:
multicaster- the application event multicaster on which this listener will register- Throws:
IllegalArgumentException- ifmulticasteris nullIllegalArgumentException- if there is noVaadinSessionassociated with the current thread
-
VaadinApplicationListener
public VaadinApplicationListener(ApplicationEventMulticaster multicaster, VaadinSession session)
Primary constructor.- Parameters:
multicaster- the application event multicaster on which this listener will registersession- the associated Vaadin application- Throws:
IllegalArgumentException- if either parameter is null
-
-
Method Detail
-
register
protected void register(ApplicationEventMulticaster multicaster)
Description copied from class:VaadinExternalListenerRegister as a listener on the given event source.Subclass must implement this to perform the actual listener registration.
- Specified by:
registerin classVaadinExternalListener<ApplicationEventMulticaster>- Parameters:
multicaster- event source, never null; will be same as provided to the constructor
-
unregister
protected void unregister(ApplicationEventMulticaster multicaster)
Description copied from class:VaadinExternalListenerRegister as a listener from the given event source.Subclass must implement this to perform the actual listener registration.
- Specified by:
unregisterin classVaadinExternalListener<ApplicationEventMulticaster>- Parameters:
multicaster- event source, never null; will be same as provided to the constructor
-
onApplicationEvent
public final void onApplicationEvent(E event)
- Specified by:
onApplicationEventin interfaceApplicationListener<E extends ApplicationEvent>
-
onApplicationEventInternal
protected abstract void onApplicationEventInternal(E event)
Handle a listener event. When this method is invoked, it will already be within the context of theVaadinSessionwith which this listener is associated.- Parameters:
event- event to handle- See Also:
VaadinUtil.invoke(com.vaadin.server.VaadinSession, java.lang.Runnable),VaadinUtil.getCurrentSession()
-
-