org.apache.camel.component.file
Class GenericFileEndpoint<T>

java.lang.Object
  extended by org.apache.camel.impl.DefaultEndpoint
      extended by org.apache.camel.impl.ScheduledPollEndpoint
          extended by org.apache.camel.component.file.GenericFileEndpoint<T>
All Implemented Interfaces:
CamelContextAware, Endpoint, IsSingleton, Service, HasId
Direct Known Subclasses:
FileEndpoint

public abstract class GenericFileEndpoint<T>
extends ScheduledPollEndpoint

Generic FileEndpoint


Field Summary
protected  boolean autoCreate
           
protected  int bufferSize
           
protected  String charset
           
protected  GenericFileConfiguration configuration
           
protected static int DEFAULT_IDEMPOTENT_CACHE_SIZE
           
protected static String DEFAULT_STRATEGYFACTORY_CLASS
           
protected  boolean delete
           
protected  boolean directoryMustExist
           
protected  boolean eagerDeleteTargetFile
           
protected  String exclude
           
protected  GenericFileExclusiveReadLockStrategy<T> exclusiveReadLockStrategy
           
protected  GenericFileExist fileExist
           
protected  Expression fileName
           
protected  GenericFileFilter<T> filter
           
protected  boolean flatten
           
protected  Boolean idempotent
           
protected  IdempotentRepository<String> idempotentRepository
           
protected  String include
           
protected  IdempotentRepository<String> inProgressRepository
           
protected  boolean keepLastModified
           
protected  String localWorkDirectory
           
protected  org.apache.commons.logging.Log log
           
protected  int maxMessagesPerPoll
           
protected  Expression move
           
protected  Expression moveFailed
           
protected  boolean noop
           
protected  Expression preMove
           
protected  GenericFileProcessStrategy<T> processStrategy
           
protected  String readLock
           
protected  long readLockTimeout
           
protected  boolean recursive
           
protected  Comparator<Exchange> sortBy
           
protected  Comparator<GenericFile<T>> sorter
           
protected  boolean startingDirectoryMustExist
           
protected  Expression tempFileName
           
protected  String tempPrefix
           
 
Constructor Summary
GenericFileEndpoint()
           
GenericFileEndpoint(String endpointUri, Component component)
           
 
Method Summary
 void configureExchange(Exchange exchange)
          Set up the exchange properties with the options of the file endpoint
 void configureMessage(GenericFile<T> file, Message message)
          Configures the given message with the file which sets the body to the file object.
protected  String configureMoveOrPreMoveExpression(String expression)
          Strategy to configure the move or premove option based on a String input.
abstract  GenericFileConsumer<T> createConsumer(Processor processor)
          Creates a new Event Driven Consumer which consumes messages from the endpoint using the given processor
abstract  Exchange createExchange(GenericFile<T> file)
           
protected  GenericFileProcessStrategy<T> createGenericFileStrategy()
          A strategy method to lazily create the file strategy
abstract  GenericFileProducer<T> createProducer()
          Creates a new producer which is used send messages into the endpoint
 int getBufferSize()
           
 String getCharset()
           
 GenericFileConfiguration getConfiguration()
           
 String getExclude()
           
 GenericFileExclusiveReadLockStrategy<T> getExclusiveReadLockStrategy()
           
 GenericFileExist getFileExist()
           
 Expression getFileName()
           
abstract  char getFileSeparator()
           
 GenericFileFilter<T> getFilter()
           
 String getGeneratedFileName(Message message)
          Return the file name that will be auto-generated for the given message if none is provided
 GenericFileProcessStrategy<T> getGenericFileProcessStrategy()
           
 IdempotentRepository<String> getIdempotentRepository()
           
 String getInclude()
           
 IdempotentRepository<String> getInProgressRepository()
           
 String getLocalWorkDirectory()
           
 int getMaxMessagesPerPoll()
           
 Expression getMove()
           
 Expression getMoveFailed()
           
protected  Map<String,Object> getParamsAsMap()
           
 Expression getPreMove()
           
 GenericFileProcessStrategy<T> getProcessStrategy()
           
 String getReadLock()
           
 long getReadLockTimeout()
           
abstract  String getScheme()
           
 Comparator<Exchange> getSortBy()
           
 Comparator<GenericFile<T>> getSorter()
           
 Expression getTempFileName()
           
 String getTempPrefix()
           
