org.directwebremoting.create
Class SingletonCreator

java.lang.Object
  extended by org.directwebremoting.create.AbstractCreator
      extended by org.directwebremoting.create.SingletonCreator
All Implemented Interfaces:
Creator

public class SingletonCreator
extends AbstractCreator
implements Creator

A Creator that uses an instance method to create singletons.

By default this creator uses a static method with the signature: SomeClass.getInstance() to create new instances. The name of the singleton constructor method can be customized using the getInstance parameter.

Author:
Ahmed Hashim [hashim at egjug dot org], Joe Walker [joe at getahead dot ltd dot uk]

Field Summary
 
Fields inherited from interface org.directwebremoting.extend.Creator
APPLICATION, PAGE, REQUEST, SCRIPT, SESSION
 
Constructor Summary
SingletonCreator()
           
 
Method Summary
 java.lang.String getFactoryMethod()
           
 java.lang.Object getInstance()
          Accessor for the/an instance of this Creator.
 java.lang.Class getType()
          Accessor for the java.lang.Class that this Creator allows access to.
 void setClass(java.lang.String classname)
          What sort of class do we create?
 void setFactoryMethod(java.lang.String functionToCall)
           
 
Methods inherited from class org.directwebremoting.create.AbstractCreator
checkScope, getJavascript, getScope, isCacheable, setCacheable, setJavascript, setProperties, setScope, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.directwebremoting.extend.Creator
getJavascript, getScope, isCacheable, setProperties
 

Constructor Detail

SingletonCreator

public SingletonCreator()
Method Detail

setClass

public void setClass(java.lang.String classname)
What sort of class do we create?

Parameters:
classname - The name of the class

getInstance

public java.lang.Object getInstance()
                             throws java.lang.InstantiationException
Description copied from interface: Creator
Accessor for the/an instance of this Creator.

Specified by:
getInstance in interface Creator
Returns:
the instance to use
Throws:
java.lang.InstantiationException - If for some reason the object can not be created

getType

public java.lang.Class getType()
Description copied from interface: Creator
Accessor for the java.lang.Class that this Creator allows access to.

Specified by:
getType in interface Creator
Returns:
The type of this allowed class

getFactoryMethod

public java.lang.String getFactoryMethod()
Returns:
the factoryMethod function name

setFactoryMethod

public void setFactoryMethod(java.lang.String functionToCall)
Parameters:
functionToCall - the name of the factory function.