Package org.apache.camel.support
Class FileWatcherResourceReloadStrategy
java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.support.ResourceReloadStrategySupport
org.apache.camel.support.FileWatcherResourceReloadStrategy
- All Implemented Interfaces:
AutoCloseable,org.apache.camel.CamelContextAware,org.apache.camel.Service,org.apache.camel.ShutdownableService,org.apache.camel.spi.HasCamelContext,org.apache.camel.spi.ReloadStrategy,org.apache.camel.spi.ResourceReloadStrategy,org.apache.camel.StatefulService,org.apache.camel.StaticService,org.apache.camel.SuspendableService
- Direct Known Subclasses:
RouteWatcherReloadStrategy
@ManagedResource(description="Managed FileWatcherResourceReloadStrategy")
public class FileWatcherResourceReloadStrategy
extends ResourceReloadStrategySupport
A file based
ResourceReloadStrategy which watches a file folder for modified files and
reload on file changes.
This implementation uses the JDK WatchService to watch for when files are created or modified. Mac OS X users
should be noted the osx JDK does not support native file system changes and therefore the watch service is much
slower than on Linux or Windows systems.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classBackground task which watches for file changes -
Field Summary
Fields inherited from class org.apache.camel.support.service.BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING -
Constructor Summary
ConstructorsConstructorDescriptionFileWatcherResourceReloadStrategy(String directory) FileWatcherResourceReloadStrategy(String directory, boolean isRecursive) -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoStart()protected voiddoStop()booleanbooleanvoidvoidsetFileFilter(FileFilter fileFilter) To use a custom filter for accepting files.voidvoidsetPollTimeout(long pollTimeout) Sets the poll timeout in millis.voidsetRecursive(boolean isRecursive) voidsetScheduler(boolean scheduler) protected StringstartupMessage(File dir) Methods inherited from class org.apache.camel.support.ResourceReloadStrategySupport
getCamelContext, getFailedCounter, getLastError, getReloadCounter, getResourceReload, incFailedCounter, incSucceededCounter, lastErrorMessage, resetCounters, setCamelContext, setFailed, setLastError, setResourceReload, setSucceededMethods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getInternalLock, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.camel.Service
build, close, init, start, stopMethods inherited from interface org.apache.camel.ShutdownableService
shutdownMethods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Constructor Details
-
FileWatcherResourceReloadStrategy
public FileWatcherResourceReloadStrategy() -
FileWatcherResourceReloadStrategy
-
FileWatcherResourceReloadStrategy
-
-
Method Details
-
setFolder
-
setRecursive
public void setRecursive(boolean isRecursive) -
setScheduler
public void setScheduler(boolean scheduler) -
setPollTimeout
public void setPollTimeout(long pollTimeout) Sets the poll timeout in millis. The default value is 2000. -
getFolder
-
isRecursive
@ManagedAttribute(description="Whether the reload strategy watches directory recursively") public boolean isRecursive() -
isRunning
@ManagedAttribute(description="Whether the watcher is running") public boolean isRunning() -
getFileFilter
-
setFileFilter
To use a custom filter for accepting files. -
onReload
-
doStart
- Overrides:
doStartin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
startupMessage
-
doStop
- Overrides:
doStopin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-