Commit a3b73ab4 authored by Andre Freyssinet's avatar Andre Freyssinet

JORAM-340: Defines the fr.dyade.aaa.agent.exitOnServiceFailure property

allowing to force the AgentServer exiting if there is error during services
launching.
parent 1f26b4b5
......@@ -754,13 +754,9 @@ public final class AgentServer {
}
/**
* Determines the boolean value of the server property with the specified
* name.
* Determines the boolean value of the server property with the specified name.
*
* @param key
* property name.
* @param value
* a default value.
* @param key property name.
* @return the boolean value of the property.
*/
public static boolean getBoolean(String key) {
......@@ -1510,6 +1506,14 @@ public final class AgentServer {
status.value = Status.INITIALIZED;
}
}
/**
* Name of the property specifying that the server should stop if any of the services can
* not start correctly. By default false.
* <p>
* This property can be fixed either from XML configuration file or Java launching command.
*/
public final static String CFG_EXIT_ON_SERVICE_FAILURE_PROPERTY = "fr.dyade.aaa.agent.exitOnServiceFailure";
/**
* Causes this AgentServer to begin its execution. This method starts all
......@@ -1531,10 +1535,11 @@ public final class AgentServer {
StringBuffer errBuf = null;
try {
try {
ServiceManager.start();
// with osgi, ServiceManager start asynchronously, we can't save here.
// ServiceManager.save(); //NTA
logmon.log(BasicLevel.INFO, getName() + ", ServiceManager started");
boolean exitOnServiceFailure = getBoolean(CFG_EXIT_ON_SERVICE_FAILURE_PROPERTY);
ServiceManager.start(exitOnServiceFailure);
// with osgi, ServiceManager start asynchronously, we can't save here.
// ServiceManager.save(); //NTA
logmon.log(BasicLevel.INFO, getName() + ", ServiceManager started");
} catch (Exception exc) {
logmon.log(BasicLevel.FATAL,
getName() + ", can't start services", exc);
......
/*
* Copyright (C) 2001 - 2012 ScalAgent Distributed Technologies
* Copyright (C) 2001 - 2019 ScalAgent Distributed Technologies
* Copyright (C) 1996 - 2000 BULL
* Copyright (C) 1996 - 2000 INRIA
*
......@@ -186,7 +186,7 @@ public class ServiceManager implements Serializable {
/**
* Starts all defined services.
*/
static void start() throws Exception {
static void start(boolean exitOnFailure) throws Exception {
// Launch all services defined in A3CML file
for (Enumeration<ServiceDesc> e = manager.registry.elements(); e.hasMoreElements() ;) {
ServiceDesc desc = e.nextElement();
......@@ -195,6 +195,8 @@ public class ServiceManager implements Serializable {
} catch (Exception exc) {
xlogmon.log(BasicLevel.ERROR,
getName() + ", cannot start service:" + desc.getClassName(), exc);
if (exitOnFailure)
throw new Exception("Cannot start service " + desc.getClassName());
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment