]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/runtime/DefaultAgent.java
Improve launcher
[gpl/argeo-slc.git] / runtime / org.argeo.slc.core / src / main / java / org / argeo / slc / core / runtime / DefaultAgent.java
index 932a6ad4b8aedbde2e2d2ea2f945ce0b1be5da9f..4af24ae97fbe480d40ee4ac8afd48d2236ff6d08 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
+ * Copyright (C) 2007-2012 Argeo GmbH
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -13,7 +13,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.argeo.slc.core.runtime;
 
 import java.net.InetAddress;
@@ -24,6 +23,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.argeo.slc.SlcException;
 import org.argeo.slc.core.execution.ProcessThread;
 import org.argeo.slc.execution.ExecutionModuleDescriptor;
@@ -38,6 +39,8 @@ import org.argeo.slc.runtime.SlcAgentDescriptor;
 /** Implements the base methods of an SLC agent. */
 @SuppressWarnings("deprecation")
 public class DefaultAgent implements SlcAgent, ExecutionProcessNotifier {
+       private final static Log log = LogFactory.getLog(DefaultAgent.class);
+
        private SlcAgentDescriptor agentDescriptor;
        private ExecutionModulesManager modulesManager;
 
@@ -48,13 +51,15 @@ public class DefaultAgent implements SlcAgent, ExecutionProcessNotifier {
        /*
         * LIFECYCLE
         */
+       /** Initialization */
        public void init() {
+               agentDescriptor = new SlcAgentDescriptor();
+               agentDescriptor.setUuid(initAgentUuid());
                try {
-                       agentDescriptor = new SlcAgentDescriptor();
-                       agentDescriptor.setUuid(initAgentUuid());
                        agentDescriptor.setHost(InetAddress.getLocalHost().getHostName());
                } catch (UnknownHostException e) {
-                       throw new SlcException("Unable to create agent descriptor.", e);
+                       log.error("Cannot resolve localhost host name: " + e.getMessage());
+                       agentDescriptor.setHost("localhost");
                }
                processesThreadGroup = new ThreadGroup("SLC Processes of Agent #"
                                + agentDescriptor.getUuid());
@@ -62,7 +67,8 @@ public class DefaultAgent implements SlcAgent, ExecutionProcessNotifier {
                                new HashMap<String, String>());
        }
 
-       public void dispose() {
+       /** Clean up (needs to be called by overriding method) */
+       public void destroy() {
                modulesManager.unregisterProcessNotifier(this,
                                new HashMap<String, String>());
        }