Class FsProducer
- java.lang.Object
-
- com.adaptris.core.AdaptrisMessageWorkerImp
-
- com.adaptris.core.AdaptrisMessageProducerImp
-
- com.adaptris.core.ProduceOnlyProducerImp
-
- com.adaptris.core.fs.FsProducer
-
- All Implemented Interfaces:
AdaptrisComponent
,AdaptrisMessageProducer
,AdaptrisMessageSender
,AdaptrisMessageWorker
,ComponentLifecycle
,ComponentLifecycleExtension
,MessageEventGenerator
- Direct Known Subclasses:
LargeFsProducer
@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.
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.AdaptrisMessageWorkerImp
log
-
-
Constructor Summary
Constructors Constructor Description FsProducer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.@NonNull FileNameCreator
getFilenameCreator()
Sets theFileNameCreator
.@NonNull FsWorker
getFsWorker()
TheFsWorker
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
setFilenameCreator(@NonNull FileNameCreator filenameCreator)
Sets theFileNameCreator
.void
setFsWorker(@NonNull FsWorker fsWorker)
TheFsWorker
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>
TwithBaseDirectoryUrl(java.lang.String s)
protected void
write(AdaptrisMessage msg, java.io.File destFile)
-
Methods inherited from class com.adaptris.core.ProduceOnlyProducerImp
produce, request, request
-
Methods inherited from class com.adaptris.core.AdaptrisMessageProducerImp
createName
-
Methods inherited from class com.adaptris.core.AdaptrisMessageWorkerImp
createQualifier, decode, encode, getEncoder, getIsTrackingEndpoint, getMessageFactory, getUniqueId, handleConnectionException, isTrackingEndpoint, registerConnection, registerEncoderMessageFactory, retrieveConnection, setEncoder, setIsTrackingEndpoint, setMessageFactory, setUniqueId, withMessageFactory, withUniqueID
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.AdaptrisComponent
getUniqueId
-
Methods inherited from interface com.adaptris.core.AdaptrisMessageWorker
decode, encode, getEncoder, getMessageFactory, handleConnectionException, registerConnection, retrieveConnection, setEncoder, setMessageFactory
-
Methods inherited from interface com.adaptris.core.ComponentLifecycle
close, init, start, stop
-
Methods inherited from interface com.adaptris.core.MessageEventGenerator
createQualifier, isTrackingEndpoint
-
-
-
-
Method Detail
-
doProduce
protected void doProduce(AdaptrisMessage msg, java.lang.String baseUrl) throws ProduceException
- Specified by:
doProduce
in classProduceOnlyProducerImp
- Throws:
ProduceException
-
addProducerMetadata
protected void addProducerMetadata(AdaptrisMessage msg, java.io.File destFile) throws java.io.IOException
- Throws:
java.io.IOException
-
write
protected void write(AdaptrisMessage msg, java.io.File destFile) throws java.lang.Exception
- Throws:
java.lang.Exception
-
createTempFile
protected java.io.File createTempFile(AdaptrisMessage msg) throws java.lang.Exception
- Throws:
java.lang.Exception
-
validateDir
protected void validateDir(java.net.URL url) throws java.io.IOException
- Throws:
java.io.IOException
-
shouldCreateDirs
protected boolean shouldCreateDirs()
-
prepare
public void prepare() throws CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Throws:
CoreException
-
endpoint
public java.lang.String endpoint(AdaptrisMessage msg) throws ProduceException
Description copied from class:AdaptrisMessageProducerImp
Return the endpoint that will be derived from the message.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".- Specified by:
endpoint
in classAdaptrisMessageProducerImp
- Throws:
ProduceException
- See Also:
AdaptrisMessageSender.produce(AdaptrisMessage)
-
withBaseDirectoryUrl
public <T extends FsProducer> T withBaseDirectoryUrl(java.lang.String s)
-
getCreateDirs
public java.lang.Boolean getCreateDirs()
Specify whether to create directories that do not exist.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.
-
setCreateDirs
public void setCreateDirs(java.lang.Boolean createDirs)
Specify whether to create directories that do not exist.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.
-
getTempDirectory
public java.lang.String getTempDirectory()
The temporary directory for initially writing files to.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)
.
-
setTempDirectory
public void setTempDirectory(java.lang.String tempDirectory)
The temporary directory for initially writing files to.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)
.
-
getFsWorker
@NonNull public @NonNull FsWorker getFsWorker()
-
setFsWorker
public void setFsWorker(@NonNull @NonNull FsWorker fsWorker)
-
getFilenameCreator
@NonNull public @NonNull FileNameCreator getFilenameCreator()
Sets theFileNameCreator
.The default is
FormattedFilenameCreator
if not explicitly configured
-
setFilenameCreator
public void setFilenameCreator(@NonNull @NonNull FileNameCreator filenameCreator)
Sets theFileNameCreator
.The default is
FormattedFilenameCreator
if not explicitly configured
-
getBaseDirectoryUrl
public java.lang.String getBaseDirectoryUrl()
The base directory specified as a URL.
-
setBaseDirectoryUrl
public void setBaseDirectoryUrl(java.lang.String baseDirectoryUrl)
The base directory specified as a URL.
-
-