2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org
.argeo
.slc
.core
.runtime
;
19 import java
.net
.InetAddress
;
20 import java
.net
.UnknownHostException
;
21 import java
.util
.List
;
22 import java
.util
.UUID
;
24 import org
.argeo
.slc
.SlcException
;
25 import org
.argeo
.slc
.execution
.ExecutionModuleDescriptor
;
26 import org
.argeo
.slc
.execution
.ExecutionModulesManager
;
27 import org
.argeo
.slc
.process
.SlcExecution
;
28 import org
.argeo
.slc
.runtime
.SlcAgent
;
29 import org
.argeo
.slc
.runtime
.SlcAgentDescriptor
;
31 public class DefaultAgent
implements SlcAgent
{
32 // private final static Log log = LogFactory.getLog(AbstractAgent.class);
34 private final SlcAgentDescriptor agentDescriptor
;
35 private ExecutionModulesManager modulesManager
;
37 public DefaultAgent() {
39 agentDescriptor
= new SlcAgentDescriptor();
40 agentDescriptor
.setUuid(UUID
.randomUUID().toString());
41 agentDescriptor
.setHost(InetAddress
.getLocalHost().getHostName());
42 } catch (UnknownHostException e
) {
43 throw new SlcException("Unable to create agent descriptor.", e
);
47 public void runSlcExecution(final SlcExecution slcExecution
) {
48 modulesManager
.process(slcExecution
);
51 public ExecutionModuleDescriptor
getExecutionModuleDescriptor(
52 String moduleName
, String version
) {
53 return modulesManager
.getExecutionModuleDescriptor(moduleName
, version
);
56 public List
<ExecutionModuleDescriptor
> listExecutionModuleDescriptors() {
57 return modulesManager
.listExecutionModules();
60 public boolean ping() {
64 public void setModulesManager(ExecutionModulesManager modulesManager
) {
65 this.modulesManager
= modulesManager
;
68 public ExecutionModulesManager
getModulesManager() {
69 return modulesManager
;
72 protected SlcAgentDescriptor
getAgentDescriptor() {
73 return agentDescriptor
;
76 public String
getAgentUuid() {
77 return getAgentDescriptor().getUuid();
81 public String
toString() {
82 return agentDescriptor
.toString();