SK.gnome.dwarf.main
Class MainServer

java.lang.Object
  extended bySK.gnome.dwarf.GenericService
      extended bySK.gnome.dwarf.GenericServer
          extended bySK.gnome.dwarf.main.MainServer
All Implemented Interfaces:
Reportable, Server, Service

public class MainServer
extends GenericServer

The main server application.

It can be used as a common container for other - more specific - servers. It provides also remote management via the Console. An instance of this class can be created an started easily by the Main static class.


Field Summary
protected  long started
          The starting time of the server.
 
Fields inherited from class SK.gnome.dwarf.GenericService
initParameters, parent
 
Fields inherited from interface SK.gnome.dwarf.Service
INITIALIZED, LOG_DEBUG, LOG_ERROR, LOG_FATAL, LOG_INFO, LOG_TRACE, LOG_WARN, LOG_XFER, SHUTDOWN, STARTED, STOPPED
 
Constructor Summary
MainServer(java.lang.String name)
          Creates a new MainServer.
 
Method Summary
 void addService(Service service)
          Adds a service to the server.
 Console getConsole()
          Returns the server console.
 java.lang.String getUptime()
          Returns the uptime.
 java.lang.String report()
          Returns the service report.
 void shutdown()
          Shuts down the server.
 void start()
          Starts the server.
 
Methods inherited from class SK.gnome.dwarf.GenericServer
addService, getAuthenticator, getLogger, getParameters, getService, getServices, getServices, init, removeService, stop
 
Methods inherited from class SK.gnome.dwarf.GenericService
getAuthFacility, getFullName, getInitParameter, getInitParameterNames, getLogFacility, getName, getPrincipal, getShutdownTimeout, getState, log, log, login, logout, setAuthFacility, setInitParameters, setLogFacility, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface SK.gnome.dwarf.Service
getFullName, getName, getState, log, log, login, logout
 

Field Detail

started

protected long started
The starting time of the server.

Constructor Detail

MainServer

public MainServer(java.lang.String name)
Creates a new MainServer.

Method Detail

getConsole

public Console getConsole()
Returns the server console.

Returns a reference to directly contained instance of the Console class, or null if no such service exists.

The Console instance may be used to execute various console commands.

If a security manager is installed, the ServicePermission "getConsole" is checked first.

Returns:
the console instance

addService

public void addService(Service service)
                throws ServiceException
Adds a service to the server.

If the service being added to the server is an instance of the Console class, a reference to it is stored inernally, and can be obtained later by the getConsole() method.

Specified by:
addService in interface Server
Overrides:
addService in class GenericServer
Throws:
ServiceException

start

public void start()
           throws ServiceException
Starts the server.

The value of the started field is set to the current system time.

Specified by:
start in interface Service
Overrides:
start in class GenericServer
Throws:
ServiceException

shutdown

public void shutdown()
Description copied from class: GenericServer
Shuts down the server.

First shuts down the superclass and then shuts down all services contained by the server by calling their Service.shutdown() methoda. Services will be processed in the reverse order they were added to the server. It is left to the developer to take care of the eventual service dependencies.

Specified by:
shutdown in interface Service
Overrides:
shutdown in class GenericServer

getUptime

public java.lang.String getUptime()
Returns the uptime.

Returns the total running time of the server.

Returns:
the total running time

report

public java.lang.String report()
Returns the service report.

Returns the uptime, starting time and the memory usage.

Specified by:
report in interface Reportable
Overrides:
report in class GenericServer
Returns:
the report of all contained services


Copyright (c) 1999-2005, Gnome Ltd. All rights reserved.