X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.core%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fcore%2Fruntime%2FDefaultAgent.java;h=430b6bd973e6c12df8228b5993c3e7bbc1620956;hb=d601802d5a50e4e30eb639a08eff5270b63fe599;hp=141ccbe72cf2f3e6dfdd323da08170e2bc850aeb;hpb=8edbca70380f4c884f523073819fd915754185d2;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/runtime/DefaultAgent.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/runtime/DefaultAgent.java index 141ccbe72..430b6bd97 100644 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/runtime/DefaultAgent.java +++ b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/runtime/DefaultAgent.java @@ -1,25 +1,56 @@ +/* + * Copyright (C) 2010 Mathieu Baudier + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * 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.net.UnknownHostException; import java.util.List; +import java.util.UUID; +import org.argeo.slc.SlcException; import org.argeo.slc.execution.ExecutionModuleDescriptor; import org.argeo.slc.execution.ExecutionModulesManager; import org.argeo.slc.process.SlcExecution; import org.argeo.slc.runtime.SlcAgent; +import org.argeo.slc.runtime.SlcAgentDescriptor; public class DefaultAgent implements SlcAgent { // private final static Log log = LogFactory.getLog(AbstractAgent.class); + private final SlcAgentDescriptor agentDescriptor; private ExecutionModulesManager modulesManager; + public DefaultAgent() { + try { + agentDescriptor = new SlcAgentDescriptor(); + agentDescriptor.setUuid(UUID.randomUUID().toString()); + agentDescriptor.setHost(InetAddress.getLocalHost().getHostName()); + } catch (UnknownHostException e) { + throw new SlcException("Unable to create agent descriptor.", e); + } + } + public void runSlcExecution(final SlcExecution slcExecution) { modulesManager.process(slcExecution); } public ExecutionModuleDescriptor getExecutionModuleDescriptor( String moduleName, String version) { - return modulesManager.getExecutionModuleDescriptor(moduleName, - version); + return modulesManager.getExecutionModuleDescriptor(moduleName, version); } public List listExecutionModuleDescriptors() { @@ -38,4 +69,16 @@ public class DefaultAgent implements SlcAgent { return modulesManager; } + protected SlcAgentDescriptor getAgentDescriptor() { + return agentDescriptor; + } + + public String getAgentUuid() { + return getAgentDescriptor().getUuid(); + } + + @Override + public String toString() { + return agentDescriptor.toString(); + } }