abstract  boolean isAbsolute(String name)
           
 boolean isAutoCreate()
           
 boolean isDelete()
           
 boolean isDirectoryMustExist()
           
 boolean isEagerDeleteTargetFile()
           
 boolean isFlatten()
           
 Boolean isIdempotent()
           
 boolean isKeepLastModified()
           
 boolean isNoop()
           
 boolean isRecursive()
           
 boolean isSingleton()
          Whether this class supports being singleton or not.
 boolean isStartingDirectoryMustExist()
           
 void setAutoCreate(boolean autoCreate)
           
 void setBufferSize(int bufferSize)
           
 void setCharset(String charset)
           
 void setConfiguration(GenericFileConfiguration configuration)
           
 void setDelete(boolean delete)
           
 void setDirectoryMustExist(boolean directoryMustExist)
           
 void setEagerDeleteTargetFile(boolean eagerDeleteTargetFile)
           
 void setExclude(String exclude)
           
 void setExclusiveReadLockStrategy(GenericFileExclusiveReadLockStrategy<T> exclusiveReadLockStrategy)
           
 void setFileExist(GenericFileExist fileExist)
           
 void setFileName(Expression fileName)
           
 void setFileName(String fileLanguageExpression)
          Sets the file expression based on SimpleLanguage
 void setFilter(GenericFileFilter<T> filter)
           
 void setFlatten(boolean flatten)
           
 void setIdempotent(Boolean idempotent)
           
 void setIdempotentRepository(IdempotentRepository<String> idempotentRepository)
           
 void setInclude(String include)
           
 void setInProgressRepository(IdempotentRepository<String> inProgressRepository)
           
 void setKeepLastModified(boolean keepLastModified)
           
 void setLocalWorkDirectory(String localWorkDirectory)
           
 void setMaxMessagesPerPoll(int maxMessagesPerPoll)
           
 void setMove(Expression move)
           
 void setMove(String fileLanguageExpression)
          Sets the move expression based on SimpleLanguage
 void setMoveFailed(Expression moveFailed)
           
 void setMoveFailed(String fileLanguageExpression)
          Sets the move failure expression based on SimpleLanguage
 void setNoop(boolean noop)
           
 void setPreMove(Expression preMove)
           
 void setPreMove(String fileLanguageExpression)
          Sets the pre move expression based on SimpleLanguage
 void setProcessStrategy(GenericFileProcessStrategy<T> processStrategy)
           
 void setReadLock(String readLock)
           
 void setReadLockTimeout(long readLockTimeout)
           
 void setRecursive(boolean recursive)
           
 void setSortBy(Comparator<Exchange> sortBy)
           
 void setSortBy(String expression)
           
 void setSortBy(String expression, boolean reverse)
           
 void setSorter(Comparator<GenericFile<T>> sorter)
           
 void setStartingDirectoryMustExist(boolean startingDirectoryMustExist)
           
 void setTempFileName(Expression tempFileName)
           
 void setTempFileName(String tempFileNameExpression)
           
 void setTempPrefix(String tempPrefix)
          Enables and uses temporary prefix when writing files, after write it will be renamed to the correct name.
 
Methods inherited from class org.apache.camel.impl.ScheduledPollEndpoint
configureConsumer, configureProperties, getConsumerProperties, setConsumerProperties
 
Methods inherited from class org.apache.camel.impl.DefaultEndpoint
createEndpointUri, createExchange, createExchange, createExchange, createPollingConsumer, equals, getCamelContext, getComponent, getEndpointKey, getEndpointUri, getExchangePattern, getExchangeType, getId, hashCode, isLenientProperties, isSynchronous, sanitizeUri, setCamelContext, setEndpointUri, setEndpointUriIfNotSpecified, setExchangePattern, setSynchronous, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_STRATEGYFACTORY_CLASS

protected static final transient String DEFAULT_STRATEGYFACTORY_CLASS
See Also:
Constant Field Values

DEFAULT_IDEMPOTENT_CACHE_SIZE

protected static final transient int DEFAULT_IDEMPOTENT_CACHE_SIZE
See Also:
Constant Field Values

log

protected final transient org.apache.commons.logging.Log log

processStrategy

protected GenericFileProcessStrategy<T> processStrategy

configuration

protected GenericFileConfiguration configuration

inProgressRepository

