public class Daemon
extends java.lang.Object
It does this by monitoring for the presence of a file, whose path is specified as a configuration parameter. The file can optionally be deleted as the process terminates.
Configure by passing it a Properties
object with the following
properties defined:
Example:
Properties properties = new Properties (); properties.load (new FileInputStream ("myapp.properties")); Daemon daemon = new Daemon (properties); while (!daemon.isProcessEnding ()) { // Continue running! // Nothing to do? if (nothingToDo) { try {Thread.sleep (5000);} catch (Exception e) {} } }
Modifier and Type | Field and Description |
---|---|
protected java.io.File |
shutdownFile
Field shutdownFile
|
protected boolean |
shutdownFileAutoDelete
Field shutdownFileAutoDelete
|
protected java.lang.String |
shutdownFileName
Our standard batch job control mechanism -
shutdown files.
|
Constructor and Description |
---|
Daemon(java.util.Properties properties)
Create a new Daemon from properties.
|
Daemon(java.lang.String shutdownFileName,
boolean autoDelete)
Create a new Daemon.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isProcessEnding()
Return true if its time to shut down.
|
protected java.lang.String shutdownFileName
protected boolean shutdownFileAutoDelete
protected java.io.File shutdownFile
public Daemon(java.lang.String shutdownFileName, boolean autoDelete)
shutdownFileName
- The path to the shutdown file.autoDelete
- If true, delete the file as we exit.public Daemon(java.util.Properties properties)
properties
- See the class javadoc for a description of the
properties that are read.Copyright ? 2002 Clarity Systems Group, LLC. All Rights Reserved.