com.wutka.util
Class ServiceStarter

java.lang.Object
  |
  +--com.wutka.util.ServiceStarter
All Implemented Interfaces:
java.lang.Runnable

public class ServiceStarter
extends java.lang.Object
implements java.lang.Runnable

Handles the starting of services by reading a file listing service names and the class names for the service implementation. It uses the Config class to find out the name of the file (looking for the config item "services.file"), or uses "servstart.dat" as the default file of services. The format of the service file is:

 serviceName serviceClass
 serviceName serviceClass
          .
          .

Lines that start with # or ; are treated as comment lines and ignored

After it loads a class, it starts the class, expecting it to support the Service interface.


Field Summary
protected  java.lang.String serviceName
           
protected  Service serviceToStart
           
 
Constructor Summary
ServiceStarter(java.lang.String theServiceName, Service theServiceToStart)
          Creates a runnable instance that actually starts the service.
 
Method Summary
protected static void parseServiceFileLine(java.lang.String line)
           
 void run()
          Starts a new service
static void startServices()
          Opens the services file and starts the services listed in it.
static void startServices(java.lang.String serviceFilename)
          Opens the services file and starts the services listed in it
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serviceToStart

protected Service serviceToStart

serviceName

protected java.lang.String serviceName
Constructor Detail

ServiceStarter

public ServiceStarter(java.lang.String theServiceName,
                      Service theServiceToStart)
Creates a runnable instance that actually starts the service. By starting each service in a separate threads, the ServiceStarter is immune to locking issues caused by one service waiting for another to start before it can start.
Method Detail

run

public void run()
Starts a new service
Specified by:
run in interface java.lang.Runnable

startServices

public static void startServices(java.lang.String serviceFilename)
Opens the services file and starts the services listed in it
Parameters:
serviceFilename - The name of the file to read

startServices

public static void startServices()
Opens the services file and starts the services listed in it. If there is a configuration entry called "services.file" then it reads that file. Otherwise, it tries to read a file called "servstart.dat".

parseServiceFileLine

protected static void parseServiceFileLine(java.lang.String line)