Interface StreamScriptContext
-
public interface StreamScriptContext
Scripts executed on a per stream basis (e.g. through theScriptNode
/ScriptWorker
) communicate with the server through this interface.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
debug(String message, Object... args)
Emit a debug message into the log if debugging is enabled.void
error(String message, Object... args)
Emit an error message into the log.void
error(String message, Throwable cause, Object... args)
Emit an error message into the log.void
error(org.jadice.util.log.qualified.MessageID messageId, Throwable cause, Object... args)
void
fail(String message, Object... args)
Abort the job giving the specified message as a reason.void
fail(String message, Throwable cause, Object... args)
Abort the job giving the specified message as a reason.void
fail(org.jadice.util.log.qualified.MessageID messageId, Throwable cause, Object... args)
Job
getClientJob()
Stream
getNextInput()
Get the next input stream.Map<String,Serializable>
getParameters()
ServerJob
getServerJob()
ScriptWorker
getWorker()
boolean
hasNextInput()
void
info(String message, Object... args)
Emit an info message into the log if info logging is enabled.void
loopback(Node input, Node output)
Process a sub-pipeline defined by the input and output node and loop back its output into the current node.void
loopback(Stream s)
Loop back the given stream into the current node.OutputStream
loopback(StreamDescriptor type)
void
loopback(Stream s, Node inputNode, Node outputNode)
void
loopback(InputStream is, StreamDescriptor type)
Loop back the given stream (described by the given stream descriptor) into the current node.void
loopback(List<Stream> s, Node inputNode, Node outputNode)
void
output(Node input, Node output)
Process a sub-pipeline defined by the input and output node.void
output(Stream s)
Output the given stream to down-stream nodes.OutputStream
output(StreamDescriptor type)
Create anOutputStream
described by the given stream descriptor which feeds into down-stream nodes.void
output(Stream s, Node inputNode, Node outputNode)
void
output(InputStream is, StreamDescriptor type)
Output the given stream (described by the given stream descriptor) to down-stream nodes.void
output(List<Stream> s, Node inputNode, Node outputNode)
StreamBundle
process(Node inputNode, Node outputNode)
Execute the sub-pipeline defined by the input and output node and return the result as aStreamBundle
.StreamBundle
process(Stream s, Node inputNode, Node outputNode)
StreamBundle
process(List<Stream> s, Node inputNode, Node outputNode)
void
warn(String message, Object... args)
Emit a warning message into the log.void
warn(String message, Throwable cause, Object... args)
Emit a warning message into the log.void
warn(org.jadice.util.log.qualified.MessageID messageId, Throwable cause, Object... args)
-
-
-
Method Detail
-
getNextInput
Stream getNextInput()
Get the next input stream.- Returns:
- the next input
Stream
ornull
if there are no more streams to be processed.
-
hasNextInput
boolean hasNextInput()
- Returns:
- true, if there is another
Stream
that waits for being processed - See Also:
getNextInput()
-
getWorker
ScriptWorker getWorker()
- Returns:
- The worker handling the current
ScriptNode
-
getServerJob
ServerJob getServerJob()
- Returns:
- The
ServerJob
associated with thisScriptNode
-
getClientJob
Job getClientJob()
- Returns:
- The client-side
Job
associated with thisScriptNode
-
getParameters
Map<String,Serializable> getParameters()
- Returns:
- The script parameters supplied by the client.
-
output
void output(Node input, Node output) throws Throwable
Process a sub-pipeline defined by the input and output node. The pipeline between input and output node may be of arbitrary complexity, and may even encompass splits and merges. After its initialization, the current stream is piped into the input node of the sub-pipeline while the output of the output node is forwarded down-stream.
-
output
void output(InputStream is, StreamDescriptor type) throws IOException
Output the given stream (described by the given stream descriptor) to down-stream nodes.- Parameters:
is
-InputStream
to be forwardedtype
- the associatedStreamDescriptor
- Throws:
IOException
- if initializing the forwarding fails
-
output
void output(Stream s)
Output the given stream to down-stream nodes.- Parameters:
s
- theStream
to be forwarded
-
output
OutputStream output(StreamDescriptor type) throws IOException
Create anOutputStream
described by the given stream descriptor which feeds into down-stream nodes.- Parameters:
type
- associatedStreamDescriptor
- Returns:
- an
OutputStream
that can be written to - Throws:
IOException
- if the creation of theOutputStream
fails
-
loopback
void loopback(Node input, Node output) throws Throwable
Process a sub-pipeline defined by the input and output node and loop back its output into the current node. The pipeline between input and output node may be of arbitrary complexity, and may even encompass splits and merges. After its initialization, the current stream is piped into the input node of the sub-pipeline while the output of the output node is looped back into the current node.
-
loopback
void loopback(InputStream is, StreamDescriptor type) throws IOException
Loop back the given stream (described by the given stream descriptor) into the current node.- Parameters:
is
-InputStream
to loopbacktype
- the associatedStreamDescriptor
- Throws:
IOException
- if initializing the loopback fails
-
loopback
void loopback(Stream s)
Loop back the given stream into the current node.- Parameters:
s
- theStream
to loopback
-
loopback
OutputStream loopback(StreamDescriptor type) throws IOException
- Parameters:
type
- associatedStreamDescriptor
- Returns:
- an
OutputStream
that can be written to - Throws:
IOException
- if the creation of theOutputStream
fails
-
process
StreamBundle process(Node inputNode, Node outputNode) throws Throwable
Execute the sub-pipeline defined by the input and output node and return the result as aStreamBundle
.- Parameters:
inputNode
- theNode
to be used as the input for the current streamoutputNode
- theNode
which' result shall be the return value of this method- Returns:
- the resulting
StreamBundle
of the sub-pipeline - Throws:
Throwable
- if the processing fails
-
debug
void debug(String message, Object... args)
Emit a debug message into the log if debugging is enabled. The given arguments (if any) are interpolated into the message according to the syntax specified inMessageFormat
.- Parameters:
message
- log messageargs
- optional parameters to be injected
-
info
void info(String message, Object... args)
Emit an info message into the log if info logging is enabled. The given arguments (if any) are interpolated into the message according to the syntax specified inMessageFormat
.- Parameters:
message
- log messageargs
- optional parameters to be injected
-
warn
void warn(String message, Object... args)
Emit a warning message into the log. The given arguments (if any) are interpolated into the message according to the syntax specified inMessageFormat
. The warning is also forwarded to anyJobListener
s of the current job.- Parameters:
message
- log messageargs
- optional parameters to be injected
-
warn
void warn(String message, Throwable cause, Object... args)
Emit a warning message into the log. The given arguments (if any) are interpolated into the message according to the syntax specified inMessageFormat
. The warning is also forwarded to anyJobListener
s of the current job. The message is accompanied with the givenThrowable
causing the warning.- Parameters:
message
- log messageargs
- optional parameters to be injectedcause
- aThrowable
to be associated with the message
-
error
void error(String message, Object... args)
Emit an error message into the log. The given arguments (if any) are interpolated into the message according to the syntax specified inMessageFormat
. The error message is also forwarded to anyJobListener
s of the current job.- Parameters:
message
- log messageargs
- optional parameters to be injected
-
error
void error(String message, Throwable cause, Object... args)
Emit an error message into the log. The given arguments (if any) are interpolated into the message according to the syntax specified inMessageFormat
. The error message is also forwarded to anyJobListener
s of the current job. The message is accompanied with the givenThrowable
causing the error.- Parameters:
message
- log messageargs
- optional parameters to be injectedcause
- aThrowable
to be associated with the message
-
fail
void fail(String message, Object... args)
Abort the job giving the specified message as a reason. The given arguments (if any) are interpolated into the message according to the syntax specified inMessageFormat
.- Parameters:
message
- log messageargs
- optional parameters to be injected
-
fail
void fail(String message, Throwable cause, Object... args)
Abort the job giving the specified message as a reason. The given arguments (if any) are interpolated into the message according to the syntax specified inMessageFormat
. The message is accompanied with the givenThrowable
causing the error.- Parameters:
message
- log messageargs
- optional parameters to be injectedcause
- aThrowable
to be associated with the message
-
loopback
void loopback(Stream s, Node inputNode, Node outputNode) throws Throwable
- Throws:
Throwable
-
process
StreamBundle process(Stream s, Node inputNode, Node outputNode) throws Throwable
- Throws:
Throwable
-
loopback
void loopback(List<Stream> s, Node inputNode, Node outputNode) throws Throwable
- Throws:
Throwable
-
output
void output(List<Stream> s, Node inputNode, Node outputNode) throws Throwable
- Throws:
Throwable
-
process
StreamBundle process(List<Stream> s, Node inputNode, Node outputNode) throws Throwable
- Throws:
Throwable
-
error
void error(org.jadice.util.log.qualified.MessageID messageId, Throwable cause, Object... args)
-
-