org.springframework.integration.adapter.file
Class AbstractFileMessageCreator<T>

java.lang.Object
  extended by org.springframework.integration.adapter.file.AbstractFileMessageCreator<T>
All Implemented Interfaces:
MessageCreator<java.io.File,T>
Direct Known Subclasses:
ByteArrayFileMessageCreator, FileMessageCreator, TextFileMessageCreator

public abstract class AbstractFileMessageCreator<T>
extends java.lang.Object
implements MessageCreator<java.io.File,T>

Base class providing common behavior for file-based message creators. The subclasses will redefine the readMessagePayload() method. This class allows to choose between keeping the file after message creation and removing it, by setting the appropriate value in the constructor. The desired behaviour depends on the nature of the created message (i.e. messages with a String payload can safely remove the file after creation, but messages with a File payload cannot do that) or of the collaborator that uses the class instance (e.g. if the file is a locally created copy, it can be always discarded).

Author:
Mark Fisher, Marius Bogoevici

Field Summary
private  boolean deleteFileAfterCreation
           
protected  org.apache.commons.logging.Log logger
           
 
Constructor Summary
AbstractFileMessageCreator(boolean deleteFileAfterCreation)
           
 
Method Summary
 Message<T> createMessage(java.io.File file)
           
protected abstract  T readMessagePayload(java.io.File file)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected org.apache.commons.logging.Log logger

deleteFileAfterCreation

private final boolean deleteFileAfterCreation
Constructor Detail

AbstractFileMessageCreator

public AbstractFileMessageCreator(boolean deleteFileAfterCreation)
Parameters:
deleteFileAfterCreation - Indicates whether the file should be deleted after the message has been created.
Method Detail

createMessage

public final Message<T> createMessage(java.io.File file)
Specified by:
createMessage in interface MessageCreator<java.io.File,T>

readMessagePayload

protected abstract T readMessagePayload(java.io.File file)
                                 throws java.lang.Exception
Throws:
java.lang.Exception