Class ScriptingService
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.services.ScriptingServiceImp
-
- com.adaptris.core.services.ScriptingService
-
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,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 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 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 ScriptingService()
ScriptingService(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
getScriptFilename()
protected void
initService()
void
prepare()
Prepare for initialisation.void
setScriptFilename(java.lang.String s)
Set the contents of the script.-
Methods inherited from class com.adaptris.core.services.ScriptingServiceImp
checkEngine, closeService, doService, getBranchingEnabled, getLanguage, isBranching, 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
-
getScriptFilename
public java.lang.String getScriptFilename()
-
setScriptFilename
public void setScriptFilename(java.lang.String s)
Set the contents of the script.- Parameters:
s
- the script
-
initService
protected void initService() throws CoreException
- Overrides:
initService
in classScriptingServiceImp
- Throws:
CoreException
-
createReader
protected java.io.Reader createReader() throws java.io.IOException
- Specified by:
createReader
in classScriptingServiceImp
- Throws:
java.io.IOException
-
prepare
public void prepare() throws CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Specified by:
prepare
in interfaceComponentLifecycleExtension
- Overrides:
prepare
in classScriptingServiceImp
- Throws:
CoreException
-
-