org.rhq.bindings
Class ScriptEngineFactory

java.lang.Object
  extended by org.rhq.bindings.ScriptEngineFactory

public class ScriptEngineFactory
extends Object

This is RHQ specific imitation of ScriptEngineFactory. In RHQ, we provide a standard set of bound variables in the script context and also import classes from our standard packages to ease the development of the scripts.

This factory is able to instantiate a script engine and initialize it consistently so that all users of the script engine get the uniform environment to write the scripts in.

Author:
Lukas Krejci

Method Summary
static void bindIndirectionMethods(ScriptEngine scriptEngine, String bindingName, Object object)
           
static ScriptEngineInitializer getInitializer(String language)
           
static ScriptEngine getScriptEngine(String language, PackageFinder packageFinder, StandardBindings bindings)
          Initializes the script engine for given language.
static void injectStandardBindings(ScriptEngine engine, StandardBindings bindings, boolean deleteExistingBindings)
          Injects the values provided in the bindings into the engine scope of the provided script engine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getScriptEngine

public static ScriptEngine getScriptEngine(String language,
                                           PackageFinder packageFinder,
                                           StandardBindings bindings)
                                    throws ScriptException,
                                           IOException
Initializes the script engine for given language.

Parameters:
language - the language of the script to instantiate
packageFinder - the package finder to find the standard packages in user provided locations
Returns:
the initialized engine or null if the engine for given language isn't known.
Throws:
ScriptException - on error during initialization of the script environment
IOException - if the package finder fails to find the packages

injectStandardBindings

public static void injectStandardBindings(ScriptEngine engine,
                                          StandardBindings bindings,
                                          boolean deleteExistingBindings)
Injects the values provided in the bindings into the engine scope of the provided script engine.

Parameters:
engine - the engine
bindings - the bindings
deleteExistingBindings - true if the existing bindings should be replaced by the provided ones, false if the provided bindings should be added to the existing ones (possibly overwriting bindings with the same name).

bindIndirectionMethods

public static void bindIndirectionMethods(ScriptEngine scriptEngine,
                                          String bindingName,
                                          Object object)

getInitializer

public static ScriptEngineInitializer getInitializer(String language)


Copyright © 2008-2011 Red Hat, Inc.. All Rights Reserved.