Remove SlcAgentFactory
authorMathieu Baudier <mbaudier@argeo.org>
Tue, 26 Feb 2013 16:07:09 +0000 (16:07 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Tue, 26 Feb 2013 16:07:09 +0000 (16:07 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@6090 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

modules/org.argeo.slc.agent/META-INF/spring/agent.xml
modules/org.argeo.slc.agent/META-INF/spring/osgi.xml
plugins/org.argeo.slc.client.ui/META-INF/spring/controllers.xml
plugins/org.argeo.slc.client.ui/META-INF/spring/osgi.xml
plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/controllers/ProcessController.java
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultAgentFactory.java [deleted file]
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultProcess.java
runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/execution/SlcAgentFactory.java [deleted file]

index 388b21bcdac54ef2dbcb6ccef829efce90437146..1f8ca96cfb45108902288c6bfc9f6e2d9a9b7191 100644 (file)
@@ -21,7 +21,4 @@
        <bean id="bundlesManager" class="org.argeo.slc.osgi.BundlesManager">\r
                <property name="defaultTimeout" value="${slc.agent.osgi.defaultTimeout}" />\r
        </bean>\r
-\r
-       <!-- Agent Factory -->\r
-       <bean id="vmAgentFactory" class="org.argeo.slc.core.execution.DefaultAgentFactory" />\r
 </beans>
\ No newline at end of file
index d11106858151c72a9af2ffb7fd6fa7a3df7aace3..61d2d6b5cecf8cda8984ca031d7cda56bbe51feb 100644 (file)
@@ -8,6 +8,7 @@
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
 \r
        <!-- REFERENCES -->\r
+       <!-- No <set> so that the equals methods are not called -->\r
        <list id="executionContexts" interface="org.argeo.slc.execution.ExecutionContext"\r
                cardinality="0..N">\r
                <listener ref="modulesManager" bind-method="register"\r
                        unbind-method="unregister" />\r
        </list>\r
 \r
-       <!-- No sets so that the equals methods are not called -->\r
        <list id="executionFlowDescriptorConverters"\r
                interface="org.argeo.slc.execution.ExecutionFlowDescriptorConverter"\r
                cardinality="0..N">\r
                <listener ref="modulesManager" />\r
        </list>\r
 \r
-       <list id="agents" interface="org.argeo.slc.execution.SlcAgent"\r
-               cardinality="0..N">\r
-               <listener ref="vmAgentFactory" bind-method="register"\r
-                       unbind-method="unregister" />\r
-       </list>\r
-\r
        <!-- SERVICES -->\r
        <service ref="modulesManager" interface="org.argeo.slc.execution.ExecutionModulesManager" />\r
-\r
-       <service ref="vmAgentFactory" interface="org.argeo.slc.execution.SlcAgentFactory">\r
-               <service-properties>\r
-                       <beans:entry key="argeo.slc.jcr.path" value="/slc:system/slc:agents/slc:vm" />\r
-               </service-properties>\r
-       </service>\r
-\r
 </beans:beans>
\ No newline at end of file
index 229d6d1ab0972bb5db5fe99307035b3efcd9cf9e..774b9da99fbbabb6a4b7005b07a4a5567071e36f 100644 (file)
@@ -5,5 +5,6 @@
         http://www.springframework.org/schema/beans/spring-beans.xsd">
 
        <bean id="processController" class="org.argeo.slc.client.ui.controllers.ProcessController">
+               <property name="agent" ref="agent" />
        </bean>
 </beans>
index 6397bb637a18d3ac05cf674429626b357d5abf46..da9f8bc91bad93d73d558a214852012263d59e2a 100644 (file)
        <reference id="repository" interface="javax.jcr.Repository"\r
                filter="(argeo.jcr.repository.alias=slc)" />\r
 \r
-       <list id="agentFactories" interface="org.argeo.slc.execution.SlcAgentFactory">\r
-               <listener ref="processController" bind-method="register"\r
-                       unbind-method="unregister" />\r
-       </list>\r
+       <reference id="agent" interface="org.argeo.slc.execution.SlcAgent" />\r
 \r
        <reference id="modulesManager"\r
                interface="org.argeo.slc.execution.ExecutionModulesManager" />\r
index 4cb7c9bda7130fa7966917a27542f6255e0b0bad..abf41dc5b54daec7868ee6e90778d53e43e2d335 100644 (file)
  */
 package org.argeo.slc.client.ui.controllers;
 
-import java.util.HashMap;
-import java.util.Map;
-
 import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
 import javax.jcr.RepositoryException;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.argeo.slc.SlcException;
 import org.argeo.slc.execution.ExecutionProcess;
 import org.argeo.slc.execution.SlcAgent;
-import org.argeo.slc.execution.SlcAgentFactory;
-import org.argeo.slc.jcr.SlcJcrConstants;
-import org.argeo.slc.jcr.SlcJcrUtils;
-import org.argeo.slc.jcr.SlcNames;
 import org.argeo.slc.jcr.execution.JcrExecutionProcess;
 
 /**
@@ -39,8 +28,12 @@ import org.argeo.slc.jcr.execution.JcrExecutionProcess;
  * in an application context.
  */
 public class ProcessController {
-       private final static Log log = LogFactory.getLog(ProcessController.class);
-       private Map<String, SlcAgentFactory> agentFactories = new HashMap<String, SlcAgentFactory>();
+       // private final static Log log =
+       // LogFactory.getLog(ProcessController.class);
+       // private Map<String, SlcAgentFactory> agentFactories = new HashMap<String,
+       // SlcAgentFactory>();
+
+       private SlcAgent agent;
 
        public ExecutionProcess process(Node processNode) {
                JcrExecutionProcess process = new JcrExecutionProcess(processNode);
@@ -71,49 +64,55 @@ public class ProcessController {
                }
        }
 
+       /** Always return the default runtime agent */
        protected SlcAgent findAgent(Node processNode) throws RepositoryException {
                // we currently only deal with single agents
-               Node realizedFlowNode = processNode.getNode(SlcNames.SLC_FLOW);
-               NodeIterator nit = realizedFlowNode.getNodes();
-               if (nit.hasNext()) {
-                       // TODO find a better way to determine which agent to use
-                       // currently we check the agent of the first registered flow
-                       Node firstRealizedFlow = nit.nextNode();
-                       // we assume there is an nt:address
-                       String firstFlowPath = firstRealizedFlow
-                                       .getNode(SlcNames.SLC_ADDRESS)
-                                       .getProperty(Property.JCR_PATH).getString();
-                       Node flowNode = processNode.getSession().getNode(firstFlowPath);
-                       String agentFactoryPath = SlcJcrUtils
-                                       .flowAgentFactoryPath(firstFlowPath);
-                       if (!agentFactories.containsKey(agentFactoryPath))
-                               throw new SlcException("No agent factory registered under "
-                                               + agentFactoryPath);
-                       SlcAgentFactory agentFactory = agentFactories.get(agentFactoryPath);
-                       Node agentNode = ((Node) flowNode
-                                       .getAncestor(SlcJcrUtils.AGENT_FACTORY_DEPTH + 1));
-                       String agentUuid = agentNode.getProperty(SlcNames.SLC_UUID)
-                                       .getString();
+               // Node realizedFlowNode = processNode.getNode(SlcNames.SLC_FLOW);
+               // NodeIterator nit = realizedFlowNode.getNodes();
+               // if (nit.hasNext()) {
+               // // TODO find a better way to determine which agent to use
+               // // currently we check the agent of the first registered flow
+               // Node firstRealizedFlow = nit.nextNode();
+               // // we assume there is an nt:address
+               // String firstFlowPath = firstRealizedFlow
+               // .getNode(SlcNames.SLC_ADDRESS)
+               // .getProperty(Property.JCR_PATH).getString();
+               // Node flowNode = processNode.getSession().getNode(firstFlowPath);
+               // String agentFactoryPath = SlcJcrUtils
+               // .flowAgentFactoryPath(firstFlowPath);
+               // if (!agentFactories.containsKey(agentFactoryPath))
+               // throw new SlcException("No agent factory registered under "
+               // + agentFactoryPath);
+               // SlcAgentFactory agentFactory = agentFactories.get(agentFactoryPath);
+               // Node agentNode = ((Node) flowNode
+               // .getAncestor(SlcJcrUtils.AGENT_FACTORY_DEPTH + 1));
+               // String agentUuid = agentNode.getProperty(SlcNames.SLC_UUID)
+               // .getString();
+               //
+               // // process
+               // return agentFactory.getAgent(agentUuid);
+               // }
 
-                       // process
-                       return agentFactory.getAgent(agentUuid);
-               }
-               return null;
+               return agent;
        }
 
-       public synchronized void register(SlcAgentFactory agentFactory,
-                       Map<String, String> properties) {
-               String path = properties.get(SlcJcrConstants.PROPERTY_PATH);
-               if (log.isDebugEnabled())
-                       log.debug("Agent factory registered under " + path);
-               agentFactories.put(path, agentFactory);
+       public void setAgent(SlcAgent agent) {
+               this.agent = agent;
        }
 
-       public synchronized void unregister(SlcAgentFactory agentFactory,
-                       Map<String, String> properties) {
-               String path = properties.get(SlcJcrConstants.PROPERTY_PATH);
-               if (log.isDebugEnabled())
-                       log.debug("Agent factory unregistered from " + path);
-               agentFactories.remove(path);
-       }
+       // public synchronized void register(SlcAgentFactory agentFactory,
+       // Map<String, String> properties) {
+       // String path = properties.get(SlcJcrConstants.PROPERTY_PATH);
+       // if (log.isDebugEnabled())
+       // log.debug("Agent factory registered under " + path);
+       // agentFactories.put(path, agentFactory);
+       // }
+       //
+       // public synchronized void unregister(SlcAgentFactory agentFactory,
+       // Map<String, String> properties) {
+       // String path = properties.get(SlcJcrConstants.PROPERTY_PATH);
+       // if (log.isDebugEnabled())
+       // log.debug("Agent factory unregistered from " + path);
+       // agentFactories.remove(path);
+       // }
 }
diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultAgentFactory.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultAgentFactory.java
deleted file mode 100644 (file)
index 1564fde..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.
- * 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.execution;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.execution.SlcAgent;
-import org.argeo.slc.execution.SlcAgentFactory;
-
-/** Register agents (typically via OSGi listeners) */
-public class DefaultAgentFactory implements SlcAgentFactory {
-       private final static Log log = LogFactory.getLog(DefaultAgentFactory.class);
-
-       private Map<String, SlcAgent> agents = new HashMap<String, SlcAgent>();
-
-       public SlcAgent getAgent(String uuid) {
-               if (agents.containsKey(uuid))
-                       return agents.get(uuid);
-               else
-                       return null;
-       }
-
-       public void pingAll(List<String> activeAgentIds) {
-               for (SlcAgent agent : agents.values())
-                       agent.ping();
-       }
-
-       public synchronized void register(SlcAgent agent,
-                       Map<String, String> properties) {
-               agents.put(agent.getAgentUuid(), agent);
-               if (log.isDebugEnabled())
-                       log.debug("Agent " + agent.getAgentUuid() + " registered");
-       }
-
-       public synchronized void unregister(SlcAgent agent,
-                       Map<String, String> properties) {
-               agents.remove(agent.getAgentUuid());
-               if (log.isDebugEnabled())
-                       log.debug("Agent " + agent.getAgentUuid() + " unregistered");
-       }
-
-}
index e3090e571cc25562e3c26374b44ae5e74a76abac..06ff4d2f7048404a376a6c3ec543d7bb86ba7198 100644 (file)
@@ -31,8 +31,19 @@ public class DefaultProcess implements ExecutionProcess {
        }
 
        public List<RealizedFlow> getRealizedFlows() {
-               // TODO Auto-generated method stub
                return null;
        }
 
+       public List<ExecutionStep> getSteps() {
+               return steps;
+       }
+
+       public void setSteps(List<ExecutionStep> steps) {
+               this.steps = steps;
+       }
+
+       public void setUuid(String uuid) {
+               this.uuid = uuid;
+       }
+
 }
diff --git a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/execution/SlcAgentFactory.java b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/execution/SlcAgentFactory.java
deleted file mode 100644 (file)
index 979f41f..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * 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.
- * 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.execution;
-
-import java.util.List;
-
-public interface SlcAgentFactory {
-       public SlcAgent getAgent(String uuid);
-
-       public void pingAll(List<String> activeAgentIds);
-}