net.grinder.scriptengine
Interface ScriptEngineService

All Known Implementing Classes:
ClojureScriptEngineService, JavaScriptEngineService, JythonScriptEngineService

public interface ScriptEngineService

Service interface that script engines should implement.

The Grinder discovers script engine implementations from the META-INF/net.grinder.scriptengines resource files. Each engine should register its class name as a line in such a resource file. The order of the search engines is important, since it determines priority. The engines are ordered first by the class path search order used to load the resource files, and then the order of lines in the resource files. Earlier engines have higher priority.

Each script engine is injected with framework services using PicoContainer. The use of PicoContainer should be transparent; implementations simply need to declare the services they require as constructor parameters.

Available services include:

A DCRContext will be provided only if DCR is available. Engines that use DCR should have two constructors, one of them requiring a DCRContext, and one of them not. The latter constructor will be used if DCR is unavailable.

Author:
Philip Aston

Nested Class Summary
static interface ScriptEngineService.ScriptEngine
          Handler for a particular type of script.
static interface ScriptEngineService.WorkerRunnable
          Interface to the runnable script object for a particular worker thread.
 
Field Summary
static String RESOURCE_NAME
          All resources with this name are loaded to discover implementations.
 
Method Summary
 List<? extends Instrumenter> createInstrumenters()
          Initialises script engine instrumentation.
 ScriptEngineService.ScriptEngine createScriptEngine(ScriptLocation script)
          If the script engine service can handle the given script, it should return a suitable implementation.
 

Field Detail

RESOURCE_NAME

static final String RESOURCE_NAME
All resources with this name are loaded to discover implementations.

See Also:
Constant Field Values
Method Detail

createScriptEngine

ScriptEngineService.ScriptEngine createScriptEngine(ScriptLocation script)
                                                    throws EngineException
If the script engine service can handle the given script, it should return a suitable implementation.

Implementations typically will execute the script and perform any process level initialisation.

Parameters:
script - The script.
Returns:
The script engine, or null.
Throws:
EngineException - If an implementation could not be created.

createInstrumenters

List<? extends Instrumenter> createInstrumenters()
                                                 throws EngineException
Initialises script engine instrumentation.

Each script engine can provide instrumenters, irrespective of the engine used to execute the script. The instrumenters provided by each engine are consulted according to service registration order in the META-INF file.

Returns:
Additional instrumenters to use. Engines that do not provide instrumentation should return an empty list.
Throws:
EngineException - If a problem occurred creating instrumenters.


Copyright © 2000-2013. All Rights Reserved.