@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
Constructor and Description |
---|
FsProducer() |
Modifier and Type | Method and Description |
---|---|
protected void |
addProducerMetadata(AdaptrisMessage msg,
java.io.File destFile) |
protected java.io.File |
createTempFile(AdaptrisMessage msg) |
protected void |
doProduce(AdaptrisMessage msg,
java.lang.String baseUrl) |
java.lang.String |
endpoint(AdaptrisMessage msg)
Return the endpoint that will be derived from the message.
|
java.lang.String |
getBaseDirectoryUrl()
The base directory specified as a URL.
|
java.lang.Boolean |
getCreateDirs()
Specify whether to create directories that do not exist.
|
ProduceDestination |
getDestination()
Deprecated.
|
@NonNull FileNameCreator |
getFilenameCreator()
Sets the
FileNameCreator . |
@NonNull FsWorker |
getFsWorker()
The
FsWorker implementation to use when performing write operations. |
java.lang.String |
getTempDirectory()
The temporary directory for initially writing files to.
|
void |
prepare()
Prepare for initialisation.
|
void |
setBaseDirectoryUrl(java.lang.String baseDirectoryUrl)
The base directory specified as a URL.
|
void |
setCreateDirs(java.lang.Boolean createDirs)
Specify whether to create directories that do not exist.
|
void |
setDestination(ProduceDestination destination)
Deprecated.
|
void |
setFilenameCreator(@NonNull FileNameCreator filenameCreator)
Sets the
FileNameCreator . |
void |
setFsWorker(@NonNull FsWorker fsWorker)
The
FsWorker implementation to use when performing write operations. |
void |
setTempDirectory(java.lang.String tempDirectory)
The temporary directory for initially writing files to.
|
protected boolean |
shouldCreateDirs() |
protected void |
validateDir(java.net.URL url) |
<T extends FsProducer> |
withBaseDirectoryUrl(java.lang.String s) |
protected void |
write(AdaptrisMessage msg,
java.io.File destFile) |
produce, produce, request, request, request, request
createName
createQualifier, decode, encode, getEncoder, getIsTrackingEndpoint, getMessageFactory, getUniqueId, handleConnectionException, isTrackingEndpoint, registerConnection, registerEncoderMessageFactory, retrieveConnection, setEncoder, setIsTrackingEndpoint, setMessageFactory, setUniqueId, withMessageFactory, withUniqueID
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
decode, encode, getEncoder, getMessageFactory, handleConnectionException, registerConnection, retrieveConnection, setEncoder, setMessageFactory
getUniqueId
close, init, start, stop
createQualifier, isTrackingEndpoint
protected void doProduce(AdaptrisMessage msg, java.lang.String baseUrl) throws ProduceException
doProduce
in class ProduceOnlyProducerImp
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
protected boolean shouldCreateDirs()
public void prepare() throws CoreException
ComponentLifecycleExtension
CoreException
public java.lang.String endpoint(AdaptrisMessage msg) throws ProduceException
AdaptrisMessageProducerImp
The purpose of this method is to mitigate the number of changes that need to happen because
ProduceDestination
is being deprecated; boilerplate code can still be present in the
parent super-classes w/o impacting concrete sub-classes "too much".
endpoint
in class AdaptrisMessageProducerImp
ProduceException
AdaptrisMessageProducer.request(AdaptrisMessage, ProduceDestination)
,
AdaptrisMessageProducer.request(AdaptrisMessage, ProduceDestination, long)
,
AdaptrisMessageSender.produce(AdaptrisMessage)
,
AdaptrisMessageSender.produce(AdaptrisMessage, ProduceDestination)
public <T extends FsProducer> T withBaseDirectoryUrl(java.lang.String s)
public java.lang.Boolean getCreateDirs()
If this flag has been set, then an attempt to create the directory is made, if the directory
does not exist. The default is false
if not explicitly configured.
public void setCreateDirs(java.lang.Boolean createDirs)
If this flag has been set, then an attempt to create the directory is made, if the directory
does not exist. The default is false
if not explicitly configured.
public java.lang.String getTempDirectory()
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)
.
public void setTempDirectory(java.lang.String tempDirectory)
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)
.
@NonNull public @NonNull FsWorker getFsWorker()
public void setFsWorker(@NonNull @NonNull FsWorker fsWorker)
@NonNull public @NonNull FileNameCreator getFilenameCreator()
FileNameCreator
.
The default is FormattedFilenameCreator
if not explicitly configured
public void setFilenameCreator(@NonNull @NonNull FileNameCreator filenameCreator)
FileNameCreator
.
The default is FormattedFilenameCreator
if not explicitly configured
@Deprecated public ProduceDestination getDestination()
@Deprecated public void setDestination(ProduceDestination destination)
public java.lang.String getBaseDirectoryUrl()
public void setBaseDirectoryUrl(java.lang.String baseDirectoryUrl)