@Requires(property="micronaut.io.watch.paths") @Requires(property="micronaut.io.watch.enabled",value="true",defaultValue="false") @Requires(condition=FileWatchCondition.class) @Requires(notEnv={"function","android"}) @Requires(beans=java.nio.file.WatchService.class) @Parallel @Singleton public class DefaultWatchThread extends java.lang.Object implements LifeCycle<DefaultWatchThread>
For example with Gradle you use ./gradlew run --continuous
Modifier | Constructor and Description |
---|---|
protected |
DefaultWatchThread(ApplicationEventPublisher eventPublisher,
FileWatchConfiguration configuration,
java.nio.file.WatchService watchService)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Delegates to
LifeCycle.stop() . |
protected void |
closeWatchService()
Closes the watch service.
|
java.nio.file.WatchService |
getWatchService() |
boolean |
isRunning() |
protected java.nio.file.WatchKey |
registerPath(java.nio.file.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, java.nio.file.WatchService watchService)
eventPublisher
- The event publisherconfiguration
- the configurationwatchService
- the watch servicepublic boolean isRunning()
isRunning
in interface LifeCycle<DefaultWatchThread>
@PostConstruct public DefaultWatchThread start()
LifeCycle
start
in interface LifeCycle<DefaultWatchThread>
public DefaultWatchThread stop()
LifeCycle
stop
in interface LifeCycle<DefaultWatchThread>
@PreDestroy public void close()
LifeCycle
LifeCycle.stop()
.close
in interface LifeCycle<DefaultWatchThread>
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
@NonNull public java.nio.file.WatchService getWatchService()
protected void closeWatchService()
@NonNull protected java.nio.file.WatchKey registerPath(@NonNull java.nio.file.Path dir) throws java.io.IOException
dir
- The directory to watchjava.io.IOException
- if an error occurs.