Update CM to us Local Intermediate Certs
[aaf/authz.git] / auth / auth-core / src / main / java / org / onap / aaf / auth / server / JettyServiceStarter.java
index dbf24cc..cefc7a2 100644 (file)
@@ -21,6 +21,7 @@
 package org.onap.aaf.auth.server;
 
 import java.io.IOException;
+import java.net.Inet4Address;
 import java.net.InetAddress;
 import java.util.Properties;
 
@@ -112,7 +113,10 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex
 
        @Override
        public void _start(RServlet<TRANS> rserv) throws Exception {
-               final String hostname = access().getProperty(Config.HOSTNAME, "localhost");
+               String hostname = access().getProperty(Config.HOSTNAME, null);
+               if(hostname==null) {
+                       hostname = Inet4Address.getLocalHost().getHostName();
+               }
                final int port = Integer.parseInt(access().getProperty("port","0"));
                final String keystore = access().getProperty(Config.CADI_KEYSTORE, null);
                final int IDLE_TIMEOUT = Integer.parseInt(access().getProperty(Config.AAF_CONN_IDLE_TIMEOUT, Config.AAF_CONN_IDLE_TIMEOUT_DEF));
@@ -217,16 +221,26 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex
                        access().log(Level.INIT,server.dump());
                } catch (Exception e) {
                        access().log(e,"Error starting " + service.app_name);
-                       System.exit(1);
+                       String doExit = access().getProperty("cadi_exitOnFailure", "true");
+                       if (doExit == "true") {
+                               System.exit(1);
+                       } else {
+                               throw e;
+                       }
                }
                try {
                        register(service.registrants(port));
                        access().printf(Level.INIT, "Starting Jetty Service for %s, version %s, on %s://%s:%d", service.app_name,service.app_version,protocol,hostname,port);
+                       server.join();
                } catch(Exception e) {
                        access().log(e,"Error registering " + service.app_name);
-                       // Question: Should Registered Services terminate?
+                       String doExit = access().getProperty("cadi_exitOnFailure", "true");
+                       if (doExit == "true") {
+                               System.exit(1);
+                       } else {
+                               throw e;
+                       }
                }
-               server.join();
        }
 
        private FilterChain buildFilterChain(final AbsService<?,?> as, final FilterChain doLast) throws CadiException, LocatorException {