The 'scripted' Creator
The scripted creator is declared by default by DWR as follows:
<creator id="script" class="org.directwebremoting.create.ScriptedCreator"/>
This creator uses BSF to execute scripts that return some bean, for example:
The script creator accepts the following parameters:
|language||1.0||The language that we are scripting in. This string is passed to BSF. For example 'beanshell'. (required)|
|class||1.0||The type of object that is created. This is required for security reasons.|
|script||1.0||The script to execute which will return a Java Object to remote. (required unless scriptPath is used)|
|scriptPath||1.1||The path to a script stored in a file. (required unless script is used)|
|reloadable||1.1||Should the ScriptedCreator check for changes to scripts loaded using scriptPath? (optional, defaults to true)|
Issues to be aware of
If there is a class that the script creates where the scope is session (or application), and you change the script, The class in the session is no longer going to match the class generated by the script and errors will occur. The container doesn't have to be restarted but the user has to log out (or clear the session somehow) and log back in.
Also when the class param is not null and is used to create a new instance, it simply calls the class.newInstance() method. This is ok unless the script is creating a new class with certain parameters or calling certain functions to configure the class. Unfortunately, re-evaluating the script each time causes the issue above to happen every request.