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.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 basedResourceReloadStrategy
which watches a file folder for modified files and reload on file changes. This implementation uses the JDKWatchService
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 Classes Modifier and Type Class Description protected class
FileWatcherResourceReloadStrategy.WatchFileChangesTask
Background task which watches for file changes
-
Constructor Summary
Constructors Constructor Description FileWatcherResourceReloadStrategy()
FileWatcherResourceReloadStrategy(String directory)
FileWatcherResourceReloadStrategy(String directory, boolean isRecursive)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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)
protected String
startupMessage(File dir)
-
Methods inherited from class org.apache.camel.support.ResourceReloadStrategySupport
getCamelContext, getFailedCounter, getReloadCounter, getResourceReload, incFailedCounter, incSucceededCounter, resetCounters, setCamelContext, setFailed, setResourceReload, setSucceeded
-
Methods inherited from class org.apache.camel.support.service.BaseService
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
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Constructor Detail
-
FileWatcherResourceReloadStrategy
public FileWatcherResourceReloadStrategy()
-
FileWatcherResourceReloadStrategy
public FileWatcherResourceReloadStrategy(String directory)
-
FileWatcherResourceReloadStrategy
public FileWatcherResourceReloadStrategy(String directory, boolean isRecursive)
-
-
Method Detail
-
setFolder
public void setFolder(String folder)
-
setRecursive
public void setRecursive(boolean isRecursive)
-
setPollTimeout
public void setPollTimeout(long pollTimeout)
Sets the poll timeout in millis. The default value is 2000.
-
getFolder
@ManagedAttribute(description="Folder being watched") public String 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
public FileFilter getFileFilter()
-
setFileFilter
public void setFileFilter(FileFilter fileFilter)
To use a custom filter for accepting files.
-
doStart
protected void doStart() throws Exception
- Overrides:
doStart
in classResourceReloadStrategySupport
- Throws:
Exception
-
doStop
protected void doStop() throws Exception
- Overrides:
doStop
in classResourceReloadStrategySupport
- Throws:
Exception
-
-