Package com.levigo.jadice.server.nodes
Class URLOutputNode
- java.lang.Object
-
- com.levigo.jadice.server.internal.NodeInternal
-
- com.levigo.jadice.server.Node
-
- com.levigo.jadice.server.nodes.URLOutputNode
-
public class URLOutputNode extends Node
ThisNode
writes out incoming streams the specified URL.As several incoming streams cause several resulting files, the filenames can be patternized:
- If it contains
SEQUENCE_NUMBER
this will be replaced by a sequential number per stream (i.e. 0..n ). - If it contains
STREAMDESCRIPTOR_FILENAME
this will be replaced by the filename that theStreamDescriptor
provides for particular stream.
See:StreamDescriptor.getFileName()
Currently, the only supported protocols are:
file
- stores the results on the server side
ftp
- uploads the result on an FTP server
As this node is a data sink it must not have a successor.
- If it contains
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
URLOutputNode.StreamListener
This listener will be informed whenever aStream
has been successfully written on the server side.-
Nested classes/interfaces inherited from class com.levigo.jadice.server.Node
Node.Cardinality
-
-
Field Summary
Fields Modifier and Type Field Description static String
SEQUENCE_NUMBER
Pattern that will be replaced by a sequence number.static String
STREAMDESCRIPTOR_FILENAME
Pattern that will be replaced by the filename given in theStreamDescriptor
.static String[]
SUPPORTED_PROTOCOLS
Protocols supported by this node.
-
Constructor Summary
Constructors Constructor Description URLOutputNode()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addStreamListener(URLOutputNode.StreamListener listener)
Adds a listener to be informed about aStream
been writtenURL
generateEffectiveURL(StreamDescriptor sd, String seqNumber)
Creates an URL for aStream
to write as specified in this node and replaces all patterns.String
getFileNamePattern()
Node.Cardinality
getOutputCardinality()
Return the output cardinality of this node, i.e.URL
getUrlPath()
String
getWorkerClassName()
Return the node's associatedcom.levigo.jadice.server.core.NodeWorker
full qualified class's name.protected void
initialize(CommunicationSide side)
boolean
isAllowOverwrite()
void
removeStreamListener(URLOutputNode.StreamListener listener)
Removes aURLOutputNode.StreamListener
for the events.void
setAllowOverwrite(boolean allowOverwrite)
Flag if it's allowed to overwrite already existing files (default:false
).void
setFileNamePattern(String fileNamePattern)
Set a pattern for the filename.void
setUrlPath(URL url)
Set the path of theURL
(without the filename)void
validate()
Tests if all parameters are valid.protected void
validateConfiguration()
-
Methods inherited from class com.levigo.jadice.server.Node
addTransportReceiver, appendSuccessor, apply, equals, getInputCardinality, getJob, getPredecessors, getSubsidiaryNodes, getSuccessors, getTransportSender, getUUID, hashCode, prependPredecessor, remove
-
-
-
-
Field Detail
-
SEQUENCE_NUMBER
public static final String SEQUENCE_NUMBER
Pattern that will be replaced by a sequence number.- See Also:
- Constant Field Values
-
STREAMDESCRIPTOR_FILENAME
public static final String STREAMDESCRIPTOR_FILENAME
Pattern that will be replaced by the filename given in theStreamDescriptor
.
-
SUPPORTED_PROTOCOLS
public static final String[] SUPPORTED_PROTOCOLS
Protocols supported by this node.
-
-
Method Detail
-
generateEffectiveURL
public URL generateEffectiveURL(StreamDescriptor sd, String seqNumber) throws MalformedURLException
Creates an URL for aStream
to write as specified in this node and replaces all patterns.- Parameters:
sd
- The StreamDescriptorseqNumber
- The sequence number of the Stream- Returns:
- The URI where so store the Stream
- Throws:
MalformedURLException
- If the given parameters are not valid
-
validate
public void validate() throws IllegalArgumentException
Tests if all parameters are valid.- Throws:
IllegalArgumentException
- if any of the parameters is not valid.
-
getWorkerClassName
public String getWorkerClassName()
Description copied from class:Node
Return the node's associatedcom.levigo.jadice.server.core.NodeWorker
full qualified class's name. By default, the worker class name is- The same as the node name with the trailing "Node" replaced by "Worker" if the node name ends in "Node"
- The node class name with an appended "Worker" otherwise.
This behavior can be overridden in concrete subclasses.
- Overrides:
getWorkerClassName
in classNode
- Returns:
- the full qualified class name of the worker of this node.
-
initialize
protected void initialize(CommunicationSide side)
- Overrides:
initialize
in classNode
-
getFileNamePattern
public String getFileNamePattern()
-
setFileNamePattern
public void setFileNamePattern(String fileNamePattern)
Set a pattern for the filename.Legal place holders are
SEQUENCE_NUMBER
andSTREAMDESCRIPTOR_FILENAME
.- Parameters:
fileNamePattern
- The pattern to set
-
isAllowOverwrite
public boolean isAllowOverwrite()
-
setAllowOverwrite
public void setAllowOverwrite(boolean allowOverwrite)
Flag if it's allowed to overwrite already existing files (default:false
). In such a case an error with MessageIDJS.SERVER.NODES-OVERWRITE_FORBIDDEN
will be raised.Implementation node: This flag is only respected when using the protocol
file
.- Parameters:
allowOverwrite
- files are allowed be be overwritten iff set totrue
-
getUrlPath
public URL getUrlPath()
-
setUrlPath
public void setUrlPath(URL url)
Set the path of theURL
(without the filename)- Parameters:
url
- the base URL.
-
getOutputCardinality
public Node.Cardinality getOutputCardinality()
Description copied from class:Node
Return the output cardinality of this node, i.e. how many bundles (not streams!) it expects to produce. By default, nodes are "pipe-style", i.e. one input, one output.- Overrides:
getOutputCardinality
in classNode
- Returns:
- output cardinality
-
validateConfiguration
protected void validateConfiguration() throws ConfigurationException
- Overrides:
validateConfiguration
in classNode
- Throws:
ConfigurationException
-
addStreamListener
public void addStreamListener(URLOutputNode.StreamListener listener)
Adds a listener to be informed about aStream
been written- Parameters:
listener
- The listener to add- Since:
- jadice server 5.4.2.0
-
removeStreamListener
public void removeStreamListener(URLOutputNode.StreamListener listener)
Removes aURLOutputNode.StreamListener
for the events.- Parameters:
listener
- The listener to remove- Since:
- jadice server 5.4.2.0
-
-