com.partnersoft.scripting
Class ScriptEngineScript

java.lang.Object
  extended by com.partnersoft.scripting.AbstractScript
      extended by com.partnersoft.scripting.ScriptEngineScript
All Implemented Interfaces:
Script, java.lang.Runnable
Direct Known Subclasses:
RubyScript

public class ScriptEngineScript
extends AbstractScript

A configurable Script using the javax.script framework.

If you have the appropriate ScriptEngine available (see https://scripting.dev.java.net/) you can invoke it using the supplied type or extension in the constructor. For example:

 Script script = new ScriptEngineScript(file, "ruby");
 script.run();
 

Copyright 2005-2007 Partner Software, Inc.

Version:
$Id: ScriptEngineScript.java 2013 2009-08-10 03:29:31Z paul $
Author:
Paul Reavis

Constructor Summary
ScriptEngineScript(VfsFile file)
          Create a script using the ScriptEngine corresponding to the given file's extension.
ScriptEngineScript(VfsFile file, java.lang.String type)
          Create a script using a ScriptEngine with the given type name.
 
Method Summary
protected  void reloadImp()
          Subclasses should implement this method to do any maintenance associated with changes in the source file.
static void resetManager()
          Resets the script engine manager.
protected  java.lang.Object runScriptImp(Naming<java.lang.Object> variables)
          Subclasses should implement this method with their actual script-running implementation.
static boolean supportsFile(VfsFile file)
           
 
Methods inherited from class com.partnersoft.scripting.AbstractScript
getFile, getName, getScriptLog, getThrown, getVariable, getVariables, isModified, parse, run, runScript, runThreaded, setThrown, setVariable, setVariables, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ScriptEngineScript

public ScriptEngineScript(VfsFile file)
Create a script using the ScriptEngine corresponding to the given file's extension.


ScriptEngineScript

public ScriptEngineScript(VfsFile file,
                          java.lang.String type)
Create a script using a ScriptEngine with the given type name. You can also (sometimes) specify an extension; it's smart enough to deal with leading periods (.).

Method Detail

resetManager

public static void resetManager()
Resets the script engine manager. Should only be called by early bootstrap code.


supportsFile

public static boolean supportsFile(VfsFile file)

reloadImp

protected void reloadImp()
                  throws java.lang.Exception
Description copied from class: AbstractScript
Subclasses should implement this method to do any maintenance associated with changes in the source file. This method is called whenever the source file's modification timestamp changes. Use it to load, parse, compile, or whatever you do with the scripting language in question to get it ready to execute. Feel free to throw exceptions; these will be caught and handled appropriately (logging the error, providing the Throwable in getThrown(), etc.).

Specified by:
reloadImp in class AbstractScript
Throws:
java.lang.Exception

runScriptImp

protected java.lang.Object runScriptImp(Naming<java.lang.Object> variables)
                                 throws java.lang.Exception
Description copied from class: AbstractScript
Subclasses should implement this method with their actual script-running implementation. They should feel free to throw exceptions; these will be caught and handled appropriately (logging the error, providing the Throwable in getThrown(), etc.).

Specified by:
runScriptImp in class AbstractScript
Throws:
java.lang.Exception