protected IdempotentRepository<String> inProgressRepository

localWorkDirectory

protected String localWorkDirectory

autoCreate

protected boolean autoCreate

startingDirectoryMustExist

protected boolean startingDirectoryMustExist

directoryMustExist

protected boolean directoryMustExist

bufferSize

protected int bufferSize

fileExist

protected GenericFileExist fileExist

noop

protected boolean noop

recursive

protected boolean recursive

delete

protected boolean delete

flatten

protected boolean flatten

maxMessagesPerPoll

protected int maxMessagesPerPoll

tempPrefix

protected String tempPrefix

tempFileName

protected Expression tempFileName

eagerDeleteTargetFile

protected boolean eagerDeleteTargetFile

include

protected String include

exclude

protected String exclude

charset

protected String charset

fileName

protected Expression fileName

move

protected Expression move

moveFailed

protected Expression moveFailed

preMove

protected Expression preMove

idempotent

protected Boolean idempotent

idempotentRepository

protected IdempotentRepository<String> idempotentRepository

filter

protected GenericFileFilter<T> filter

sorter

protected Comparator<GenericFile<T>> sorter

sortBy

protected Comparator<Exchange> sortBy

readLock

protected String readLock

readLockTimeout

protected long readLockTimeout

exclusiveReadLockStrategy

protected GenericFileExclusiveReadLockStrategy<T> exclusiveReadLockStrategy

keepLastModified

protected boolean keepLastModified
Constructor Detail

GenericFileEndpoint

public GenericFileEndpoint()

GenericFileEndpoint

public GenericFileEndpoint(String endpointUri,
                           Component component)
Method Detail

isSingleton

public boolean isSingleton()
Description copied from interface: IsSingleton
Whether this class supports being singleton or not.

Returns:
true to be a single shared instance, false to create new instances.

createConsumer

public abstract GenericFileConsumer<T> createConsumer(Processor processor)
                                               throws Exception
Description copied from interface: Endpoint
Creates a new Event Driven Consumer which consumes messages from the endpoint using the given processor

Parameters:
processor - the given processor
Returns:
a newly created consumer
Throws:
Exception - can be thrown

createProducer

public abstract GenericFileProducer<T> createProducer()
                                               throws Exception
Description copied from interface: Endpoint
Creates a new producer which is used send messages into the endpoint

Returns:
a newly created producer
Throws:
Exception - can be thrown

createExchange

public abstract Exchange createExchange(GenericFile<T> file)

getScheme

public abstract String getScheme()

getFileSeparator

public abstract char getFileSeparator()

isAbsolute

public abstract boolean isAbsolute(String name)

getGeneratedFileName

public String getGeneratedFileName(Message message)
Return the file name that will be auto-generated for the given message if none is provided


getGenericFileProcessStrategy

public GenericFileProcessStrategy<T> getGenericFileProcessStrategy()

createGenericFileStrategy

protected GenericFileProcessStrategy<T> createGenericFileStrategy()
A strategy method to lazily create the file strategy


isNoop

public boolean isNoop()

setNoop

public void setNoop(boolean noop)

isRecursive

public boolean isRecursive()

setRecursive

public void setRecursive(boolean recursive)

getInclude

public String getInclude()

setInclude

public void setInclude(String include)

getExclude

public String getExclude()

setExclude

public void setExclude(String exclude)

isDelete

public boolean isDelete()

setDelete

public void setDelete(boolean delete)

isFlatten

public boolean isFlatten()

setFlatten

public void setFlatten(boolean flatten)

getMove

public Expression getMove()

setMove

public void setMove(Expression move)

setMoveFailed

public void setMoveFailed(String fileLanguageExpression)
Sets the move failure expression based on SimpleLanguage


getMoveFailed

public Expression getMoveFailed()

setMoveFailed

public void setMoveFailed(Expression moveFailed)

setMove

public void setMove(String fileLanguageExpression)
Sets the move expression based on SimpleLanguage


getPreMove

public Expression getPreMove()

setPreMove

public void setPreMove(Expression preMove)

setPreMove

public void setPreMove(String fileLanguageExpression)
Sets the pre move expression based on SimpleLanguage


getFileName

public Expression getFileName()

setFileName

public void setFileName(Expression fileName)

setFileName

public void setFileName(String fileLanguageExpression)
Sets the file expression based on SimpleLanguage


