Package org.dellroad.stuff.vaadin7

Vaadin-related classes, especially relating to Spring integration.

This package contains classes that add some missing "glue" between Vaadin and Spring. In addition, these classes help address the "scope mismatch" between Vaadin application scope and Spring web application context scope that leads to memory leaks when a Vaadin application closes.

The key features included are:

  • Automatic management of per-Vaadin application Spring application contexts, with lifecycle management of Vaadin application beans
  • Autowiring of Spring-configured beans (both per-Vaadin application and "servlet global") into Vaadin beans
  • An AOP aspect that allows @VaadinConfigurable application beans to be autowired on instantiation using the curent Vaadin application's Spring application context
  • A safe and clearly defined interface for background threads needing to interact with a Vaadin application
  • A custom Spring scope that matches Vaadin application scope
  • Support for Vaadin application beans as listeners on non-Vaadin application event sources

Key classes include:

  • SpringVaadinServlet associates a Spring application context with each "Vaadin application" instance (i.e., each VaadinSession) using the SpringVaadinSessionListener class (which does the bulk of the work). The parent context is the application context associated with the overall servlet context already set up by Spring. This is analogous to what Spring's DispatcherServlet does for each servlet instance. Beans inside this context have a lifecycle which exactly tracks the Vaadin application, eliminating a major source of thread and memory leaks.
  • An AOP aspect that works on @VaadinConfigurable beans, allowing them to be autowired by the Spring application context associated with the current Vaadin application instance by SpringVaadinServlet (note: not just the parent context). Arbitrary beans get autowired into the Vaadin application's context at the time of construction.
  • VaadinApplicationScope, which adds a custom Spring scope so you can define application scoped beans in XML with scope="vaadinApplication" (for example, in the parent context).
  • VaadinExternalListener, a support superclass for listeners scoped to a Vaadin application that avoids memory leaks when listening to more widely scoped event sources. In particular, the subclass VaadinApplicationListener supports listeners for Spring application events multicasted in a (non-Vaadin application scoped) parent context.
  • The VaadinApplication class can serve as an application-wide singleton for a Vaadin application just like the Vaadin 6.x class of the same name used to do.
  • VaadinUtil provides some utility and convenience methods.

The classes in this package are also available as a Vaadin Add-on and sample code is available on GitHub.

See Also:
SpringVaadinServlet, VaadinConfigurable, SpringVaadinSessionListener, VaadinApplicationScope, VaadinExternalListener, VaadinApplicationListener, Vaadin, Spring Stuff Vaadin Add-on