Home
Categories
Dictionary
Download
Project Details
Changes Log
FAQ
License

Running a script



There are two major xays of running a script:
  • Executing one of the methods of the interface defined for the wrapper
  • Invoking directly any of the script methods

Executing one of the methods of the interface

After or before having Installed a script, executing of of the methods of the ScriptWrapper interface can be performed by simply:
      <The interface class> scriptInterface = wrapper.getScriptProxy();
      scriptInterface.<executeOneMethod>
Note that a script instance is not null even before any script has been installed, because this is a proxy to the effective script.

For example, suppose the following script interface:
      public interface Script {
        public int computeResult(int value);
      }
We could perform:
      ScriptWrapper<Script> wrapper = new GroovyScriptWrapper<Script>() {
      };      
            
      Script script = wrapper.getScriptProxy();      
      File file = new File(<our script file>);
      wrapper.installScript(file);
      
      int result = script.computeResult(10);

Invoking directly a script method


Invoking directly any method (and not only those defined in the interface) in the script can be performed by calling one of the following methods:

See also


Categories: api

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