]>
git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultAgentFactory.java
e80db134619a75773db2373f04d66d8b51bc2d2a
2 * Copyright (C) 2007-2012 Argeo GmbH
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.
16 package org
.argeo
.slc
.core
.execution
;
18 import java
.util
.HashMap
;
19 import java
.util
.List
;
22 import org
.apache
.commons
.logging
.Log
;
23 import org
.apache
.commons
.logging
.LogFactory
;
24 import org
.argeo
.slc
.runtime
.SlcAgent
;
25 import org
.argeo
.slc
.runtime
.SlcAgentFactory
;
27 /** Register agents (typically via OSGi listeners) */
28 public class DefaultAgentFactory
implements SlcAgentFactory
{
29 private final static Log log
= LogFactory
.getLog(DefaultAgentFactory
.class);
31 private Map
<String
, SlcAgent
> agents
= new HashMap
<String
, SlcAgent
>();
33 public SlcAgent
getAgent(String uuid
) {
34 if (agents
.containsKey(uuid
))
35 return agents
.get(uuid
);
40 public void pingAll(List
<String
> activeAgentIds
) {
41 for (SlcAgent agent
: agents
.values())
45 public synchronized void register(SlcAgent agent
,
46 Map
<String
, String
> properties
) {
47 agents
.put(agent
.getAgentUuid(), agent
);
48 if (log
.isDebugEnabled())
49 log
.debug("Agent " + agent
.getAgentUuid() + " registered");
52 public synchronized void unregister(SlcAgent agent
,
53 Map
<String
, String
> properties
) {
54 agents
.remove(agent
.getAgentUuid());
55 if (log
.isDebugEnabled())
56 log
.debug("Agent " + agent
.getAgentUuid() + " unregistered");