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.ComponentAware, 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.HasCamelContext, 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 Details

  • Constructor Details

    • FileEndpoint

      public FileEndpoint()
    • FileEndpoint

      public FileEndpoint(String endpointUri, org.apache.camel.Component component)
  • Method Details

    • createConsumer

      public FileConsumer createConsumer(org.apache.camel.Processor processor) throws Exception
      Specified by:
      createConsumer in interface org.apache.camel.Endpoint
      Specified by:
      createConsumer in class GenericFileEndpoint<File>
      Throws:
      Exception
    • createPollingConsumer

      public org.apache.camel.PollingConsumer createPollingConsumer() throws Exception
      Specified by:
      createPollingConsumer in interface org.apache.camel.Endpoint
      Overrides:
      createPollingConsumer in class org.apache.camel.support.DefaultEndpoint
      Throws:
      Exception
    • createProducer

      public GenericFileProducer<File> createProducer() throws Exception
      Specified by:
      createProducer in interface org.apache.camel.Endpoint
      Specified by:
      createProducer in class GenericFileEndpoint<File>
      Throws:
      Exception
    • createExchange

      public org.apache.camel.Exchange createExchange(GenericFile<File> file)
      Specified by:
      createExchange in class GenericFileEndpoint<File>
    • newFileConsumer

      protected FileConsumer newFileConsumer(org.apache.camel.Processor processor, GenericFileOperations<File> operations)
      Strategy to create a new FileConsumer
      Parameters:
      processor - the given processor
      operations - 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 class GenericFileEndpoint<File>
    • getFile

      public File getFile()
    • setFile

      public void setFile(File file)
      The starting directory
    • getScheme

      public String getScheme()
      Specified by:
      getScheme in class GenericFileEndpoint<File>
    • createEndpointUri

      protected String createEndpointUri()
      Overrides:
      createEndpointUri in class org.apache.camel.support.DefaultEndpoint
    • getFileSeparator

      public char getFileSeparator()
      Specified by:
      getFileSeparator in class GenericFileEndpoint<File>
    • isAbsolute

      public boolean isAbsolute(String name)
      Specified by:
      isAbsolute in class GenericFileEndpoint<File>
    • isHiddenFilesEnabled

      public boolean isHiddenFilesEnabled()
      Overrides:
      isHiddenFilesEnabled in class GenericFileEndpoint<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.
    • isIncludeHiddenFiles

      public boolean isIncludeHiddenFiles()
    • setIncludeHiddenFiles

      public void setIncludeHiddenFiles(boolean includeHiddenFiles)
      Whether to accept hidden files. Files which names starts with dot is regarded as a hidden file, and by default not included. Set this option to true to include hidden files in the file consumer.
    • isIncludeHiddenDirs

      public boolean isIncludeHiddenDirs()
    • setIncludeHiddenDirs

      public void setIncludeHiddenDirs(boolean includeHiddenDirs)
      Whether to accept hidden directories. Directories which names starts with dot is regarded as a hidden directory, and by default not included. Set this option to true to include hidden directories in the file consumer.
    • 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 throw 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 uses Files.probeContentType(java.nio.file.Path) to determine the content-type of the file, and store that as a header with key Exchange.FILE_CONTENT_TYPE on the Message.
    • 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.