org.directwebremoting.guice
Class InternalCreatorManager

java.lang.Object
  extended by org.directwebremoting.guice.InternalCreatorManager
All Implemented Interfaces:
CreatorManager

public class InternalCreatorManager
extends java.lang.Object
implements CreatorManager

Extends an existing creator manager with an injected list of creators specified at Guice bind-time. Only to be used in conjunction with DwrGuiceServlet.

Author:
Tim Peierls [tim at peierls dot net]

Constructor Summary
InternalCreatorManager()
          Retrieves an underlying creator manager from thread-local state to which this class delegates CreatorManager calls.
 
Method Summary
 void addCreator(Creator creator)
          Add a new creator.
 void addCreator(java.lang.String type, java.util.Map<java.lang.String,java.lang.String> params)
          Add a new creator
 void addCreatorType(java.lang.String type, java.lang.String className)
          In init mode, add a new type of creator
 Creator getCreator(java.lang.String scriptName, boolean includesHidden)
          Find an Creator by name
 java.util.Collection<java.lang.String> getCreatorNames(boolean includesHidden)
          Get a list of the javascript names of the allowed creators.
 boolean isDebug()
          Debug mode allows access to the list of creator names
 boolean isInitApplicationScopeCreatorsAtStartup()
           
 void setCreators(java.util.Map<java.lang.String,Creator> creators)
          Sets the creators for this creator manager.
 void setDebug(boolean debug)
           
 void setInitApplicationScopeCreatorsAtStartup(boolean initApplicationScopeCreatorsAtStartup)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InternalCreatorManager

public InternalCreatorManager()
Retrieves an underlying creator manager from thread-local state to which this class delegates CreatorManager calls. Adds any creators found from the Guice bindings.

Method Detail

setDebug

public void setDebug(boolean debug)
Parameters:
debug - Are we in debug mode?

isDebug

public boolean isDebug()
Description copied from interface: CreatorManager
Debug mode allows access to the list of creator names

Specified by:
isDebug in interface CreatorManager
Returns:
Are we in debug mode

addCreatorType

public void addCreatorType(java.lang.String type,
                           java.lang.String className)
Description copied from interface: CreatorManager
In init mode, add a new type of creator

Specified by:
addCreatorType in interface CreatorManager
Parameters:
type - The name of the new creator type
className - The class that we create

addCreator

public void addCreator(java.lang.String type,
                       java.util.Map<java.lang.String,java.lang.String> params)
                throws java.lang.InstantiationException,
                       java.lang.IllegalAccessException,
                       java.lang.IllegalArgumentException
Description copied from interface: CreatorManager
Add a new creator

Specified by:
addCreator in interface CreatorManager
Parameters:
type - The class to use as a creator
params - The extra parameters to allow the creator to configure itself
Throws:
java.lang.InstantiationException - If reflection based creation fails
java.lang.IllegalAccessException - If reflection based creation fails
java.lang.IllegalArgumentException - If we have a duplicate name

addCreator

public void addCreator(Creator creator)
                throws java.lang.IllegalArgumentException
Description copied from interface: CreatorManager
Add a new creator. read the value from the creator

Specified by:
addCreator in interface CreatorManager
Parameters:
creator - The creator to add
Throws:
java.lang.IllegalArgumentException - If we have a duplicate name

getCreatorNames

public java.util.Collection<java.lang.String> getCreatorNames(boolean includesHidden)
                                                       throws java.lang.SecurityException
Description copied from interface: CreatorManager
Get a list of the javascript names of the allowed creators. This method could be seen as a security risk because it could allow an attacker to find out extra information about your system so it is only available if debug is turned on.

Specified by:
getCreatorNames in interface CreatorManager
Parameters:
includesHidden - Should we include hidden classes in the list?
Returns:
Loop over all the known allowed classes
Throws:
java.lang.SecurityException - If we are not in debug mode

getCreator

public Creator getCreator(java.lang.String scriptName,
                          boolean includesHidden)
                   throws java.lang.SecurityException
Description copied from interface: CreatorManager
Find an Creator by name

Specified by:
getCreator in interface CreatorManager
Parameters:
scriptName - The name of the creator to Javascript
includesHidden - Should we include hidden classes?
Returns:
The found Creator instance, or null if none was found.
Throws:
java.lang.SecurityException - If the Creator is not known

setCreators

public void setCreators(java.util.Map<java.lang.String,Creator> creators)
Description copied from interface: CreatorManager
Sets the creators for this creator manager.

Specified by:
setCreators in interface CreatorManager
Parameters:
creators - the map of managed beans and their creator instances

isInitApplicationScopeCreatorsAtStartup

public boolean isInitApplicationScopeCreatorsAtStartup()
Returns:
accessor for if we create the created objects at startup

setInitApplicationScopeCreatorsAtStartup

public void setInitApplicationScopeCreatorsAtStartup(boolean initApplicationScopeCreatorsAtStartup)

Copyright 2008