org.directwebremoting.spring
Class SpringContainer

java.lang.Object
  extended by org.directwebremoting.impl.AbstractContainer
      extended by org.directwebremoting.impl.DefaultContainer
          extended by org.directwebremoting.spring.SpringContainer
All Implemented Interfaces:
Container, UninitializingBean, org.springframework.beans.factory.BeanFactoryAware

public class SpringContainer
extends DefaultContainer
implements Container, org.springframework.beans.factory.BeanFactoryAware, UninitializingBean

A Container implementation that looks up all beans from the configuration specified in a Spring context. It loads the configuration from a Spring web application context.

Author:
Bram Smeets, Joe Walker [joe at getahead dot ltd dot uk]

Constructor Summary
SpringContainer()
           
 
Method Summary
 void addParameter(java.lang.String askFor, java.lang.Object valueParam)
          Add a parameter to the container as a possibility for injection
 void contextDestroyed()
          This should be called only by DwrListener.
 java.lang.Object getBean(java.lang.String id)
          Get the contained instance of a bean/setting of a given name.
 java.util.Collection<java.lang.String> getBeanNames()
          Get a list of all the available beans.
 void servletDestroyed()
          Should be called only by DwrServlet (or other servlet implementations).
 void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
           
 
Methods inherited from class org.directwebremoting.impl.DefaultContainer
addBean, addImplementation, addImplementationOption, contextDestroyed, getParameter, initializeBean, newInstance, servletDestroyed, setupFinished
 
Methods inherited from class org.directwebremoting.impl.AbstractContainer
getBean
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.directwebremoting.Container
getBean, initializeBean, newInstance
 

Constructor Detail

SpringContainer

public SpringContainer()
Method Detail

setBeanFactory

public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
                    throws org.springframework.beans.BeansException
Specified by:
setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware
Throws:
org.springframework.beans.BeansException

addParameter

public void addParameter(java.lang.String askFor,
                         java.lang.Object valueParam)
                  throws ContainerConfigurationException
Description copied from class: DefaultContainer
Add a parameter to the container as a possibility for injection

Overrides:
addParameter in class DefaultContainer
Parameters:
askFor - The key that will be looked up
valueParam - The value to be returned from the key lookup
Throws:
ContainerConfigurationException - If the specified beans could not be used

getBean

public java.lang.Object getBean(java.lang.String id)
Description copied from interface: Container
Get the contained instance of a bean/setting of a given name.

Specified by:
getBean in interface Container
Overrides:
getBean in class DefaultContainer
Parameters:
id - The type to get an instance of
Returns:
The object of the given type, or null if the object does not exist

getBeanNames

public java.util.Collection<java.lang.String> getBeanNames()
Description copied from interface: Container
Get a list of all the available beans. Implementation of this method is optional so it is valid for this method to return an empty collection, but to return Objects when queried directly using Container.getBean(String). This method should only be used for debugging purposes.

Specified by:
getBeanNames in interface Container
Overrides:
getBeanNames in class DefaultContainer
Returns:
A collection containing all the available bean names.

contextDestroyed

public void contextDestroyed()
Description copied from interface: Container
This should be called only by DwrListener. It requests all reverse ajax threads to stop.

GenericServlet.destroy() is called only when all connections are closed. If a DwrListener is configured then we can close down the connections in a timely way. All other tidy-up is done by Container.servletDestroyed() which will work even when a DwrListener has not been configured.

Specified by:
contextDestroyed in interface Container
Specified by:
contextDestroyed in interface UninitializingBean
Overrides:
contextDestroyed in class DefaultContainer
See Also:
Container.servletDestroyed()

servletDestroyed

public void servletDestroyed()
Description copied from interface: Container
Should be called only by DwrServlet (or other servlet implementations). It requests all other threads to stop, and any tidy-up that can be done after the context has been fully destroyed.

Specified by:
servletDestroyed in interface Container
Specified by:
servletDestroyed in interface UninitializingBean
Overrides:
servletDestroyed in class DefaultContainer
See Also:
Container.contextDestroyed()

Copyright 2008