javax.script
Interface Invocable


public interface Invocable

Optional interface implemented by ScriptEngines which allow the invocation of procedures in scripts that have previously been executed.

See Javadoc of Java Scripting API


Method Summary
 Object getInterface(Class clasz)
          Retrieves an instance of a java class whose methods are implemented using procedures in script which are in the intermediate code repository in the underlying interpreter.
 Object getInterface(Object thiz, Class clasz)
          Retrieves an instance of a java class whose methods are implemented using procedures in script which are in the intermediate code repository in the underlying interpreter.
 Object invokeFunction(String name, Object[] args)
          Invokes a scripting procedure with the given name using the array of objects as its arguments set.
 Object invokeMethod(Object thiz, String name, Object[] args)
          Invokes a procedure on an object which already defined in the script using the array of objects as its arguments set.
 

Method Detail

invokeFunction

Object invokeFunction(String name,
                      Object[] args)
                      throws ScriptException,
                             NoSuchMethodException
Invokes a scripting procedure with the given name using the array of objects as its arguments set.

Parameters:
name - name of the scripting procedure
args - arguments set for the scripting procedure
Returns:
resultant object after the execution of the procedure
Throws:
ScriptException - if the invocation of the scripting procedure fails
NoSuchMethodException - if method with given name or matching argument types cannot be found
NullPointerException - if the method name is null.

invokeMethod

Object invokeMethod(Object thiz,
                    String name,
                    Object[] args)
                    throws ScriptException,
                           NoSuchMethodException
Invokes a procedure on an object which already defined in the script using the array of objects as its arguments set.

Parameters:
thiz - object on which the procedure is called
name - name of the procedure to be invoked
args - arguments set for the procedure
Returns:
resultant object after the execution of the procedure
Throws:
ScriptException - if the invocation of the procedure fails
NoSuchMethodException - if a method with given name or matching argument types cannot be found
NullPointerException - if the method name is null.
IllegalArgumentException - if the specified thiz is null or the specified Object is does not represent a scripting object.

getInterface

Object getInterface(Class clasz)
Retrieves an instance of a java class whose methods are implemented using procedures in script which are in the intermediate code repository in the underlying interpreter.

Parameters:
clasz - an interface which the returned class must implement
Returns:
an instance of the class which implements the specified interface
Throws:
IllegalArgumentException - if the specified Class object is null or is not an interface

getInterface

Object getInterface(Object thiz,
                    Class clasz)
Retrieves an instance of a java class whose methods are implemented using procedures in script which are in the intermediate code repository in the underlying interpreter.

Parameters:
thiz - The scripting object whose member functions are used to implement the methods of the interface.
clasz - The Class object of the interface to return.
Returns:
An instance of requested interface. Will be null if the requested interface is unavailable, i.e. if compiled methods in the ScriptEngine cannot be found matching the ones in the requested interface.
Throws:
IllegalArgumentException - if the specified Class object is null or is not an interface, or if the specified Object is null or does not represent a scripting object.


Copyright © 1999-2012 The Apache Software Foundation. All Rights Reserved.