@ManagedResource(description="Managed FileWatcherResourceReloadStrategy") public class FileWatcherResourceReloadStrategy extends ResourceReloadStrategySupport
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.Modifier and Type | Class and Description |
---|---|
protected class |
FileWatcherResourceReloadStrategy.WatchFileChangesTask
Background task which watches for file changes
|
Constructor and Description |
---|
FileWatcherResourceReloadStrategy() |
FileWatcherResourceReloadStrategy(String directory) |
FileWatcherResourceReloadStrategy(String directory,
boolean isRecursive) |
Modifier and Type | Method and Description |
---|---|
protected void |
doStart() |
protected void |
doStop() |
FileFilter |
getFileFilter() |
String |
getFolder() |
boolean |
isRecursive() |
boolean |
isRunning() |
void |
setFileFilter(FileFilter fileFilter)
To use a custom filter for accepting files.
|
void |
setFolder(String folder) |
void |
setPollTimeout(long pollTimeout)
Sets the poll timeout in millis.
|
void |
setRecursive(boolean isRecursive) |
getCamelContext, getFailedCounter, getReloadCounter, getResourceReload, incFailedCounter, incSucceededCounter, resetCounters, setCamelContext, setFailed, setResourceReload, setSucceeded
build, doBuild, doFail, doInit, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public FileWatcherResourceReloadStrategy()
public FileWatcherResourceReloadStrategy(String directory)
public FileWatcherResourceReloadStrategy(String directory, boolean isRecursive)
public void setFolder(String folder)
public void setRecursive(boolean isRecursive)
public void setPollTimeout(long pollTimeout)
@ManagedAttribute(description="Folder being watched") public String getFolder()
@ManagedAttribute(description="Whether the reload strategy watches directory recursively") public boolean isRecursive()
@ManagedAttribute(description="Whether the watcher is running") public boolean isRunning()
public FileFilter getFileFilter()
public void setFileFilter(FileFilter fileFilter)
protected void doStart() throws Exception
doStart
in class ResourceReloadStrategySupport
Exception
protected void doStop() throws Exception
doStop
in class ResourceReloadStrategySupport
Exception
Apache Camel