Package fr.dyade.aaa.agent
Class ServiceManager
- java.lang.Object
-
- fr.dyade.aaa.agent.ServiceManager
-
- All Implemented Interfaces:
Serializable
public class ServiceManager extends Object implements Serializable
Object which manages services. There is only oneServiceManagerobject per agent server. TheServiceManagerobject is initialized ininit, called fromAgentServer.init. This classes reuses the persistency service provided byTransaction.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static booleanDEBUG(package private) static Loggerlogger(package private) static ServiceManagermanagerthe uniqueServiceManagerin the agent serverprivate static Stringname(package private) Hashtable<String,ServiceDesc>registryrepository holdingServicesprivate static longserialVersionUIDDefine serialVersionUID for interoperability.static Stringtxname
-
Constructor Summary
Constructors Modifier Constructor Description privateServiceManager()Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StringgetName()static ServiceDescgetService(String serviceClassName)(package private) static ServiceDesc[]getServices()(package private) static voidinit()Initializes theServiceManagerobject.(package private) static Set<String>listServices()(package private) static ServiceManagerload()Builds object from persistent image.static voidloadServiceClass(ServiceDesc desc)Loads the class of a service.static voidloadServiceClasses()Loads the class of every service.static voidregister(String scname, String args)Registers a newServiceobject.(package private) static voidsave()Saves object in persistent storage.(package private) static voidstart(boolean exitOnFailure)Starts all defined services.static voidstart(ServiceDesc desc)Start aServicedefined by its descriptor.(package private) static voidstart(String scname)Start aServiceidentified by its name.(package private) static voidstop()Stops all running services.static voidstop(ServiceDesc desc)Stop aServicedefined by its descriptor.static voidstop(String scname)Stop aServiceidentified by its name.StringtoString()Provides a string image for this object.(package private) static voidunregister(String scname)Unregisters uselessService.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
Define serialVersionUID for interoperability.- See Also:
- Constant Field Values
-
logger
static Logger logger
-
DEBUG
private static final boolean DEBUG
-
manager
static ServiceManager manager
the uniqueServiceManagerin the agent server
-
name
private static String name
-
txname
public static String txname
-
registry
Hashtable<String,ServiceDesc> registry
repository holdingServices
-
-
Method Detail
-
getName
public static final String getName()
-
init
static void init() throws ExceptionInitializes theServiceManagerobject. Synchronize the persistent image and the configuration file.- Throws:
Exception- unspecialized exception
-
load
static ServiceManager load() throws IOException, ClassNotFoundException
Builds object from persistent image.- Returns:
- loaded object or null if no persistent image exists
- Throws:
IOException- when accessing the stored imageClassNotFoundException- if the corresponding image class may not be found
-
save
static void save() throws IOExceptionSaves object in persistent storage.- Throws:
IOException- an error occurs.
-
loadServiceClasses
public static void loadServiceClasses() throws ExceptionLoads the class of every service.- Throws:
Exception- if an error occurs
-
loadServiceClass
public static void loadServiceClass(ServiceDesc desc) throws Exception
Loads the class of a service.- Parameters:
desc- the service descriptor- Throws:
Exception- if an error occurs
-
start
public static void start(ServiceDesc desc) throws Exception
Start aServicedefined by its descriptor.- Parameters:
desc- service descriptor.- Throws:
Exception- if an error occurs
-
start
static void start(String scname) throws Exception
Start aServiceidentified by its name.- Parameters:
scname- service class name.- Throws:
Exception- if an error occurs
-
start
static void start(boolean exitOnFailure) throws ExceptionStarts all defined services.- Parameters:
exitOnFailure- if true exit on failure.- Throws:
Exception- if an error occurs
-
stop
public static void stop(ServiceDesc desc) throws Exception
Stop aServicedefined by its descriptor.- Parameters:
desc- service descriptor.- Throws:
Exception- if an error occurs
-
stop
public static void stop(String scname) throws Exception
Stop aServiceidentified by its name.- Parameters:
scname- service class name.- Throws:
Exception- if an error occurs
-
stop
static void stop()
Stops all running services.
-
register
public static void register(String scname, String args)
Registers a newServiceobject.- Parameters:
scname- service class name.args- launching arguments.
-
unregister
static void unregister(String scname)
Unregisters uselessService.- Parameters:
scname- service class name.
-
getService
public static ServiceDesc getService(String serviceClassName)
-
getServices
static ServiceDesc[] getServices()
-
-