For invoking a script you have two options - either you invoke the script directly using the ScriptService or you can use a ScriptRunnable (which relies on the ScriptService).
This example invokes a script called "CompilableInterface" and passed two parameters for executing the script.
Object result = null;
SimpleNamespace args = new SimpleNamespace();
args.put("count",new Integer(i));
args.put("currentTime",new Long(System.currentTimeMillis()));
result = scriptService.eval("CompilableInterface", args);
This example creates a ScriptRunnable to invoke a script called "MultiThreaded".
Hashtable args = new Hashtable();
args.put("foo", new Double(0));
ScriptRunnable runnable = scriptService.createRunnable( scriptService, "MultiThreaded", args );
runnable.run();
result = runnable.getResult();
The Fulcrum Script Service passes a ScriptAvalonContext to the script
var logger = avalonContext.getLogger();
var applicationDir = avalonContext.getApplicationDir();
var tempDir = avalonContext.getTempDir();
var serviceManager = avalonContext.getServiceManager();
var parameters = avalonContext.getParameters();
var configuration = avalonContext.getConfiguration();
var isDebug = configuration.getChild("isDebug").getValueAsBoolean(false);
serviceManager.lookup("org.apache.fulcrum.script.ScriptService").exists("Avalon");