/*
- * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
+ * Copyright (C) 2007-2012 Mathieu Baudier
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.argeo.slc.core.runtime;
import java.net.InetAddress;
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;
/** 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;
/*
* 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());
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>());
}