Package com.adaptris.core.services
Class ScriptingServiceImp
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.services.ScriptingServiceImp
-
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,DynamicPollingTemplate.TemplateProvider
,MessageEventGenerator
,Service
,StateManagedComponent
- Direct Known Subclasses:
EmbeddedScriptingService
,ScriptingService
public abstract class ScriptingServiceImp extends ServiceImp implements DynamicPollingTemplate.TemplateProvider
Base class for enabling JSR223 enabled scripting languages.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
GRAAL_JS_ENGINE
protected static java.lang.String
NASHORN
protected static java.lang.String
NASHORN_ENGINE
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description ScriptingServiceImp()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
checkEngine(javax.script.ScriptEngineManager engineManager)
protected void
closeService()
protected abstract java.io.Reader
createReader()
void
doService(AdaptrisMessage msg)
Apply the service to the message.java.lang.Boolean
getBranchingEnabled()
java.lang.String
getLanguage()
protected void
initService()
boolean
isBranching()
Returns true if the implementation supports branching.void
prepare()
Prepare for initialisation.void
setBranchingEnabled(java.lang.Boolean branching)
Specify whether or not this service is branching.void
setLanguage(java.lang.String s)
Set the language the the script is written in.void
start()
Starts the component.void
stop()
Stop the component-
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
-
-
-
-
Field Detail
-
NASHORN_ENGINE
protected static final java.lang.String NASHORN_ENGINE
- See Also:
- Constant Field Values
-
GRAAL_JS_ENGINE
protected static final java.lang.String GRAAL_JS_ENGINE
- See Also:
- Constant Field Values
-
NASHORN
protected static final java.lang.String NASHORN
- See Also:
- Constant Field Values
-
-
Method Detail
-
doService
public final void doService(AdaptrisMessage msg) throws ServiceException
Description copied from interface:Service
Apply the service to the message.
- Specified by:
doService
in interfaceService
- Parameters:
msg
- theAdaptrisMessage
to process- Throws:
ServiceException
- wrapping any underlyingException
s
-
createReader
protected abstract java.io.Reader createReader() throws java.io.IOException
- Throws:
java.io.IOException
-
initService
protected void initService() throws CoreException
- Specified by:
initService
in classServiceImp
- Throws:
CoreException
-
checkEngine
protected final void checkEngine(javax.script.ScriptEngineManager engineManager)
-
closeService
protected void closeService()
- Specified by:
closeService
in classServiceImp
-
start
public void start() throws CoreException
Description copied from interface:ComponentLifecycle
Starts the component.Once a component is started it should be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling start will begin message delivery.- Specified by:
start
in interfaceComponentLifecycle
- Overrides:
start
in classServiceImp
- Throws:
CoreException
- wrapping any underlyingException
s
-
stop
public void stop()
Description copied from interface:ComponentLifecycle
Stop the componentA stopped component is not expected to be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling stop will pause message delivery. Throwing aRuntimeException
may cause unintended consequences- Specified by:
stop
in interfaceComponentLifecycle
- Overrides:
stop
in classServiceImp
-
getLanguage
public java.lang.String getLanguage()
-
setLanguage
public void setLanguage(java.lang.String s)
Set the language the the script is written in.- Parameters:
s
- a JSR223 supported language.
-
prepare
public void prepare() throws CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Specified by:
prepare
in interfaceComponentLifecycleExtension
- Throws:
CoreException
-
isBranching
public boolean isBranching()
Description copied from interface:Service
Returns true if the implementation supports branching.
- Specified by:
isBranching
in interfaceService
- Overrides:
isBranching
in classServiceImp
- Returns:
- true if the implementation supports branching
- See Also:
BranchingServiceCollection
-
getBranchingEnabled
public java.lang.Boolean getBranchingEnabled()
-
setBranchingEnabled
public void setBranchingEnabled(java.lang.Boolean branching)
Specify whether or not this service is branching.- Parameters:
branching
- true to causeisBranching()
to return true; default is false.- Since:
- 3.4.0
- See Also:
Service.isBranching()
-
-