@ComponentProfile(summary="Write the current message to the filesystem", tag="producer,fs,filesystem", recommended=NullConnection.class, metadata={"producedname","fsProduceDir"}) public class FsProducer extends ProduceOnlyProducerImp
AdaptrisMessageProducer
implementation that writes to the file system.In the adapter configuration file this class is aliased as fs-producer which is the preferred alternative to the fully qualified classname when building your configuration.
log
CONFIRMATION_ID_KEY
Constructor and Description |
---|
FsProducer() |
FsProducer(ProduceDestination d) |
Modifier and Type | Method and Description |
---|---|
protected void |
addProducerMetadata(AdaptrisMessage msg,
java.io.File destFile) |
void |
close()
Closes the component.
|
protected java.io.File |
createTempFile(AdaptrisMessage msg) |
protected void |
doProduce(AdaptrisMessage msg,
java.lang.String baseUrl) |
java.lang.Boolean |
getCreateDirs()
Get the flag specifying creation of directories as required..
|
FileNameCreator |
getFilenameCreator() |
FsWorker |
getFsWorker()
Get the
FsWorker implementation. |
java.lang.String |
getTempDirectory() |
void |
init()
Initialises the component.
|
void |
prepare()
Prepare for initialisation.
|
void |
produce(AdaptrisMessage msg,
ProduceDestination overload)
Produce the
AdaptrisMessage to the supplied ProduceDestination , over-riding any configured destinations. |
void |
setCreateDirs(java.lang.Boolean b)
Specify whether to create directories that do not exist.
|
void |
setFilenameCreator(FileNameCreator creator)
Sets the
FileNameCreator to use. |
void |
setFsWorker(FsWorker fw)
Set the
FsWorker implementation to use when performing write operations. |
void |
setTempDirectory(java.lang.String s)
Set the temporary directory for initially writing files to.
|
boolean |
shouldCreateDirs() |
void |
start()
Starts the component.
|
void |
stop()
Stop the component
|
protected void |
validateDir(java.net.URL url) |
protected void |
write(AdaptrisMessage msg,
java.io.File destFile) |
produce, request, request, request, request
getDestination, setDestination
createName, createQualifier, decode, encode, getEncoder, getIsTrackingEndpoint, getMessageFactory, getUniqueId, handleConnectionException, isTrackingEndpoint, registerConnection, registerEncoderMessageFactory, retrieveConnection, setEncoder, setIsTrackingEndpoint, setMessageFactory, setUniqueId, withMessageFactory
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
decode, encode, getEncoder, getMessageFactory, handleConnectionException, registerConnection, retrieveConnection, setEncoder, setMessageFactory
getUniqueId
createName, createQualifier, isTrackingEndpoint
public FsProducer()
public FsProducer(ProduceDestination d)
public void init() throws CoreException
ComponentLifecycle
Component initialisation includes config verification, creation of connections etc.
CoreException
- wrapping any underlying Exception
sComponentLifecycle.init()
public void start() throws CoreException
ComponentLifecycle
Once a component is started it should be ready to process messages. In the case of AdaptrisMessageConsumer
, calling start
will begin message delivery.
CoreException
- wrapping any underlying Exception
sComponentLifecycle.start()
public void stop()
ComponentLifecycle
A stopped component is not expected to be ready to process messages. In the case of AdaptrisMessageConsumer
, calling stop
will pause message delivery. Throwing a RuntimeException
may cause unintended consequences
ComponentLifecycle.stop()
public void close()
ComponentLifecycle
A closed component should release any connections it uses, etc. and clean up completely. Throwing a RuntimeException
may
cause unintended consequences
ComponentLifecycle.close()
public void produce(AdaptrisMessage msg, ProduceDestination overload) throws ProduceException
AdaptrisMessageSender
AdaptrisMessage
to the supplied ProduceDestination
, over-riding any configured destinations.msg
- the AdaptrisMessage
to produceoverload
- the ProduceDestination
to produce toProduceException
- wrapping any underlying Exceptions#produce(AdaptrisMessage, ProduceDestination)
protected void doProduce(AdaptrisMessage msg, java.lang.String baseUrl) throws ProduceException
ProduceException
protected void addProducerMetadata(AdaptrisMessage msg, java.io.File destFile) throws java.io.IOException
java.io.IOException
protected void write(AdaptrisMessage msg, java.io.File destFile) throws java.lang.Exception
java.lang.Exception
protected java.io.File createTempFile(AdaptrisMessage msg) throws java.lang.Exception
java.lang.Exception
protected void validateDir(java.net.URL url) throws java.io.IOException
java.io.IOException
public void setCreateDirs(java.lang.Boolean b)
When the ProduceDestination returns a destination, if this flag has been set, then an attempt to create the directory is made, if the directory does not exist.
b
- true to enable directory creation, default falsepublic java.lang.Boolean getCreateDirs()
shouldCreateDirs()
public boolean shouldCreateDirs()
public java.lang.String getTempDirectory()
public void setTempDirectory(java.lang.String s)
In some instances, for instance, writing to network shares, it may be preferable to initial write to a temporary directory and
then move the resulting file to the final location. Setting this to a non-null value will cause a temporary file to be created
in this directory; this is then renamed to the correct location using File.renameTo(File)
.
s
- the tempDirectory to setpublic FsWorker getFsWorker()
FsWorker
implementation.FsWorker
implementation.public void setFsWorker(FsWorker fw)
FsWorker
implementation to use when performing write operations.fw
- the fsWorker implementation, default NioWorker
public FileNameCreator getFilenameCreator()
public void setFilenameCreator(FileNameCreator creator)
Sets the FileNameCreator
to use. May not be null.
creator
- the FileNameCreator
to use, default is FormattedFilenameCreator
public void prepare() throws CoreException
ComponentLifecycleExtension
CoreException