oemware.core
Class ServiceManager

java.lang.Object
  extended by oemware.core.ServiceManager

public final class ServiceManager
extends java.lang.Object

The service manager. This class is the base for all java applications. When a server/module is started/initialized, it is done so here. If a stop service is registered, then it interacts with the service manager. There will only be one instance of this singleton running. The service manager executes the start/stop chains registered.

The startup/shutdown is modular so you don't need to add application specific initialization here. The contract is to call the startup method when you begin and the shutdown method when you need to exit :-^

Version:
$Id: ServiceManager.java 13 2008-06-15 19:43:04Z oemware $

Field Summary
static int STATE_INITIALIZE
           
static int STATE_RUNNING
           
static int STATE_STARTING
           
static int STATE_STOPPED
           
static int STATE_STOPPING
           
 
Method Summary
 java.lang.String getAppDir()
           
 java.lang.String getBaseDir()
           
 java.lang.String getDataDir()
           
 java.lang.String getEnvName()
           
static ServiceManager getInstance()
          Returns the (only) instance of this class.
 short getInstanceId()
           
 short getNodeId()
           
 int getRunState()
           
 java.lang.String getServiceName()
           
 long getStartTime()
           
 long getUptime()
           
 boolean isRunning()
           
 boolean isStopping()
           
static void main(java.lang.String[] pArgs)
          The main method.
 void shutdown()
          The stop hook.
 void startup()
          The start hook.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATE_INITIALIZE

public static final int STATE_INITIALIZE
See Also:
Constant Field Values

STATE_STARTING

public static final int STATE_STARTING
See Also:
Constant Field Values

STATE_RUNNING

public static final int STATE_RUNNING
See Also:
Constant Field Values

STATE_STOPPING

public static final int STATE_STOPPING
See Also:
Constant Field Values

STATE_STOPPED

public static final int STATE_STOPPED
See Also:
Constant Field Values
Method Detail

startup

public final void startup()
                   throws ServiceException
The start hook. Calls the registered startup chain.

Throws:
ServiceException

shutdown

public final void shutdown()
                    throws ServiceException
The stop hook. Calls the registered shutdown chain.

Throws:
ServiceException

main

public static final void main(java.lang.String[] pArgs)
The main method. Used to init from command line.

Parameters:
pArgs - The command line arguments.

isRunning

public final boolean isRunning()

isStopping

public final boolean isStopping()

getServiceName

public final java.lang.String getServiceName()

getEnvName

public final java.lang.String getEnvName()

getNodeId

public final short getNodeId()

getAppDir

public final java.lang.String getAppDir()

getBaseDir

public final java.lang.String getBaseDir()

getDataDir

public final java.lang.String getDataDir()

getInstanceId

public final short getInstanceId()

getRunState

public final int getRunState()

getStartTime

public final long getStartTime()

getUptime

public final long getUptime()

getInstance

public static final ServiceManager getInstance()
                                        throws ServiceException
Returns the (only) instance of this class. This methoed is syncronized so cache the result.

Returns:
The instance.
Throws:
ServiceException


Copyright © 2008 Deft Labs - Released under LGPL, Version 3.0