Class ScriptingService
- All Implemented Interfaces:
AdaptrisComponent,ComponentLifecycle,ComponentLifecycleExtension,ConfigComment,DynamicPollingTemplate.TemplateProvider,MessageEventGenerator,Service,StateManagedComponent
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.
-
Field Summary
Fields inherited from class com.adaptris.core.ServiceImp
log -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Reader@NonNull StringSet the contents of the script.protected voidvoidsetScriptContentEncoding(String scriptContentEncoding) voidsetScriptFilename(@NonNull String scriptFilename) Set the contents of the script.Methods inherited from class com.adaptris.core.scripting.services.ScriptingServiceImp
closeService, doService, getBranchingEnabled, getLanguage, isBranching, prepare, setBranchingEnabled, setLanguageMethods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, createName, createQualifier, enabled, getComments, getContinueOnFail, getEnabled, getIsTrackingEndpoint, getUniqueId, init, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setComments, setContinueOnFail, setEnabled, setIsTrackingEndpoint, setUniqueId, start, stopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.adaptris.core.AdaptrisComponent
getUniqueIdMethods inherited from interface com.adaptris.core.ComponentLifecycle
close, init, start, stopMethods inherited from interface com.adaptris.core.ConfigComment
getComments, setCommentsMethods inherited from interface com.adaptris.core.MessageEventGenerator
createName, createQualifier, isTrackingEndpointMethods inherited from interface com.adaptris.core.Service
continueOnFailure, enabled, setUniqueIdMethods inherited from interface com.adaptris.core.StateManagedComponent
changeState, requestClose, requestInit, requestStart, requestStop, retrieveComponentState
-
Constructor Details
-
ScriptingService
public ScriptingService() -
ScriptingService
-
-
Method Details
-
initService
- Overrides:
initServicein classScriptingServiceImp- Throws:
CoreException
-
createReader
- Specified by:
createReaderin classScriptingServiceImp- Throws:
IOException
-
getScriptFilename
Set the contents of the script. -
setScriptFilename
Set the contents of the script.- Parameters:
scriptFilename- the file name of the script to execute
-
getScriptContentEncoding
-
setScriptContentEncoding
- Parameters:
scriptContentEncoding- the encoding of the script file. Default to UTF-8
-