Since 1994, the Java™ programming language evolved and became a
valid tool to develop, other than applets and client applications,
reliable and performant server applications. The major disadvantage of
the Java™ platform is that still today the only portable way to
start a Java™ applcation relies on a single point of entry: the
public static void main(String)
Having a single-point of entry is a valid solution for client
applications, where interactively a user can command to the application
to quit (which can terminate the Virtual Machine process at calling the
method), but in those cases where the application is not interactive
(server applications) there is currently no portable way to notify
the Virtual Machine of its imminent shutdown.
A server application written in Java might have to perform several tasks before being able to shutdown the Virtual Machine process. For example in the case of a Servlet container, before the VM process is shut down, sessions might need to be serialized to disk, and web applications need to be destroyed.
One common solution to this problem is to create (for example) a
ServerSocket and wait for a particular
message to be issued. When the message is received, all operations
required to shut down the server applications are performed and at the
System.exit method is called
to terminate the Virtual Machine process. This method, however, implies
several disadvantages and risks: for example in case of a system-wide
shutdown, it might happen that the Virtual Machine process will be shut
down directly by the operating system, without notifying the running
server application. Or, for example, if an attacker finds out what is
the required message to send to the server, and discovers a way to send
this message to the running server application, he can easily interrupt
the operation of a server, bypassing all the security restrictions
implemented in the operating system.
Most multi-user operating systems already have a way in which server applications are started and stopped, under Unix based operating systems non interactive server applications are called daemons and are controlled by the operating system with a set of specified signals. Under Windows such programs are called services and are controlled by appropriate calls to specific functions defined in the application binary, but although the ways of dealing with the problem are different, in both cases the operating system can notify a server application of its imminent shutdown, and the application has the ability to perform certain tasks before its process of execution is destroyed.
The scope of this specification is to define an API in line with the
current Java™ Platform APIs to support an alternative invocation
mechanism which could be used instead of the above mentioned
public static void main(String)
method. This specification cover the behavior and life cycle of what
we define as "Java ™ daemons", or, in other words,
non interactive Java™ applications.
This specification does not cover how the container of a Java™
daemon must be implemented, or how to build a native liaison between
the operating system and the
interface, but defines the relation between the an operating system
process and the
life cycle. It should be trivial for implementors to build a native
liaison and container for Java™ daemons.
This specification, together with the related API documentation, can be used by software deveopers to build portable non interactive applications based on the Java™ platform.
Daemon relies only on standard JDK 1.2 (or later) APIs for production deployment. It utilizes the JUnit unit testing framework for developing and executing unit tests, but this is of interest only to developers of the component. Daemon will be a dependency for several existing components in the open source world.
No external configuration files are utilized.
The original Java classes come from the Jakarta Tomcat 4.0 project.
The proposed package name for the new component is
The initial committers on the Daemon component shall be: