Class GenericFileProcessStrategySupport<T>
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.component.file.strategy.GenericFileProcessStrategySupport<T>
-
- All Implemented Interfaces:
AutoCloseable,org.apache.camel.CamelContextAware,GenericFileProcessStrategy<T>,org.apache.camel.Service,org.apache.camel.ShutdownableService,org.apache.camel.StatefulService,org.apache.camel.SuspendableService
- Direct Known Subclasses:
GenericFileDeleteProcessStrategy,GenericFileNoOpProcessStrategy,GenericFileRenameProcessStrategy
public abstract class GenericFileProcessStrategySupport<T> extends org.apache.camel.support.service.ServiceSupport implements GenericFileProcessStrategy<T>, org.apache.camel.CamelContextAware
Base class for implementations ofGenericFileProcessStrategy.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.camel.CamelContextcamelContextprotected GenericFileExclusiveReadLockStrategy<T>exclusiveReadLockStrategy
-
Constructor Summary
Constructors Constructor Description GenericFileProcessStrategySupport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabort(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, org.apache.camel.Exchange exchange, GenericFile<T> file)Called when a begin is aborted, for example to release any resources which may have been acquired during theGenericFileProcessStrategy.begin(GenericFileOperations, GenericFileEndpoint, org.apache.camel.Exchange, GenericFile)operation.booleanbegin(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, org.apache.camel.Exchange exchange, GenericFile<T> file)Called when work is about to begin on this file.voidcommit(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, org.apache.camel.Exchange exchange, GenericFile<T> file)Releases any file locks and possibly deletes or moves the file after successful processingprotected voiddeleteLocalWorkFile(org.apache.camel.Exchange exchange)protected voiddoShutdown()protected voiddoStart()protected voiddoStop()org.apache.camel.CamelContextgetCamelContext()GenericFileExclusiveReadLockStrategy<T>getExclusiveReadLockStrategy()voidprepareOnStartup(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint)Allows custom logic to be run on first poll preparing the strategy, such as removing old lock files etc.protected GenericFile<T>renameFile(GenericFileOperations<T> operations, GenericFile<T> from, GenericFile<T> to)voidrollback(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, org.apache.camel.Exchange exchange, GenericFile<T> file)Releases any file locks and possibly deletes or moves the file after unsuccessful processingvoidsetCamelContext(org.apache.camel.CamelContext camelContext)voidsetExclusiveReadLockStrategy(GenericFileExclusiveReadLockStrategy<T> exclusiveReadLockStrategy)-
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, doLifecycleChange, doResume, 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, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Field Detail
-
exclusiveReadLockStrategy
protected GenericFileExclusiveReadLockStrategy<T> exclusiveReadLockStrategy
-
camelContext
protected org.apache.camel.CamelContext camelContext
-
-
Method Detail
-
getCamelContext
public org.apache.camel.CamelContext getCamelContext()
- Specified by:
getCamelContextin interfaceorg.apache.camel.CamelContextAware
-
setCamelContext
public void setCamelContext(org.apache.camel.CamelContext camelContext)
- Specified by:
setCamelContextin interfaceorg.apache.camel.CamelContextAware
-
prepareOnStartup
public void prepareOnStartup(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint) throws Exception
Description copied from interface:GenericFileProcessStrategyAllows custom logic to be run on first poll preparing the strategy, such as removing old lock files etc.- Specified by:
prepareOnStartupin interfaceGenericFileProcessStrategy<T>- Parameters:
operations- file operationsendpoint- the endpoint- Throws:
Exception- can be thrown in case of errors which causes poll to fail
-
begin
public boolean begin(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, org.apache.camel.Exchange exchange, GenericFile<T> file) throws Exception
Description copied from interface:GenericFileProcessStrategyCalled when work is about to begin on this file. This method may attempt to acquire some file lock before returning true; returning false if the file lock could not be obtained so that the file should be ignored.- Specified by:
beginin interfaceGenericFileProcessStrategy<T>- Parameters:
operations- file operationsendpoint- the endpointexchange- the exchangefile- the file- Returns:
- true if the file can be processed (such as if a file lock could be obtained)
- Throws:
Exception- can be thrown in case of errors
-
abort
public void abort(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, org.apache.camel.Exchange exchange, GenericFile<T> file) throws Exception
Description copied from interface:GenericFileProcessStrategyCalled when a begin is aborted, for example to release any resources which may have been acquired during theGenericFileProcessStrategy.begin(GenericFileOperations, GenericFileEndpoint, org.apache.camel.Exchange, GenericFile)operation.- Specified by:
abortin interfaceGenericFileProcessStrategy<T>- Parameters:
operations- file operationsendpoint- the endpointexchange- the exchangefile- the file- Throws:
Exception- can be thrown in case of errors
-
commit
public void commit(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, org.apache.camel.Exchange exchange, GenericFile<T> file) throws Exception
Description copied from interface:GenericFileProcessStrategyReleases any file locks and possibly deletes or moves the file after successful processing- Specified by:
commitin interfaceGenericFileProcessStrategy<T>- Parameters:
operations- file operationsendpoint- the endpointexchange- the exchangefile- the file- Throws:
Exception- can be thrown in case of errors
-
rollback
public void rollback(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, org.apache.camel.Exchange exchange, GenericFile<T> file) throws Exception
Description copied from interface:GenericFileProcessStrategyReleases any file locks and possibly deletes or moves the file after unsuccessful processing- Specified by:
rollbackin interfaceGenericFileProcessStrategy<T>- Parameters:
operations- file operationsendpoint- the endpointexchange- the exchangefile- the file- Throws:
Exception- can be thrown in case of errors
-
getExclusiveReadLockStrategy
public GenericFileExclusiveReadLockStrategy<T> getExclusiveReadLockStrategy()
-
setExclusiveReadLockStrategy
public void setExclusiveReadLockStrategy(GenericFileExclusiveReadLockStrategy<T> exclusiveReadLockStrategy)
-
renameFile
protected GenericFile<T> renameFile(GenericFileOperations<T> operations, GenericFile<T> from, GenericFile<T> to)
-
deleteLocalWorkFile
protected void deleteLocalWorkFile(org.apache.camel.Exchange exchange)
-
doStart
protected void doStart() throws Exception- Overrides:
doStartin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
doStop
protected void doStop() throws Exception- Overrides:
doStopin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
-