org.apache.camel.component.file
Class FileEndpoint

java.lang.Object
  extended by org.apache.camel.impl.DefaultEndpoint<E>
      extended by org.apache.camel.impl.ScheduledPollEndpoint<FileExchange>
          extended by org.apache.camel.component.file.FileEndpoint
All Implemented Interfaces:
CamelContextAware, Endpoint<FileExchange>

public class FileEndpoint
extends ScheduledPollEndpoint<FileExchange>

A File Endpoint for working with file systems

Version:
$Revision: 41278 $

Constructor Summary
protected FileEndpoint(File file, String endpointUri, FileComponent component)
           
  FileEndpoint(String endpointUri, File file)
           
 
Method Summary
 void configureMessage(File file, Message message)
          Configures the given message with the file which sets the body to the file object and sets the FileComponent.HEADER_FILE_NAME header.
 Consumer<FileExchange> createConsumer(Processor processor)
          Creates a new Event Driven Consumer which consumes messages from the endpoint using the given processor
 FileExchange createExchange()
          Create a new exchange for communicating with this endpoint
 FileExchange createExchange(ExchangePattern pattern)
          Create a new exchange for communicating with this endpoint with the specified ExchangePattern such as whether its going to be an ExchangePattern.InOnly or ExchangePattern.InOut exchange
 FileExchange createExchange(File file)
          Create a new exchange for communicating with this endpoint
protected  FileProcessStrategy createFileStrategy()
          A strategy method to lazily create the file strategy
 Producer<FileExchange> createProducer()
          Creates a new producer which is used send messages into the endpoint
 int getBufferSize()
           
 String[] getExcludedNamePostfixes()
           
 String[] getExcludedNamePrefixes()
           
 File getFile()
           
 FileProcessStrategy getFileStrategy()
           
 String getMoveNamePostfix()
           
 String getMoveNamePrefix()
           
 boolean isAppend()
           
 boolean isAutoCreate()
           
 boolean isDelete()
           
 boolean isIgnoreFileNameHeader()
           
 boolean isLock()
           
 boolean isNoop()
           
 boolean isSingleton()
          Returns if the endpoint should be a CamelContext singleton.
 void setAppend(boolean append)
          When writing do we append to the end of the file, or replace it? The default is to append
 void setAutoCreate(boolean autoCreate)
           
 void setBufferSize(int bufferSize)
          Sets the buffer size used to read/write files
 void setDelete(boolean delete)
           
 void setExcludedNamePostfixes(String[] excludedNamePostfixes)
          Sets the excluded file name postfixes, such as FileProcessStrategySupport.DEFAULT_LOCK_FILE_POSTFIX to ignore lock files by default.
 void setExcludedNamePrefixes(String[] excludedNamePrefixes)
          Sets the excluded file name prefixes, such as "." for hidden files which are excluded by default
 void setFileStrategy(FileProcessStrategy fileProcessStrategy)
          Sets the strategy to be used when the file has been processed such as deleting or renaming it etc.
 void setIgnoreFileNameHeader(boolean ignoreFileNameHeader)
          If this flag is enabled then producers will ignore the FileComponent.HEADER_FILE_NAME header and generate a new dynamic file
 void setLock(boolean lock)
           
 void setMoveNamePostfix(String moveNamePostfix)
          Sets the name postfix appended to moved files.
 void setMoveNamePrefix(String moveNamePrefix)
          Sets the name prefix appended to moved files.
 void setNoop(boolean noop)
          If set to true then the default FileProcessStrategy will be to use the NoOpFileProcessStrategy to not move or copy processed files
 
Methods inherited from class org.apache.camel.impl.ScheduledPollEndpoint
configureConsumer, configureProperties, getConsumerProperties, setConsumerProperties
 
Methods inherited from class org.apache.camel.impl.DefaultEndpoint
convertTo, createExchange, createExecutorService, createPollingConsumer, equals, getCamelContext, getComponent, getEndpointUri, getExchangePattern, getExchangeType, getExecutorService, hashCode, setCamelContext, setExchangePattern, setExecutorService, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileEndpoint

protected FileEndpoint(File file,
                       String endpointUri,
                       FileComponent component)

FileEndpoint

public FileEndpoint(String endpointUri,
                    File file)
