Class JRubyScriptingContainer
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.jruby.JRubyScriptingContainer
-
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,DynamicPollingTemplate.TemplateProvider
,MessageEventGenerator
,Service
,StateManagedComponent
@ComponentProfile(summary="Execute a JRuby script stored on the filesystem/classpath", tag="service,scripting", branchSelector=true) public class JRubyScriptingContainer extends ServiceImp implements DynamicPollingTemplate.TemplateProvider
Execute a jruby script usingJRuby Embed Core
Scripting container.Rather than making use of the JSR223 bindings where things need to be controlled via system properties; this makes use of
ScriptingContainer
to execute your jruby scripts which allows more fine-grained control over the behaviour.In addition to specifying the script that works on the
AdaptrisMessage
object; you have the option of specifying scripts that should be executed as each part of the lifecycle phasesinit(), start(), stop(), close()
.The
service-script
will executed at runtime and the AdaptrisMessage that is due to be processed is bound as a variablemessage
. All executed scripts will have an instance of org.slf4j.Logger is also bound aslog
. These can be used as a standard variables within the script though of course you may need additional qualifiers if you specify a differentContainerBuilderImpl.getVariableBehaviour()
.In the adapter configuration file this class is aliased as jruby-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 Constructor Description JRubyScriptingContainer()
-
Method Summary
-
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
-
doService
public final void doService(AdaptrisMessage msg) throws ServiceException
- Specified by:
doService
in interfaceService
- Throws:
ServiceException
-
initService
protected void initService() throws CoreException
- Specified by:
initService
in classServiceImp
- Throws:
CoreException
-
closeService
protected void closeService()
- Specified by:
closeService
in classServiceImp
-
start
public void start() throws CoreException
- Specified by:
start
in interfaceComponentLifecycle
- Overrides:
start
in classServiceImp
- Throws:
CoreException
-
stop
public void stop()
- Specified by:
stop
in interfaceComponentLifecycle
- Overrides:
stop
in classServiceImp
-
prepare
public void prepare() throws CoreException
- Specified by:
prepare
in interfaceComponentLifecycleExtension
- Throws:
CoreException
-
isBranching
public boolean isBranching()
- Specified by:
isBranching
in interfaceService
- Overrides:
isBranching
in classServiceImp
-
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.- See Also:
Service.isBranching()
-
getBuilder
public ContainerBuilder getBuilder()
- Returns:
- the builder
-
setBuilder
public void setBuilder(ContainerBuilder builder)
- Parameters:
builder
- the builder to set
-
getInitScript
public ScriptWrapper getInitScript()
- Returns:
- the initScript
-
setInitScript
public void setInitScript(ScriptWrapper s)
Set the script to be executed uponComponentLifecycle.init()
.- Parameters:
s
- the initScript to set
-
getStartScript
public ScriptWrapper getStartScript()
- Returns:
- the startScript
-
setStartScript
public void setStartScript(ScriptWrapper s)
Set the script to be executed uponComponentLifecycle.start()
.- Parameters:
s
- the startScript to set
-
getStopScript
public ScriptWrapper getStopScript()
- Returns:
- the stopScript
-
setStopScript
public void setStopScript(ScriptWrapper s)
Set the script to be executed uponComponentLifecycle.stop()
.- Parameters:
s
- the stopScript to set
-
getCloseScript
public ScriptWrapper getCloseScript()
- Returns:
- the closeScript
-
setCloseScript
public void setCloseScript(ScriptWrapper s)
Set the script to be executed uponComponentLifecycle.close()
.- Parameters:
s
- the closeScript to set
-
getServiceScript
public ScriptWrapper getServiceScript()
- Returns:
- the serviceScript
-
setServiceScript
public void setServiceScript(ScriptWrapper s)
- Parameters:
s
- the serviceScript to execute as part ofdoService(AdaptrisMessage)
-
-