org.directwebremoting.impl
Class DefaultContainer

java.lang.Object
  extended by org.directwebremoting.impl.AbstractContainer
      extended by org.directwebremoting.impl.DefaultContainer
All Implemented Interfaces:
Container
Direct Known Subclasses:
SpringContainer

public class DefaultContainer
extends AbstractContainer
implements Container

DefaultContainer is like a mini-IoC container for DWR. At least it is an IoC container by interface (check: no params that have anything to do with DWR), but it is hard coded specifically for DWR. If we want to make more of it we can later, but this is certainly not going to become a full blown IoC container.

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

Constructor Summary
DefaultContainer()
           
 
Method Summary
 void addParameter(java.lang.Object askFor, java.lang.Object valueParam)
          Set the class that should be used to implement the given interface
 java.lang.Object getBean(java.lang.String id)
          Get an instance of a bean of a given name (usually name=class name).
 java.util.Collection getBeanNames()
          Get a list of all the available beans.
 void setupFinished()
          Called to indicate that we finished adding parameters.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultContainer

public DefaultContainer()
Method Detail

addParameter

public void addParameter(java.lang.Object askFor,
                         java.lang.Object valueParam)
                  throws java.lang.InstantiationException,
                         java.lang.IllegalAccessException
Set the class that should be used to implement the given interface

Parameters:
askFor - The interface to implement
valueParam - The new implementation
Throws:
java.lang.IllegalAccessException - If the specified beans could not be accessed
java.lang.InstantiationException - If the specified beans could not be created

setupFinished

public void setupFinished()
Called to indicate that we finished adding parameters. The thread safety of a large part of DWR depends on this function only being called from Servlet.init(javax.servlet.ServletConfig), where all the setup is done, and where we depend on the undocumented feature of all servlet containers that they complete the init process of a Servlet before they begin servicing requests.

See Also:
addParameter(Object, Object)

getBean

public java.lang.Object getBean(java.lang.String id)
Description copied from interface: Container
Get an instance of a bean of a given name (usually name=class name).

Specified by:
getBean in interface Container
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 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
Returns:
A collection containing all the availble bean names.

Copyright ? 2005