isIdempotent

public Boolean isIdempotent()

getCharset

public String getCharset()

setCharset

public void setCharset(String charset)

setIdempotent

public void setIdempotent(Boolean idempotent)

getIdempotentRepository

public IdempotentRepository<String> getIdempotentRepository()

setIdempotentRepository

public void setIdempotentRepository(IdempotentRepository<String> idempotentRepository)

getFilter

public GenericFileFilter<T> getFilter()

setFilter

public void setFilter(GenericFileFilter<T> filter)

getSorter

public Comparator<GenericFile<T>> getSorter()

setSorter

public void setSorter(Comparator<GenericFile<T>> sorter)

getSortBy

public Comparator<Exchange> getSortBy()

setSortBy

public void setSortBy(Comparator<Exchange> sortBy)

setSortBy

public void setSortBy(String expression)

setSortBy

public void setSortBy(String expression,
                      boolean reverse)

getTempPrefix

public String getTempPrefix()

setTempPrefix

public void setTempPrefix(String tempPrefix)
Enables and uses temporary prefix when writing files, after write it will be renamed to the correct name.


getTempFileName

public Expression getTempFileName()

setTempFileName

public void setTempFileName(Expression tempFileName)

setTempFileName

public void setTempFileName(String tempFileNameExpression)

isEagerDeleteTargetFile

public boolean isEagerDeleteTargetFile()

setEagerDeleteTargetFile

public void setEagerDeleteTargetFile(boolean eagerDeleteTargetFile)

getConfiguration

public GenericFileConfiguration getConfiguration()

setConfiguration

public void setConfiguration(GenericFileConfiguration configuration)

getExclusiveReadLockStrategy

public GenericFileExclusiveReadLockStrategy<T> getExclusiveReadLockStrategy()

setExclusiveReadLockStrategy

public void setExclusiveReadLockStrategy(GenericFileExclusiveReadLockStrategy<T> exclusiveReadLockStrategy)

getReadLock

public String getReadLock()

setReadLock

public void setReadLock(String readLock)

getReadLockTimeout

public long getReadLockTimeout()

setReadLockTimeout

public void setReadLockTimeout(long readLockTimeout)

getBufferSize

public int getBufferSize()

setBufferSize

public void setBufferSize(int bufferSize)

getFileExist

public GenericFileExist getFileExist()

setFileExist

public void setFileExist(GenericFileExist fileExist)

isAutoCreate

public boolean isAutoCreate()

setAutoCreate

public void setAutoCreate(boolean autoCreate)

isStartingDirectoryMustExist

public boolean isStartingDirectoryMustExist()

setStartingDirectoryMustExist

public void setStartingDirectoryMustExist(boolean startingDirectoryMustExist)

isDirectoryMustExist

public boolean isDirectoryMustExist()

setDirectoryMustExist

public void setDirectoryMustExist(boolean directoryMustExist)

getProcessStrategy

public GenericFileProcessStrategy<T> getProcessStrategy()

setProcessStrategy

public void setProcessStrategy(GenericFileProcessStrategy<T> processStrategy)

getLocalWorkDirectory

public String getLocalWorkDirectory()

setLocalWorkDirectory

public void setLocalWorkDirectory(String localWorkDirectory)

getMaxMessagesPerPoll

public int getMaxMessagesPerPoll()

setMaxMessagesPerPoll

public void setMaxMessagesPerPoll(int maxMessagesPerPoll)

getInProgressRepository

public IdempotentRepository<String> getInProgressRepository()

setInProgressRepository

public void setInProgressRepository(IdempotentRepository<String> inProgressRepository)

isKeepLastModified

public boolean isKeepLastModified()

setKeepLastModified

public void setKeepLastModified(boolean keepLastModified)

configureMessage

public void configureMessage(GenericFile<T> file,
                             Message message)
Configures the given message with the file which sets the body to the file object.


configureExchange

public void configureExchange(Exchange exchange)
Set up the exchange properties with the options of the file endpoint

Parameters:
exchange -

configureMoveOrPreMoveExpression

protected String configureMoveOrPreMoveExpression(String expression)
Strategy to configure the move or premove option based on a String input.

Parameters:
expression - the original string input
Returns:
configured string or the original if no modifications is needed

getParamsAsMap

protected Map<String,Object> getParamsAsMap()


Apache CAMEL