Class EmbeddedScriptingService
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.services.ScriptingServiceImp
-
- com.adaptris.core.services.EmbeddedScriptingService
-
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,DynamicPollingTemplate.TemplateProvider
,MessageEventGenerator
,Service
,StateManagedComponent
@ComponentProfile(summary="Execute an embedded JSR223 script", tag="service,scripting", branchSelector=true) public class EmbeddedScriptingService extends ScriptingServiceImp
Supports arbitary scripting languges 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 invokeAdaptrisMessage.setNextServiceId(String)
as part of the script andScriptingServiceImp.setBranchingEnabled(Boolean)
should be true.In the adapter configuration file this class is aliased as embedded-scripting-service which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.services.ScriptingServiceImp
GRAAL_JS_ENGINE, NASHORN, NASHORN_ENGINE
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description EmbeddedScriptingService()
EmbeddedScriptingService(java.lang.String uniqueId)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.io.Reader
createReader()
java.lang.String
getScript()
void
setScript(java.lang.String s)
Set the contents of the script.EmbeddedScriptingService
withScript(java.lang.String lang, java.lang.String script)
-
Methods inherited from class com.adaptris.core.services.ScriptingServiceImp
checkEngine, closeService, doService, getBranchingEnabled, getLanguage, initService, isBranching, prepare, setBranchingEnabled, setLanguage, start, stop
-
Methods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.AdaptrisComponent
getUniqueId
-
Methods inherited from interface com.adaptris.core.ComponentLifecycle
close, init
-
Methods inherited from interface com.adaptris.core.MessageEventGenerator
createName, createQualifier, isTrackingEndpoint
-
Methods inherited from interface com.adaptris.core.Service
continueOnFailure, setUniqueId
-
Methods inherited from interface com.adaptris.core.StateManagedComponent
changeState, requestClose, requestInit, requestStart, requestStop, retrieveComponentState
-
-
-
-
Method Detail
-
getScript
public java.lang.String getScript()
-
setScript
public void setScript(java.lang.String s)
Set the contents of the script.- Parameters:
s
- the script
-
createReader
protected java.io.Reader createReader()
- Specified by:
createReader
in classScriptingServiceImp
-
withScript
public EmbeddedScriptingService withScript(java.lang.String lang, java.lang.String script)
-
-