Package org.apache.bsf.engines.javascript

# Class JavaScriptEngine

java.lang.Object
org.apache.bsf.util.BSFEngineImpl
org.apache.bsf.engines.javascript.JavaScriptEngine

All Implemented Interfaces:
  `PropertyChangeListener`, `EventListener`, `BSFEngine`

public class JavaScriptEngine extends BSFEngineImpl
This is the interface to Netscape's Rhino (JavaScript) from the Bean Scripting Framework.

The original version of this code was first written by Adam Peller for use in LotusXSL. Sanjiva took his code and adapted it for BSF.

Author:
  Adam Peller <peller@lotus.com>, Sanjiva Weerawarana, Matthew J. Duftler, Norris Boyd

- ## Field Summary

  ### Fields inherited from class org.apache.bsf.util.BSFEngineImpl

  `classLoader, classPath, declaredBeans, lang, mgr, tempDir`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `JavaScriptEngine()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Object`
  `call(Object object, String method, Object[] args)`
  Return an object from an extension.
  `void`
  `declareBean(BSFDeclaredBean bean)`
  Declare a bean after the engine has been started.
  `Object`
  `eval(String source, int lineNo, int columnNo, Object oscript)`
  This is used by an application to evaluate a string containing some expression.
  `void`
  `initialize(BSFManager mgr, String lang, Vector declaredBeans)`
  Initialize the engine.
  `void`
  `undeclareBean(BSFDeclaredBean bean)`
  Undeclare a previously declared bean.

  ### Methods inherited from class org.apache.bsf.util.BSFEngineImpl

  `apply, compileApply, compileExpr, compileScript, exec, iexec, propertyChange, terminate`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### JavaScriptEngine

    public JavaScriptEngine()

- ## Method Details

  - ### call

    public Object call(Object object, String method, Object[] args) throws BSFException
    Return an object from an extension.
    Parameters:
      `object` - Object on which to make the call (ignored).
      `method` - The name of the method to call.
      `args` - an array of arguments to be passed to the extension, which may be either Vectors of Nodes, or Strings.
    Throws:
      `BSFException` - if anything goes wrong while eval'ing a BSFException is thrown. The reason indicates the problem.

  - ### declareBean

    public void declareBean(BSFDeclaredBean bean) throws BSFException
    Description copied from interface: `BSFEngine`
    Declare a bean after the engine has been started. Declared beans are beans that are named and which the engine must make available to the scripts it runs in the most first class way possible.
    Specified by:
      `declareBean` in interface `BSFEngine`
    Overrides:
      `declareBean` in class `BSFEngineImpl`
    Parameters:
      `bean` - the bean to declare
    Throws:
      `BSFException` - if the engine cannot do this operation

  - ### eval

    public Object eval(String source, int lineNo, int columnNo, Object oscript) throws BSFException
    This is used by an application to evaluate a string containing some expression.
    Parameters:
      `source` - (context info) the source of this expression (e.g., filename)
      `lineNo` - (context info) the line number in source for expr
      `columnNo` - (context info) the column number in source for expr
      `oscript` - the expression to evaluate
    Throws:
      `BSFException` - if anything goes wrong while eval'ing a BSFException is thrown. The reason indicates the problem.

  - ### initialize

    public void initialize(BSFManager mgr, String lang, Vector declaredBeans) throws BSFException
    Initialize the engine. Put the manager into the context-manager map hashtable too.
    Specified by:
      `initialize` in interface `BSFEngine`
    Overrides:
      `initialize` in class `BSFEngineImpl`
    Parameters:
      `mgr` - The BSFManager that's hosting this engine.
      `lang` - Language string which this engine is handling.
      `declaredBeans` - Vector of BSFDeclaredObject containing beans that should be declared into the language runtime at init time as best as possible.
    Throws:
      `BSFException` - if anything goes wrong while init'ing a BSFException is thrown. The reason indicates the problem.

  - ### undeclareBean

    public void undeclareBean(BSFDeclaredBean bean) throws BSFException
    Description copied from interface: `BSFEngine`
    Undeclare a previously declared bean.
    Specified by:
      `undeclareBean` in interface `BSFEngine`
    Overrides:
      `undeclareBean` in class `BSFEngineImpl`
    Parameters:
      `bean` - the bean to undeclare
    Throws:
      `BSFException` - if the engine cannot do this operation