Within my web application, I am trying to create a directory polling bean using Java SDK7 WatchService. What I would like to achieve is to run this bean in its own thread so that it does not block the application. Something like:
<bean id="directoryPoller" class="org...MyDirectoryPoller" scope="thread"/>
I am afraid you will have to create this thread manually with Spring:
The
WatchServiceRunnableWrapperis simple:I haven’t tested it, but it more-or-less should work and shutdown gracefully.