com.vaadin.server
Class AddonContext

java.lang.Object
  extended by com.vaadin.server.AddonContext
All Implemented Interfaces:
java.io.Serializable

public class AddonContext
extends java.lang.Object
implements java.io.Serializable

Point of entry for add-ons for integrating into various aspects of the framework. One add-on context is initialized for each Vaadin Servlet or Portlet instance and upon initialization, every AddonContextListener that can be found is notified to let it add listeners to the context.

By default, AddonContextListeners are loaded using ServiceLoader, which means that the file META-INF/services/com.vaadin.server.AddonContextListener will be checked for lines containing fully qualified names of classes to use. This behavior can however be overridden for custom deployment situations (e.g. to use CDI or OSGi) by overriding VaadinService.getAddonContextListeners().

Since:
7.0.0
Author:
Vaadin Ltd
See Also:
Serialized Form

Constructor Summary
AddonContext(VaadinService vaadinService)
          Creates a new context using a given vaadin service.
 
Method Summary
 void addApplicationStartedListener(ApplicationStartedListener applicationStartListener)
          Adds a listener that will be notified any time a new VaadinSession instance is started or more precisely directly after VaadinSession#init() has been invoked.
 void addBootstrapListener(BootstrapListener listener)
          Shorthand for adding a bootstrap listener that will be added to every new application.
 void destroy()
          Destroys this context, causing all initialized listeners to be invoked.
 void fireApplicationStarted(VaadinSession application)
          Fires an ApplicationStartedEvent to all registered listeners.
 VaadinService getVaadinService()
          Gets the vaadin service for this context.
 void init()
          Initializes this context, causing all found listeners to be notified.
 void removeApplicationStartedListener(ApplicationStartedListener applicationStartListener)
          Removes an application start listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AddonContext

public AddonContext(VaadinService vaadinService)
Creates a new context using a given vaadin service. Only the framework itself should typically create AddonContext instances.

Parameters:
vaadinService - the vaadin service for the associated servlet or portlet.
Method Detail

getVaadinService

public VaadinService getVaadinService()
Gets the vaadin service for this context.

Returns:
the vaadin service

init

public void init()
Initializes this context, causing all found listeners to be notified. Listeners are by default found using ServiceLoader, but the VaadinService can provide an alternative implementation.

This method is not intended to be used by add-ons, but instead by the part of the framework that created this context object.


destroy

public void destroy()
Destroys this context, causing all initialized listeners to be invoked.

This method is not intended to be used by add-ons, but instead by the part of the framework that created this context object.


addBootstrapListener

public void addBootstrapListener(BootstrapListener listener)
Shorthand for adding a bootstrap listener that will be added to every new application.

Parameters:
listener - the bootstrap listener that should be added to all new applications.
See Also:
addApplicationStartedListener(ApplicationStartedListener), VaadinSession.addBootstrapListener(BootstrapListener)

fireApplicationStarted

public void fireApplicationStarted(VaadinSession application)
Fires an ApplicationStartedEvent to all registered listeners. This method is not intended to be used by add-ons, but instead by the part of the framework that creates new Application instances.

Parameters:
application - the newly started application
See Also:
addApplicationStartedListener(ApplicationStartedListener)

addApplicationStartedListener

public void addApplicationStartedListener(ApplicationStartedListener applicationStartListener)
Adds a listener that will be notified any time a new VaadinSession instance is started or more precisely directly after VaadinSession#init() has been invoked.

Parameters:
applicationStartListener - the application start listener that should be added

removeApplicationStartedListener

public void removeApplicationStartedListener(ApplicationStartedListener applicationStartListener)
Removes an application start listener.

Parameters:
applicationStartListener - the application start listener to remove
See Also:
addApplicationStartedListener(ApplicationStartedListener)


Copyright © 2000-2011 Vaadin Ltd. All Rights Reserved.