Home
Categories
Dictionary
Download
Project Details
Changes Log
FAQ
License

Script proxy



The ScriptProxy is the instance which is used by the framework to execute the script.

Script entities

There are 3 different entities used for the proxy:
  • The script object which is the instance corresponding with the script. This instance if directly generated by the language implementation used for the wrapper, and implements the script interface. This object can be retrieved by ScriptWrapper.getRawScript() but generally should not be used directly
  • The script proxy which also implements the script interface, but acts as a wrapper between the framework and the script raw instance. It allows to wrap the exceptions whch could be emitted by the script. This object can be retrieved by ScriptWrapper.getScript() and is generally the one which should be used
  • The proxy instance which manage how the wrapper is working. This object can be retrieved by ScriptWrapper.getScriptProxy()

Proxy configuration


The proxy instance returned by ScriptWrapper.getScriptProxy() has several configuration options:

Example

Suppose that we have the following interface:
      public interface Script {
        public int computeResult(int value);
      }
We can use this code to use a script which implements this interface:
      ScriptWrapper<Script> wrapper = new GroovyScriptWrapper<Script>() {};
      Script script = wrapper.getScript();

      File file = new File(<our script file>);
      wrapper.installScript(file);

      int value = script.computeResult(10);
Note that a script instance is not null even before any script has been installed, because this is a proxy to the effective script.

See also


Categories: api

Copyright 2019-2020 Herve Girod. All Rights Reserved. Documentation and source under the BSD licence