From ccaab8ee4c42b45d192ab518667be50554da0854 Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Tue, 26 Feb 2013 16:07:09 +0000 Subject: [PATCH] Remove SlcAgentFactory git-svn-id: https://svn.argeo.org/slc/trunk@6090 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- .../META-INF/spring/agent.xml | 3 - .../META-INF/spring/osgi.xml | 15 +-- .../META-INF/spring/controllers.xml | 1 + .../META-INF/spring/osgi.xml | 5 +- .../ui/controllers/ProcessController.java | 101 +++++++++--------- .../core/execution/DefaultAgentFactory.java | 59 ---------- .../slc/core/execution/DefaultProcess.java | 13 ++- .../argeo/slc/execution/SlcAgentFactory.java | 24 ----- 8 files changed, 65 insertions(+), 156 deletions(-) delete mode 100644 runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultAgentFactory.java delete mode 100644 runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/execution/SlcAgentFactory.java diff --git a/modules/org.argeo.slc.agent/META-INF/spring/agent.xml b/modules/org.argeo.slc.agent/META-INF/spring/agent.xml index 388b21bcd..1f8ca96cf 100644 --- a/modules/org.argeo.slc.agent/META-INF/spring/agent.xml +++ b/modules/org.argeo.slc.agent/META-INF/spring/agent.xml @@ -21,7 +21,4 @@ - - - \ No newline at end of file diff --git a/modules/org.argeo.slc.agent/META-INF/spring/osgi.xml b/modules/org.argeo.slc.agent/META-INF/spring/osgi.xml index d11106858..61d2d6b5c 100644 --- a/modules/org.argeo.slc.agent/META-INF/spring/osgi.xml +++ b/modules/org.argeo.slc.agent/META-INF/spring/osgi.xml @@ -8,6 +8,7 @@ http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> + - - - - - - - - - - - - \ No newline at end of file diff --git a/plugins/org.argeo.slc.client.ui/META-INF/spring/controllers.xml b/plugins/org.argeo.slc.client.ui/META-INF/spring/controllers.xml index 229d6d1ab..774b9da99 100644 --- a/plugins/org.argeo.slc.client.ui/META-INF/spring/controllers.xml +++ b/plugins/org.argeo.slc.client.ui/META-INF/spring/controllers.xml @@ -5,5 +5,6 @@ http://www.springframework.org/schema/beans/spring-beans.xsd"> + diff --git a/plugins/org.argeo.slc.client.ui/META-INF/spring/osgi.xml b/plugins/org.argeo.slc.client.ui/META-INF/spring/osgi.xml index 6397bb637..da9f8bc91 100644 --- a/plugins/org.argeo.slc.client.ui/META-INF/spring/osgi.xml +++ b/plugins/org.argeo.slc.client.ui/META-INF/spring/osgi.xml @@ -14,10 +14,7 @@ - - - + diff --git a/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/controllers/ProcessController.java b/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/controllers/ProcessController.java index 4cb7c9bda..abf41dc5b 100644 --- a/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/controllers/ProcessController.java +++ b/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/controllers/ProcessController.java @@ -15,23 +15,12 @@ */ 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 agentFactories = new HashMap(); + // private final static Log log = + // LogFactory.getLog(ProcessController.class); + // private Map agentFactories = new HashMap(); + + 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 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 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 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 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 index 1564fde80..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultAgentFactory.java +++ /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 agents = new HashMap(); - - public SlcAgent getAgent(String uuid) { - if (agents.containsKey(uuid)) - return agents.get(uuid); - else - return null; - } - - public void pingAll(List activeAgentIds) { - for (SlcAgent agent : agents.values()) - agent.ping(); - } - - public synchronized void register(SlcAgent agent, - Map properties) { - agents.put(agent.getAgentUuid(), agent); - if (log.isDebugEnabled()) - log.debug("Agent " + agent.getAgentUuid() + " registered"); - } - - public synchronized void unregister(SlcAgent agent, - Map properties) { - agents.remove(agent.getAgentUuid()); - if (log.isDebugEnabled()) - log.debug("Agent " + agent.getAgentUuid() + " unregistered"); - } - -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultProcess.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultProcess.java index e3090e571..06ff4d2f7 100644 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultProcess.java +++ b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultProcess.java @@ -31,8 +31,19 @@ public class DefaultProcess implements ExecutionProcess { } public List getRealizedFlows() { - // TODO Auto-generated method stub return null; } + public List getSteps() { + return steps; + } + + public void setSteps(List 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 index 979f41fbb..000000000 --- a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/execution/SlcAgentFactory.java +++ /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 activeAgentIds); -} -- 2.39.2