@Requires(property="micronaut.io.watch.enabled",value="true",defaultValue="true") @Requires(condition=FileWatchCondition.class) @Requires(notEnv={"function","android"}) @Requires(beans=java.nio.file.WatchService.class) @Parallel @Singleton public class DefaultWatchThread extends Object implements LifeCycle<DefaultWatchThread>
For example with Gradle you use ./gradlew run --continuous
| Modifier | Constructor and Description |
|---|---|
protected |
DefaultWatchThread(ApplicationEventPublisher eventPublisher,
FileWatchConfiguration configuration,
WatchService watchService)
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
closeWatchService()
Closes the watch service.
|
WatchService |
getWatchService() |
boolean |
isRunning() |
protected WatchKey |
registerPath(Path dir)
Registers a patch to watch.
|
DefaultWatchThread |
start()
Starts the lifecyle component.
|
DefaultWatchThread |
stop()
Stops the life cycle component.
|
protected DefaultWatchThread(ApplicationEventPublisher eventPublisher, FileWatchConfiguration configuration, WatchService watchService)
eventPublisher - The event publisherconfiguration - the configurationwatchService - the watch servicepublic boolean isRunning()
isRunning in interface LifeCycle<DefaultWatchThread>@PostConstruct public DefaultWatchThread start()
LifeCyclestart in interface LifeCycle<DefaultWatchThread>@PreDestroy public DefaultWatchThread stop()
LifeCyclestop in interface LifeCycle<DefaultWatchThread>@Nonnull public WatchService getWatchService()
protected void closeWatchService()
@Nonnull protected WatchKey registerPath(@Nonnull Path dir) throws IOException
dir - The directory to watchIOException - if an error occurs.