Package com.adaptris.core.services
Class ReadFileService
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.services.ReadFileService
-
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,MessageEventGenerator
,Service
,StateManagedComponent
@ComponentProfile(summary="Read a file from a specific path into the message payload", tag="service,file") public class ReadFileService extends ServiceImp
Read a file from a specific path into the message payload.In the adapter configuration file this class is aliased as read-file-service which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ReadFileService.ContentTypeProbe
-
Field Summary
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description ReadFileService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
closeService()
protected ReadFileService.ContentTypeProbe
contentTypeProbe()
void
doService(AdaptrisMessage message)
Apply the service to the message.java.lang.String
getContentTypeMetadataKey()
ReadFileService.ContentTypeProbe
getContentTypeProbe()
java.lang.String
getFilePath()
Get the file path parameter.protected void
initService()
void
prepare()
Prepare for initialisation.void
setContentTypeMetadataKey(java.lang.String contentTypeMetadataKey)
Sets the metadata key set the content type as, if not provided will not be set.void
setContentTypeProbe(ReadFileService.ContentTypeProbe contentTypeProbe)
IfsetContentTypeMetadataKey(String)
is set, then this interface is used to probe the content type of the file.void
setFilePath(java.lang.String filePath)
Set the file path parameter.-
Methods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId, start, stop
-
-
-
-
Method Detail
-
doService
public void doService(AdaptrisMessage message) throws ServiceException
Description copied from interface:Service
Apply the service to the message.
- Parameters:
message
- theAdaptrisMessage
to process- Throws:
ServiceException
- wrapping any underlyingException
s
-
prepare
public void prepare() throws CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Throws:
CoreException
-
closeService
protected void closeService()
- Specified by:
closeService
in classServiceImp
-
initService
protected void initService() throws CoreException
- Specified by:
initService
in classServiceImp
- Throws:
CoreException
-
getFilePath
public java.lang.String getFilePath()
Get the file path parameter.- Returns:
- The file path parameter.
-
setFilePath
public void setFilePath(java.lang.String filePath)
Set the file path parameter.- Parameters:
filePath
- The file path parameter.
-
getContentTypeMetadataKey
public java.lang.String getContentTypeMetadataKey()
-
setContentTypeMetadataKey
public void setContentTypeMetadataKey(java.lang.String contentTypeMetadataKey)
Sets the metadata key set the content type as, if not provided will not be set. (default: null)- Parameters:
contentTypeMetadataKey
-
-
getContentTypeProbe
public ReadFileService.ContentTypeProbe getContentTypeProbe()
-
setContentTypeProbe
public void setContentTypeProbe(ReadFileService.ContentTypeProbe contentTypeProbe)
IfsetContentTypeMetadataKey(String)
is set, then this interface is used to probe the content type of the file.By default
Files.probeContentType(java.nio.file.Path)
is used which means no additional jars are required. This implementation is platform dependent; so an alternative is available in thecom.adaptris:interlok-filesystem
module.- Parameters:
contentTypeProbe
- how to probe for the content type; by default usesFiles.probeContentType(java.nio.file.Path)
if not explicitly configured.
-
contentTypeProbe
protected ReadFileService.ContentTypeProbe contentTypeProbe()
-
-