Class SystemCommandExecutorService
java.lang.Object
com.adaptris.core.ServiceImp
com.adaptris.core.services.system.SystemCommandExecutorService
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,ConfigComment
,MessageEventGenerator
,Service
,StateManagedComponent
@ComponentProfile(summary="Execute an arbitrary system command (DANGER!)",
tag="service")
public class SystemCommandExecutorService
extends ServiceImp
Service that runs the specified system executable with the provided arguments, optionally
capturing the output.
Note that no checking is peformed on the command to be executed; it will be executed as-is. If
used in combination with DynamicServiceExecutor
then
you might have a large security hole if it is improperly configured or validated.
The following behaviour is non-configurable:
- The exitcode is stored against the metadata key "SystemCommandExecutorService.ReturnValue" if the service does not throw an exception.
- If a timeout occurs then a ServiceException is thrown, output that was captured before the timeout should still be available
In the adapter configuration file this class is aliased as system-command-executor 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
ConstructorDescriptionSystemCommandExecutorService
(CommandBuilder builder, CommandOutputCapture capture) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
void
doService
(AdaptrisMessage msg) Invokes the command line executableprotected void
void
prepare()
Prepare for initialisation.void
setCommandBuilder
(CommandBuilder builder) Set the command builder.void
setOutputCapture
(CommandOutputCapture outputCapture) void
Specifies a maximum time for the executable to run, after which it will be terminated.Methods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, createName, createQualifier, getComments, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setComments, setContinueOnFail, setIsTrackingEndpoint, setUniqueId, start, stop
-
Field Details
-
COMMAND_RETURN_VALUE_METADATA_KEY
- See Also:
-
-
Constructor Details
-
SystemCommandExecutorService
public SystemCommandExecutorService() -
SystemCommandExecutorService
-
-
Method Details
-
doService
Invokes the command line executable- Parameters:
msg
- theAdaptrisMessage
to process- Throws:
ServiceException
- wrapping any underlyingException
s- See Also:
-
initService
- Specified by:
initService
in classServiceImp
- Throws:
CoreException
-
closeService
protected void closeService()- Specified by:
closeService
in classServiceImp
-
getCommandBuilder
-
setCommandBuilder
Set the command builder.- Parameters:
builder
- theCommandBuilder
implementation- See Also:
-
prepare
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Throws:
CoreException
-
setTimeout
Specifies a maximum time for the executable to run, after which it will be terminated.- Parameters:
t
- the timeout; default if not configured is 30 seconds.
-
getTimeout
-
getOutputCapture
-
setOutputCapture
-