|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object SK.gnome.dwarf.main.Main
The main executable class.
It constructs, starts and shuts down the main server object. Only one main server per JVM
can be mantained by this class. The server object must be an instance of the MainServer
class. The XMLConfiguration
class is used to instantiate and configure the main server
object.
Thread safety note: Both start(String)
and shutdown(boolean)
methods are thread safe and may be called simultaneously.
Constructor Summary | |
Main()
|
Method Summary | |
static java.lang.String |
getConfigurationURL()
Returns the configuration URL. |
static MainServer |
getMainServer()
Returns the main server. |
static boolean |
checkDwarfVersion(java.lang.String version)
Checks the framework specification version. |
static void |
main(java.lang.String[] args)
Starts the main server. |
static void |
shutdown(boolean exit)
Shuts down the main server. |
static void |
start(java.lang.String url)
Starts the main server. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Main()
Method Detail |
public static void main(java.lang.String[] args) throws XMLConfigurationException, ServiceException
This method requires one argument which must be an URL from which the
XMLConfiguration
instance will load the server configuration.
This method calls start
method to do the actual job.
args
- the command-line arguments
XMLConfigurationException
- if an error occured in the XML configuration
ServiceException
- if an error occured while initializing or starting
the applicationpublic static void start(java.lang.String url) throws XMLConfigurationException, ServiceException
The url argument must be an URL from which the XMLConfiguration
instance will load the server configuration.
This method returns silently if an instance of the main server is already running, or either the starting or the shutdown process is already in a progress.
The service being constructed from the XML must be an instance of the MainServer
class.
If a security manager is installed, the ServicePermission "startMainServer" is checked first.
The following code snippet illustrates restarting of the main server without changing its current configuration:
Main.shutdown(false); Main.start(Main.getConfigurationURL());
This method adds a custom shutdown hook to the current Runtime object for correct shutting down of the main server instance in the case of an unexpected JVM shutdown. It is added only if the SK.gnome.dwarf.main.disableShutdownHook system property is not set.
url
- URL of the XML-based configuration
XMLConfigurationException
- if an error occured in the XML configuration
ServiceException
- if an error occured while initializing or starting
the serverpublic static void shutdown(boolean exit)
The method returns silently if either the starting or the shutdown process is already in the progress.
If the exit argument is true the method forces JVM to exit by calling
System.exit(0). This is done even if there is no main server instance available,
, i.e. the start(String)
method has never been executed successfully.
If a security manager is installed, the ServicePermission "shutdownMainServer" is checked first.
exit
- whether to terminate the JVMpublic static java.lang.String getConfigurationURL()
It returns the configuration URL of the current main server instance.
public static MainServer getMainServer()
Returns a reference to the current main server instance. The server instance may be
in any transition state, therefore the Service.getState(int)
method must be
called on it in order to get its actual state.
If a security manager is installed, the ServicePermission "getMainServer" is checked prior to returning the object.
MainServer
public static boolean checkDwarfVersion(java.lang.String version)
For example, a Dwarf Mail Server version 1.0.0. may require the Dwarf Server Framework version 1.2 or higher. This method may be used to check the framework specification version against the given version argument. The version argument must be given as a sequence of two or more numbers separated by dots.
version
- desired version number
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |