Class ScriptingService

All Implemented Interfaces:
AdaptrisComponent, ComponentLifecycle, ComponentLifecycleExtension, ConfigComment, DynamicPollingTemplate.TemplateProvider, MessageEventGenerator, Service, StateManagedComponent

@ComponentProfile(summary="Execute a JSR223 script stored on the filesystem", tag="service,scripting", branchSelector=true) public class ScriptingService extends ScriptingServiceImp
Supports arbitrary scripting languages that are supported by JSR223.

You should take care when configuring this class; it can present an audit trail issue when used in combination with DynamicServiceExecutor if your script executes arbitrary system commands. In that situation, all commands will be executed with the current users permissions and may be subject to the virtual machines security manager.

The script is executed and the AdaptrisMessage that is due to be processed is bound against the key "message" and an instance of org.slf4j.Logger is also bound to key "log". These can be used as a standard variable within the script.

Note that this class can be used as the selector as part of a BranchingServiceCollection. If used as such, then you need to remember to invoke AdaptrisMessage.setNextServiceId(String) as part of the script and ScriptingServiceImp.setBranchingEnabled(Boolean) should be true.

In the adapter configuration file this class is aliased as scripting-service which is the preferred alternative to the fully qualified classname when building your configuration.

  • Constructor Details

    • ScriptingService

      public ScriptingService()
    • ScriptingService

      public ScriptingService(String uniqueId)
  • Method Details

    • initService

      protected void initService() throws CoreException
      Overrides:
      initService in class ScriptingServiceImp
      Throws:
      CoreException
    • createReader

      protected Reader createReader() throws IOException
      Specified by:
      createReader in class ScriptingServiceImp
      Throws:
      IOException
    • getScriptFilename

      @NonNull public @NonNull String getScriptFilename()
      Set the contents of the script.
    • setScriptFilename

      public void setScriptFilename(@NonNull @NonNull String scriptFilename)
      Set the contents of the script.
      Parameters:
      scriptFilename - the file name of the script to execute
    • getScriptContentEncoding

      public String getScriptContentEncoding()
    • setScriptContentEncoding

      public void setScriptContentEncoding(String scriptContentEncoding)
      Parameters:
      scriptContentEncoding - the encoding of the script file. Default to UTF-8