Method Detail

createProducer

public Producer<FileExchange> 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

createConsumer

public Consumer<FileExchange> 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

Returns:
a newly created consumer
Throws:
Exception

createExchange

public FileExchange createExchange(File file)
Create a new exchange for communicating with this endpoint

Parameters:
file - the file
Returns:
the created exchange

createExchange

public FileExchange createExchange()
Description copied from interface: Endpoint
Create a new exchange for communicating with this endpoint

Specified by:
createExchange in interface Endpoint<FileExchange>
Overrides:
createExchange in class DefaultEndpoint<FileExchange>

createExchange

public FileExchange createExchange(ExchangePattern pattern)
Description copied from interface: Endpoint
Create a new exchange for communicating with this endpoint with the specified ExchangePattern such as whether its going to be an ExchangePattern.InOnly or ExchangePattern.InOut exchange

Specified by:
createExchange in interface Endpoint<FileExchange>
Overrides:
createExchange in class DefaultEndpoint<FileExchange>
Parameters:
pattern - the message exchange pattern for the exchange

configureMessage

public void configureMessage(File file,
                             Message message)
Configures the given message with the file which sets the body to the file object and sets the FileComponent.HEADER_FILE_NAME header.


getFile

public File getFile()

isSingleton

public boolean isSingleton()
Description copied from interface: Endpoint
Returns if the endpoint should be a CamelContext singleton. If the endpoint is a Singleton, then a single Endpoint instance will be shared by all routes with the same URI. Because the endpoint is shared, it should be treated as an immutable.


isAutoCreate

public boolean isAutoCreate()

setAutoCreate

public void setAutoCreate(boolean autoCreate)

getFileStrategy

public FileProcessStrategy getFileStrategy()

setFileStrategy

public void setFileStrategy(FileProcessStrategy fileProcessStrategy)
Sets the strategy to be used when the file has been processed such as deleting or renaming it etc.

Parameters:
fileProcessStrategy - the new strategy to use

isDelete

public boolean isDelete()

setDelete

public void setDelete(boolean delete)

isLock

public boolean isLock()

setLock

public void setLock(boolean lock)

getMoveNamePostfix

public String getMoveNamePostfix()

setMoveNamePostfix

public void setMoveNamePostfix(String moveNamePostfix)
Sets the name postfix appended to moved files. For example to rename all the files from * to *.done set this value to .done


getMoveNamePrefix

public String getMoveNamePrefix()

setMoveNamePrefix

public void setMoveNamePrefix(String moveNamePrefix)
Sets the name prefix appended to moved files. For example to move processed files into a hidden directory called .camel set this value to .camel/


getExcludedNamePrefixes

public String[] getExcludedNamePrefixes()

setExcludedNamePrefixes

public void setExcludedNamePrefixes(String[] excludedNamePrefixes)
Sets the excluded file name prefixes, such as "." for hidden files which are excluded by default


getExcludedNamePostfixes

public String[] getExcludedNamePostfixes()

setExcludedNamePostfixes

public void setExcludedNamePostfixes(String[] excludedNamePostfixes)
Sets the excluded file name postfixes, such as FileProcessStrategySupport.DEFAULT_LOCK_FILE_POSTFIX to ignore lock files by default.


isNoop

public boolean isNoop()

setNoop

public void setNoop(boolean noop)
If set to true then the default FileProcessStrategy will be to use the NoOpFileProcessStrategy to not move or copy processed files


isAppend

public boolean isAppend()

setAppend

public void setAppend(boolean append)
When writing do we append to the end of the file, or replace it? The default is to append


getBufferSize

public int getBufferSize()

setBufferSize

public void setBufferSize(int bufferSize)
Sets the buffer size used to read/write files


isIgnoreFileNameHeader

public boolean isIgnoreFileNameHeader()

setIgnoreFileNameHeader

public void setIgnoreFileNameHeader(boolean ignoreFileNameHeader)
If this flag is enabled then producers will ignore the FileComponent.HEADER_FILE_NAME header and generate a new dynamic file


createFileStrategy

protected FileProcessStrategy createFileStrategy()
A strategy method to lazily create the file strategy



Copyright © 2008 IONA Open Source Community. All Rights Reserved.