Overview
This service uses a background thread to monitor a resource. A resource is loaded by using a resource name and an InputStreamLocator. The a SHA-1 hashcode is derived and compared to the previous hashcode. If a change is detected the container is disposed, either by terminating all active threads or by calling System.exit(). This service allows to shutdown a long-running application by writing a timestamp into a file therefore avoiding any additional network support.
Configuration
Role Configuration
<role name="org.apache.fulcrum.yaafi.service.shutdown.ShutdownService" shorthand="ShutdownService" default-class="org.apache.fulcrum.yaafi.service.shutdown.ShutdownServiceImpl" early-init="true" description="Monitors a resource to force a disposal of the Avalon container" />
Example Component Configuration
The following configuration checks every 5 seconds if the files have changed. Changing "shutdown.txt" forces a disposable of the container and invoking System.exit() afterwards
<ShutdownService interval="5000"> <entry> <location>./src/test/shutdown.txt</location> <useSystemExit>true</useSystemExit> </entry> </ShutdownService>