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 ServiceImpRead 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 interfaceReadFileService.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 voidcloseService()protected ReadFileService.ContentTypeProbecontentTypeProbe()voiddoService(AdaptrisMessage message)Apply the service to the message.java.lang.StringgetContentTypeMetadataKey()ReadFileService.ContentTypeProbegetContentTypeProbe()java.lang.StringgetFilePath()Get the file path parameter.protected voidinitService()voidprepare()Prepare for initialisation.voidsetContentTypeMetadataKey(java.lang.String contentTypeMetadataKey)Sets the metadata key set the content type as, if not provided will not be set.voidsetContentTypeProbe(ReadFileService.ContentTypeProbe contentTypeProbe)IfsetContentTypeMetadataKey(String)is set, then this interface is used to probe the content type of the file.voidsetFilePath(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:ServiceApply the service to the message.
- Parameters:
message- theAdaptrisMessageto process- Throws:
ServiceException- wrapping any underlyingExceptions
-
prepare
public void prepare() throws CoreExceptionDescription copied from interface:ComponentLifecycleExtensionPrepare for initialisation.- Throws:
CoreException
-
closeService
protected void closeService()
- Specified by:
closeServicein classServiceImp
-
initService
protected void initService() throws CoreException- Specified by:
initServicein 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-filesystemmodule.- 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()
-
-