org.dellroad.stuff.vaadin
Class VaadinApplicationScope

java.lang.Object
  extended by org.dellroad.stuff.vaadin.VaadinApplicationScope
All Implemented Interfaces:
ContextApplication.CloseListener, BeanFactoryPostProcessor, Scope

public class VaadinApplicationScope
extends Object
implements Scope, BeanFactoryPostProcessor, ContextApplication.CloseListener

A Spring custom Scope for Vaadin applications.

This works for applications that subclass ContextApplication; objects will be scoped to each ContextApplication instance. Spring destroy-methods will be invoked when the ContextApplication is closed.

To enable this scope, simply add this bean to your application context as a singleton (it will register itself):

  <!-- Enable the "vaadinApplication" custom scope -->
  <bean class="org.dellroad.stuff.vaadin.VaadinApplicationScope"/>
 
Then declare scoped beans normally using the scope name "vaadinApplication".


Field Summary
static String APPLICATION_KEY
          Key to the current application instance.
static String SCOPE_NAME
          The name of this scope (i.e., "vaadinApplication").
 
Constructor Summary
VaadinApplicationScope()
           
 
Method Summary
 void applicationClosed(ContextApplication.CloseEvent closeEvent)
          Notification upon ContextApplication closing.
 Object get(String name, ObjectFactory<?> objectFactory)
           
 String getConversationId()
           
 void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
           
 void registerDestructionCallback(String name, Runnable callback)
           
 Object remove(String name)
           
 Object resolveContextualObject(String key)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

APPLICATION_KEY

public static final String APPLICATION_KEY
Key to the current application instance. For use by resolveContextualObject(java.lang.String).

See Also:
Constant Field Values

SCOPE_NAME

public static final String SCOPE_NAME
The name of this scope (i.e., "vaadinApplication").

See Also:
Constant Field Values
Constructor Detail

VaadinApplicationScope

public VaadinApplicationScope()
Method Detail

postProcessBeanFactory

public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
Specified by:
postProcessBeanFactory in interface BeanFactoryPostProcessor

applicationClosed

public void applicationClosed(ContextApplication.CloseEvent closeEvent)
Description copied from interface: ContextApplication.CloseListener
Notification upon ContextApplication closing.

Specified by:
applicationClosed in interface ContextApplication.CloseListener

get

public Object get(String name,
                  ObjectFactory<?> objectFactory)
Specified by:
get in interface Scope

remove

public Object remove(String name)
Specified by:
remove in interface Scope

registerDestructionCallback

public void registerDestructionCallback(String name,
                                        Runnable callback)
Specified by:
registerDestructionCallback in interface Scope

getConversationId

public String getConversationId()
Specified by:
getConversationId in interface Scope

resolveContextualObject

public Object resolveContextualObject(String key)
Specified by:
resolveContextualObject in interface Scope