The 'static' Creator

The static creator is declared by default by DWR as follows: <creator id="static" class="org.directwebremoting.create.StaticCreator"/> You don't need to add this line to your dwr.xml because it is already in DWR's internal dwr.xml file.

This creator will retrieve an instance of a class using the getInstance() method (by default) or a user specified method.

You allow DWR to use the static creator to retrieve and remote your beans as follows:

<allow>
  <create creator="static" javascript="Blah">
    <param name="class" value="my.package.Singleton"/>
  </create>
  ... 
</allow>

This remotes my.package.Singleton to Javascript and gives it the name Blah so in Javascript when you call Blah.toString(reply) an instance of my.package.Singleton will be retrieved using the getInstance method. Then the toString() method will be called, and the data returned to the javascript reply function.

Please note that the creator, and javascript attributes are required as well as the param element which indicates which class DWR should retrieve.

The static creator has an optional parameter that will allow you to specify the name of the method that will retrieve an instance of the class (once again getInstance is used by default). Here is an example of this usage:

<allow>
  <create creator="static" javascript="Blah">
    <param name="class" value="my.package.Singleton"/>
    <param name="instanceMethodName" value="getCustomInstance"/>
  </create>
  ... 
</allow>