Package org.apache.camel.component.file
Class FileEndpoint
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.support.DefaultEndpoint
-
- org.apache.camel.support.ScheduledPollEndpoint
-
- org.apache.camel.component.file.GenericFileEndpoint<File>
-
- org.apache.camel.component.file.FileEndpoint
-
- All Implemented Interfaces:
AutoCloseable
,org.apache.camel.CamelContextAware
,org.apache.camel.Endpoint
,org.apache.camel.IsSingleton
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.spi.BrowsableEndpoint
,org.apache.camel.spi.HasId
,org.apache.camel.StatefulService
,org.apache.camel.SuspendableService
@UriEndpoint(firstVersion="1.0.0", scheme="file", title="File", syntax="file:directoryName", category={FILE,CORE}, headersClass=FileConstants.class) public class FileEndpoint extends GenericFileEndpoint<File>
Read and write files.
-
-
Field Summary
-
Fields inherited from class org.apache.camel.component.file.GenericFileEndpoint
allowNullBody, antExclude, antFilter, antFilterCaseSensitive, antInclude, appendChars, autoCreate, bufferSize, charset, configuration, DEFAULT_IDEMPOTENT_CACHE_SIZE, DEFAULT_IN_PROGRESS_CACHE_SIZE, delete, doneFileName, eagerDeleteTargetFile, eagerMaxMessagesPerPoll, exclude, excludeExt, exclusiveReadLockStrategy, fileExist, fileName, filter, filterDirectory, filterFile, flatten, idempotent, idempotentKey, idempotentRepository, include, includeExt, inProgressRepository, jailStartingDirectory, keepLastModified, localWorkDirectory, maxDepth, maxMessagesPerPoll, minDepth, move, moveExisting, moveExistingFileStrategy, moveFailed, noop, onCompletionExceptionHandler, preMove, preSort, processStrategy, readLock, readLockCheckInterval, readLockDeleteOrphanLockFiles, readLockIdempotentReleaseAsync, readLockIdempotentReleaseAsyncPoolSize, readLockIdempotentReleaseDelay, readLockIdempotentReleaseExecutorService, readLockLoggingLevel, readLockMarkerFile, readLockMinAge, readLockMinLength, readLockRemoveOnCommit, readLockRemoveOnRollback, readLockTimeout, recursive, shuffle, sortBy, sorter, tempFileName, tempPrefix
-
-
Constructor Summary
Constructors Constructor Description FileEndpoint()
FileEndpoint(String endpointUri, org.apache.camel.Component component)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
chmodPermissionsAreValid(String chmod)
Chmod value must be between 000 and 777; If there is a leading digit like in 0755 we will ignore it.FileConsumer
createConsumer(org.apache.camel.Processor processor)
protected String
createEndpointUri()
org.apache.camel.Exchange
createExchange(GenericFile<File> file)
protected GenericFileProcessStrategy<File>
createGenericFileStrategy()
A strategy method to lazily create the file strategyorg.apache.camel.PollingConsumer
createPollingConsumer()
GenericFileProducer<File>
createProducer()
String
getChmod()
String
getChmodDirectory()
Set<PosixFilePermission>
getDirectoryPermissions()
String
getExtendedAttributes()
File
getFile()
char
getFileSeparator()
Set<PosixFilePermission>
getPermissions()
String
getScheme()
boolean
isAbsolute(String name)
boolean
isCopyAndDeleteOnRenameFail()
boolean
isDirectoryMustExist()
boolean
isForceWrites()
boolean
isProbeContentType()
boolean
isRenameUsingCopy()
boolean
isStartingDirectoryMustExist()
boolean
isStartingDirectoryMustHaveAccess()
protected FileConsumer
newFileConsumer(org.apache.camel.Processor processor, GenericFileOperations<File> operations)
Strategy to create a newFileConsumer
void
setChmod(String chmod)
Specify the file permissions which is sent by the producer, the chmod value must be between 000 and 777; If there is a leading digit like in 0755 we will ignore it.void
setChmodDirectory(String chmodDirectory)
Specify the directory permissions used when the producer creates missing directories, the chmod value must be between 000 and 777; If there is a leading digit like in 0755 we will ignore it.void
setCopyAndDeleteOnRenameFail(boolean copyAndDeleteOnRenameFail)
Whether to fallback and do a copy and delete file, in case the file could not be renamed directly.void
setDirectoryMustExist(boolean directoryMustExist)
Similar to the startingDirectoryMustExist option but this applies during polling (after starting the consumer).void
setExtendedAttributes(String extendedAttributes)
To define which file attributes of interest.void
setFile(File file)
The starting directoryvoid
setForceWrites(boolean forceWrites)
Whether to force syncing writes to the file system.void
setProbeContentType(boolean probeContentType)
Whether to enable probing of the content type.void
setRenameUsingCopy(boolean renameUsingCopy)
Perform rename operations using a copy and delete strategy.void
setStartingDirectoryMustExist(boolean startingDirectoryMustExist)
Whether the starting directory must exist.void
setStartingDirectoryMustHaveAccess(boolean startingDirectoryMustHaveAccess)
Whether the starting directory has access permissions.-
Methods inherited from class org.apache.camel.component.file.GenericFileEndpoint
configureExchange, configureMessage, configureMoveOrPreMoveExpression, createDoneFileName, doInit, doStart, doStop, getAntExclude, getAntFilter, getAntInclude, getAppendChars, getBufferSize, getCharset, getConfiguration, getDoneFileName, getExchanges, getExclude, getExcludeExt, getExcludePattern, getExclusiveReadLockStrategy, getFileExist, getFileName, getFilter, getFilterDirectory, getFilterFile, getGeneratedFileName, getIdempotent, getIdempotentKey, getIdempotentRepository, getInclude, getIncludeExt, getIncludePattern, getInProgressRepository, getLocalWorkDirectory, getMaxDepth, getMaxMessagesPerPoll, getMinDepth, getMove, getMoveExisting, getMoveExistingFileStrategy, getMoveFailed, getOnCompletionExceptionHandler, getParamsAsMap, getPreMove, getProcessStrategy, getReadLock, getReadLockCheckInterval, getReadLockIdempotentReleaseAsyncPoolSize, getReadLockIdempotentReleaseDelay, getReadLockIdempotentReleaseExecutorService, getReadLockLoggingLevel, getReadLockMinAge, getReadLockMinLength, getReadLockTimeout, getSortBy, getSorter, getTempFileName, getTempPrefix, isAllowNullBody, isAntFilterCaseSensitive, isAutoCreate, isDelete, isDoneFile, isEagerDeleteTargetFile, isEagerMaxMessagesPerPoll, isFlatten, isIdempotent, isIdempotentSet, isJailStartingDirectory, isKeepLastModified, isNoop, isPreSort, isReadLockDeleteOrphanLockFiles, isReadLockIdempotentReleaseAsync, isReadLockMarkerFile, isReadLockRemoveOnCommit, isReadLockRemoveOnRollback, isRecursive, isShuffle, isSynchronous, setAllowNullBody, setAntExclude, setAntFilterCaseSensitive, setAntInclude, setAppendChars, setAutoCreate, setBufferSize, setCharset, setConfiguration, setDelete, setDoneFileName, setEagerDeleteTargetFile, setEagerMaxMessagesPerPoll, setExclude, setExcludeExt, setExclusiveReadLockStrategy, setFileExist, setFileName, setFileName, setFilter, setFilterDirectory, setFilterDirectory, setFilterFile, setFilterFile, setFlatten, setIdempotent, setIdempotentKey, setIdempotentKey, setIdempotentRepository, setInclude, setIncludeExt, setInProgressRepository, setJailStartingDirectory, setKeepLastModified, setLocalWorkDirectory, setMaxDepth, setMaxMessagesPerPoll, setMinDepth, setMove, setMove, setMoveExisting, setMoveExisting, setMoveExistingFileStrategy, setMoveFailed, setMoveFailed, setNoop, setOnCompletionExceptionHandler, setPreMove, setPreMove, setPreSort, setProcessStrategy, setReadLock, setReadLockCheckInterval, setReadLockDeleteOrphanLockFiles, setReadLockIdempotentReleaseAsync, setReadLockIdempotentReleaseAsyncPoolSize, setReadLockIdempotentReleaseDelay, setReadLockIdempotentReleaseExecutorService, setReadLockLoggingLevel, setReadLockMarkerFile, setReadLockMinAge, setReadLockMinLength, setReadLockRemoveOnCommit, setReadLockRemoveOnRollback, setReadLockTimeout, setRecursive, setShuffle, setSortBy, setSortBy, setSortBy, setSorter, setSynchronous, setTempFileName, setTempFileName, setTempPrefix
-
Methods inherited from class org.apache.camel.support.ScheduledPollEndpoint
configureConsumer, configureProperties, configureScheduledPollConsumerProperties, doConfigureConsumer, getBackoffErrorThreshold, getBackoffIdleThreshold, getBackoffMultiplier, getDefaultDelay, getDelay, getInitialDelay, getPollStrategy, getRepeatCount, getRunLoggingLevel, getScheduledExecutorService, getScheduler, getSchedulerProperties, getTimeUnit, isGreedy, isSendEmptyMessageWhenIdle, isStartScheduler, isUseFixedDelay, setBackoffErrorThreshold, setBackoffIdleThreshold, setBackoffMultiplier, setDelay, setGreedy, setInitialDelay, setPollStrategy, setRepeatCount, setRunLoggingLevel, setScheduledExecutorService, setScheduler, setSchedulerProperties, setSendEmptyMessageWhenIdle, setStartScheduler, setTimeUnit, setUseFixedDelay
-
Methods inherited from class org.apache.camel.support.DefaultEndpoint
configurePollingConsumer, createAsyncProducer, createExchange, createExchange, equals, getCamelContext, getComponent, getEndpointKey, getEndpointUri, getExceptionHandler, getExchangePattern, getId, getPollingConsumerBlockTimeout, getPollingConsumerQueueSize, hashCode, isAutowiredEnabled, isBridgeErrorHandler, isLazyStartProducer, isLenientProperties, isPollingConsumerBlockWhenFull, isPollingConsumerCopy, isSingleton, setAutowiredEnabled, setBridgeErrorHandler, setCamelContext, setComponent, setEndpointUri, setEndpointUriIfNotSpecified, setExceptionHandler, setExchangePattern, setLazyStartProducer, setPollingConsumerBlockTimeout, setPollingConsumerBlockWhenFull, setPollingConsumerCopy, setPollingConsumerQueueSize, setProperties, toString
-
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.camel.Endpoint
configureProperties, createAsyncProducer, createExchange, createExchange, getCamelContext, getEndpointBaseUri, getEndpointKey, getEndpointUri, getExchangePattern, isLenientProperties, isSingletonProducer, setCamelContext
-
-
-
-
Constructor Detail
-
FileEndpoint
public FileEndpoint()
-
FileEndpoint
public FileEndpoint(String endpointUri, org.apache.camel.Component component)
-
-
Method Detail
-
createConsumer
public FileConsumer createConsumer(org.apache.camel.Processor processor) throws Exception
- Specified by:
createConsumer
in interfaceorg.apache.camel.Endpoint
- Specified by:
createConsumer
in classGenericFileEndpoint<File>
- Throws:
Exception
-
createPollingConsumer
public org.apache.camel.PollingConsumer createPollingConsumer() throws Exception
- Specified by:
createPollingConsumer
in interfaceorg.apache.camel.Endpoint
- Overrides:
createPollingConsumer
in classorg.apache.camel.support.DefaultEndpoint
- Throws:
Exception
-
createProducer
public GenericFileProducer<File> createProducer() throws Exception
- Specified by:
createProducer
in interfaceorg.apache.camel.Endpoint
- Specified by:
createProducer
in classGenericFileEndpoint<File>
- Throws:
Exception
-
createExchange
public org.apache.camel.Exchange createExchange(GenericFile<File> file)
- Specified by:
createExchange
in classGenericFileEndpoint<File>
-
newFileConsumer
protected FileConsumer newFileConsumer(org.apache.camel.Processor processor, GenericFileOperations<File> operations)
Strategy to create a newFileConsumer
- Parameters:
processor
- the given processoroperations
- file operations- Returns:
- the created consumer
-
createGenericFileStrategy
protected GenericFileProcessStrategy<File> createGenericFileStrategy()
Description copied from class:GenericFileEndpoint
A strategy method to lazily create the file strategy- Specified by:
createGenericFileStrategy
in classGenericFileEndpoint<File>
-
getFile
public File getFile()
-
setFile
public void setFile(File file)
The starting directory
-
getScheme
public String getScheme()
- Specified by:
getScheme
in classGenericFileEndpoint<File>
-
createEndpointUri
protected String createEndpointUri()
- Overrides:
createEndpointUri
in classorg.apache.camel.support.DefaultEndpoint
-
getFileSeparator
public char getFileSeparator()
- Specified by:
getFileSeparator
in classGenericFileEndpoint<File>
-
isAbsolute
public boolean isAbsolute(String name)
- Specified by:
isAbsolute
in classGenericFileEndpoint<File>
-
isCopyAndDeleteOnRenameFail
public boolean isCopyAndDeleteOnRenameFail()
-
setCopyAndDeleteOnRenameFail
public void setCopyAndDeleteOnRenameFail(boolean copyAndDeleteOnRenameFail)
Whether to fallback and do a copy and delete file, in case the file could not be renamed directly. This option is not available for the FTP component.
-
isRenameUsingCopy
public boolean isRenameUsingCopy()
-
setRenameUsingCopy
public void setRenameUsingCopy(boolean renameUsingCopy)
Perform rename operations using a copy and delete strategy. This is primarily used in environments where the regular rename operation is unreliable (e.g. across different file systems or networks). This option takes precedence over the copyAndDeleteOnRenameFail parameter that will automatically fall back to the copy and delete strategy, but only after additional delays.
-
isStartingDirectoryMustExist
public boolean isStartingDirectoryMustExist()
-
setStartingDirectoryMustExist
public void setStartingDirectoryMustExist(boolean startingDirectoryMustExist)
Whether the starting directory must exist. Mind that the autoCreate option is default enabled, which means the starting directory is normally auto created if it doesn't exist. You can disable autoCreate and enable this to ensure the starting directory must exist. Will thrown an exception if the directory doesn't exist.
-
isStartingDirectoryMustHaveAccess
public boolean isStartingDirectoryMustHaveAccess()
-
setStartingDirectoryMustHaveAccess
public void setStartingDirectoryMustHaveAccess(boolean startingDirectoryMustHaveAccess)
Whether the starting directory has access permissions. Mind that the startingDirectoryMustExist parameter must be set to true in order to verify that the directory exists. Will thrown an exception if the directory doesn't have read and write permissions.
-
isDirectoryMustExist
public boolean isDirectoryMustExist()
-
setDirectoryMustExist
public void setDirectoryMustExist(boolean directoryMustExist)
Similar to the startingDirectoryMustExist option but this applies during polling (after starting the consumer).
-
isForceWrites
public boolean isForceWrites()
-
setForceWrites
public void setForceWrites(boolean forceWrites)
Whether to force syncing writes to the file system. You can turn this off if you do not want this level of guarantee, for example if writing to logs / audit logs etc; this would yield better performance.
-
isProbeContentType
public boolean isProbeContentType()
-
setProbeContentType
public void setProbeContentType(boolean probeContentType)
Whether to enable probing of the content type. If enable then the consumer usesFiles.probeContentType(java.nio.file.Path)
to determine the content-type of the file, and store that as a header with keyExchange.FILE_CONTENT_TYPE
on theMessage
.
-
getExtendedAttributes
public String getExtendedAttributes()
-
setExtendedAttributes
public void setExtendedAttributes(String extendedAttributes)
To define which file attributes of interest. Like posix:permissions,posix:owner,basic:lastAccessTime, it supports basic wildcard like posix:*, basic:lastAccessTime
-
chmodPermissionsAreValid
public boolean chmodPermissionsAreValid(String chmod)
Chmod value must be between 000 and 777; If there is a leading digit like in 0755 we will ignore it.
-
getPermissions
public Set<PosixFilePermission> getPermissions()
-
getChmod
public String getChmod()
-
setChmod
public void setChmod(String chmod)
Specify the file permissions which is sent by the producer, the chmod value must be between 000 and 777; If there is a leading digit like in 0755 we will ignore it.
-
getDirectoryPermissions
public Set<PosixFilePermission> getDirectoryPermissions()
-
getChmodDirectory
public String getChmodDirectory()
-
setChmodDirectory
public void setChmodDirectory(String chmodDirectory)
Specify the directory permissions used when the producer creates missing directories, the chmod value must be between 000 and 777; If there is a leading digit like in 0755 we will ignore it.
-
-