<bean id="slcAgentFactory" class="org.argeo.slc.core.runtime.SimpleAgentFactory">
<property name="agents">
<list>
- <ref bean="slcAgent"/>
+ <ref bean="slcAgent" />
</list>
</property>
</bean>
<bean id="slcAgent" class="org.argeo.slc.core.runtime.DefaultAgent"
- p:modulesManager-ref="modulesManager" />
+ init-method="init" destroy-method="dispose" p:modulesManager-ref="modulesManager" />
</beans>
<!-- UI Components -->
<bundle id="slc.node.jackrabbit" symbolic-name="org.argeo.slc.node.jackrabbit"
action="start" />
- <bundle id="slc.client.agent" symbolic-name="org.argeo.slc.client.agent"
- action="start" />
+<!-- <bundle id="slc.client.agent" symbolic-name="org.argeo.slc.client.agent" -->
+<!-- action="start" /> -->
<bundle id="slc.client.hibernate" symbolic-name="org.argeo.slc.client.hibernate"
action="start" />
<bundle id="slc.client.oxm" symbolic-name="org.argeo.slc.client.oxm"
<import resource="classpath:org/argeo/slc/activemq/destinations.xml" />
<!-- Agent implementation -->
- <bean id="jmsAgent" class="org.argeo.slc.jms.JmsAgent">
+ <bean id="jmsAgent" class="org.argeo.slc.jms.JmsAgent"
+ init-method="init" destroy-method="dispose">
<property name="agentRegister" ref="slcJms.destination.agent.register" />
<property name="agentUnregister" ref="slcJms.destination.agent.unregister" />
<property name="modulesManager" ref="modulesManager" />
<property name="jmsTemplate" ref="jmsTemplate" />
</bean>
- <!-- Listeners -->
+ <!-- Listeners -->
<bean id="jmsAgent.listener.request" parent="listenerTemplate">
<property name="destination" ref="slcJms.destination.agent.request" />
<property name="messageSelector">
<!-- Services -->
<bean id="resultListener" class="org.argeo.slc.jms.JmsTreeTestResultListener">
<property name="executionEventDestination" ref="slcJms.destination.execution.event" />
- <property name="onlyOnClose" value="${slc.agent.jms.resultListener.onlyOnClose}"/>
+ <property name="onlyOnClose" value="${slc.agent.jms.resultListener.onlyOnClose}" />
<property name="jmsTemplate" ref="jmsTemplate" />
</bean>
<bean id="attachmentUploader" class="org.argeo.slc.jms.JmsAttachmentUploader">
org.argeo.jcr.mvc,
org.argeo.jcr.spring,
org.argeo.security,
+ org.argeo.security.core,
org.argeo.security.jcr,
org.argeo.slc.core.attachment,
org.argeo.slc.core.execution,
org.argeo.slc.test,
org.springframework.beans.factory.config,
org.springframework.osgi.util,
+ org.springframework.security;specification-version="2.0.6.RELEASE",
org.springframework.web.context.request
<!-- REFERENCES -->\r
<reference id="nodeRepository" interface="javax.jcr.Repository"\r
filter="(argeo.jcr.repository.alias=slc)" />\r
- <reference id="systemExecutionService" interface="org.argeo.security.SystemExecutionService" />\r
+\r
+ <reference id="modulesManager"\r
+ interface="org.argeo.slc.execution.ExecutionModulesManager" />\r
+ <reference id="authenticationManager"\r
+ interface="org.springframework.security.AuthenticationManager" />\r
\r
<!-- SERVICES -->\r
<service interface="org.argeo.slc.execution.ExecutionModulesListener"\r
ref="executionModulesListener" />\r
+ <service ref="agent" interface="org.argeo.slc.runtime.SlcAgentFactory" />\r
+ <service ref="agent" interface="org.argeo.slc.runtime.SlcAgent" />\r
\r
<!-- <service interface="org.argeo.slc.dao.process.SlcExecutionDao" -->\r
<!-- ref="slcExecutionDao" /> -->\r
<!-- </property> -->\r
<!-- </bean> -->\r
\r
+ <bean id="agent" class="org.argeo.slc.jcr.execution.JcrAgent"\r
+ init-method="init" destroy-method="dispose">\r
+ <property name="session" ref="session" />\r
+ <property name="modulesManager" ref="modulesManager" />\r
+ </bean>\r
+\r
<bean id="executionModulesListener" class="org.argeo.slc.jcr.execution.JcrExecutionModulesListener"\r
init-method="init" destroy-method="dispose">\r
+ <property name="agent" ref="agent" />\r
<property name="session" ref="session" />\r
</bean>\r
\r
- <bean id="session" class="org.argeo.security.jcr.SystemSession">\r
+ <bean id="session" class="org.argeo.security.jcr.SecureThreadBoundSession">\r
<property name="repository" ref="nodeRepository" />\r
- <property name="systemExecutionService" ref="systemExecutionService" />\r
+ </bean>\r
+\r
+ <bean class="org.argeo.security.core.SystemExecutionBeanPostProcessor">\r
+ <property name="authenticationManager" ref="authenticationManager" />\r
</bean>\r
\r
<!-- <bean id="slcAgentDescriptorDao" class="org.argeo.slc.jcr.dao.SlcAgentDescriptorDaoJcr" -->\r
import org.argeo.slc.runtime.SlcAgent;
import org.argeo.slc.runtime.SlcAgentDescriptor;
+/** Implements the base methods of an SLC agent. */
public class DefaultAgent implements SlcAgent {
- // private final static Log log = LogFactory.getLog(AbstractAgent.class);
-
- private final SlcAgentDescriptor agentDescriptor;
+ private SlcAgentDescriptor agentDescriptor;
private ExecutionModulesManager modulesManager;
- public DefaultAgent() {
+ /*
+ * LIFECYCLE
+ */
+ public void init() {
try {
agentDescriptor = new SlcAgentDescriptor();
- agentDescriptor.setUuid(UUID.randomUUID().toString());
+ agentDescriptor.setUuid(initAgentUuid());
agentDescriptor.setHost(InetAddress.getLocalHost().getHostName());
} catch (UnknownHostException e) {
throw new SlcException("Unable to create agent descriptor.", e);
}
}
+ public void dispose() {
+
+ }
+
+ /**
+ * Called during initialization in order to determines the agent UUID. To be
+ * overridden. By default creates a new one per instance.
+ */
+ protected String initAgentUuid() {
+ return UUID.randomUUID().toString();
+ }
+
+ /*
+ * SLC AGENT
+ */
public void runSlcExecution(final SlcExecution slcExecution) {
modulesManager.process(slcExecution);
}
return true;
}
+ /*
+ * BEAN
+ */
public void setModulesManager(ExecutionModulesManager modulesManager) {
this.modulesManager = modulesManager;
}
- public ExecutionModulesManager getModulesManager() {
- return modulesManager;
- }
-
protected SlcAgentDescriptor getAgentDescriptor() {
return agentDescriptor;
}
public String getAgentUuid() {
- return getAgentDescriptor().getUuid();
+ return agentDescriptor.getUuid();
}
@Override
import org.argeo.slc.BasicNameVersion;
+/** The description of a versioned module. */
public class ModuleDescriptor extends BasicNameVersion {
- private static final long serialVersionUID = 3703329250058821882L;
- private String label;
+ private static final long serialVersionUID = 4310820315478645419L;
+ private String title;
private String description;
- public String getLabel() {
- return label;
+ public String getTitle() {
+ return title;
}
- public void setLabel(String label) {
- this.label = label;
+ public void setTitle(String title) {
+ this.title = title;
}
public String getDescription() {
this.description = description;
}
+ /** @deprecated use {@link #getTitle()} instead */
+ public String getLabel() {
+ return title;
+ }
+
+ /** @deprecated use {@link #setTitle(String)} instead */
+ public void setLabel(String label) {
+ this.title = label;
+ }
+
}
/**
* The class implementing this interface defines the map of attributes that are
* necessary for the corresponding ExecutionFlow.
- *
- * @author bsinou
*/
public interface ExecutionSpec {
public Map<String, ExecutionSpecAttribute> getAttributes();
package org.argeo.slc.execution;
/**
- *
* This interface stands for one attribute of a given flow.
*
* We mainly have two implementations :
* the application context + the display of some choices among which the end
* user can choose.
*
- * Note :
- *
+ * @see org.argeo.slc.core.execution.PrimitiveSpecAttribute
+ * @see org.argeo.slc.core.execution.RefSpecAttribute
* @see org.argeo.slc.core.execution.PrimitiveUtils : this class offers some
* helper, among others to cast the various type of primitive attribute.
- *
- * @author bsinou
- *
*/
public interface ExecutionSpecAttribute {
public Object getValue();
import org.argeo.slc.msg.ReferenceList;
import org.argeo.slc.process.SlcExecution;
import org.argeo.slc.runtime.SlcAgentDescriptor;
-import org.springframework.beans.factory.DisposableBean;
-import org.springframework.beans.factory.InitializingBean;
import org.springframework.jms.JmsException;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessagePostProcessor;
-/** JMS based implementation of SLC Agent. */
-public class JmsAgent extends DefaultAgent implements InitializingBean,
- DisposableBean, MessageListener {
+/** JMS based implementation of an SLC Agent. */
+public class JmsAgent extends DefaultAgent implements MessageListener {
public final static String PROPERTY_QUERY = "query";
public final static String QUERY_PING_ALL = "pingAll";
private Destination responseDestination;
- public void afterPropertiesSet() throws Exception {
+ public void init() {
+ super.init();
try {
jmsTemplate.convertAndSend(agentRegister, getAgentDescriptor());
log.info("Agent #" + getAgentUuid() + " registered to "
+ agentRegister);
} catch (JmsException e) {
- log
- .warn("Could not register agent "
- + getAgentDescriptor().getUuid()
- + " to server: "
- + e.getMessage()
- + ". The agent will stay offline but will keep listening for a ping all sent by server.");
+ log.warn("Could not register agent "
+ + getAgentDescriptor().getUuid()
+ + " to server: "
+ + e.getMessage()
+ + ". The agent will stay offline but will keep listening for a ping all sent by server.");
if (log.isTraceEnabled())
log.debug("Original error.", e);
}
}
- public void destroy() throws Exception {
+ public void dispose() {
try {
jmsTemplate.convertAndSend(agentUnregister, getAgentDescriptor());
log.info("Agent #" + getAgentUuid() + " unregistered from "
if (log.isTraceEnabled())
log.debug("Original error.", e);
}
+ super.dispose();
}
public void setAgentRegister(Destination agentRegister) {
+++ /dev/null
-package org.argeo.slc.jcr;
-
-import java.util.List;
-
-import org.argeo.slc.execution.ExecutionModuleDescriptor;
-import org.argeo.slc.process.SlcExecution;
-import org.argeo.slc.runtime.SlcAgent;
-
-public class JcrAgent implements SlcAgent {
-
- public String getAgentUuid() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public ExecutionModuleDescriptor getExecutionModuleDescriptor(
- String moduleName, String version) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public List<ExecutionModuleDescriptor> listExecutionModuleDescriptors() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void runSlcExecution(SlcExecution slcExecution) {
- // TODO Auto-generated method stub
-
- }
-
- public boolean ping() {
- // TODO Auto-generated method stub
- return false;
- }
-
-}
--- /dev/null
+package org.argeo.slc.jcr;
+
+public interface SlcJcrConstants {
+ public final static String AGENTS_BASE_PATH = "/slc/agents";
+ public final static String VM_AGENT_FACTORY_PATH = AGENTS_BASE_PATH + "/vm";
+}
public final static String SLC_NAME = "slc:name";
public final static String SLC_VERSION = "slc:version";
public final static String SLC_FLOWS = "slc:flows";
+ public final static String SLC_EXECUTION_MODULES = "slc:executionModules";
}
--- /dev/null
+package org.argeo.slc.jcr.execution;
+
+import java.util.List;
+import java.util.UUID;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.core.runtime.DefaultAgent;
+import org.argeo.slc.jcr.SlcJcrConstants;
+import org.argeo.slc.runtime.SlcAgent;
+import org.argeo.slc.runtime.SlcAgentFactory;
+
+/** SLC agent synchronizing with a JCR repository. */
+public class JcrAgent extends DefaultAgent implements SlcAgentFactory {
+ private Session session;
+
+ /*
+ * LIFECYCLE
+ */
+ protected String initAgentUuid() {
+ try {
+ Node vmAgentFactoryNode = JcrUtils.mkdirs(session,
+ SlcJcrConstants.VM_AGENT_FACTORY_PATH);
+ if (!vmAgentFactoryNode.hasNodes()) {
+ String uuid = UUID.randomUUID().toString();
+ vmAgentFactoryNode.addNode(uuid);
+ }
+ session.save();
+
+ return vmAgentFactoryNode.getNodes().nextNode().getName();
+ } catch (RepositoryException e) {
+ throw new SlcException("Cannot find JCR agent UUID", e);
+ } finally {
+ JcrUtils.discardQuietly(session);
+ }
+ }
+
+ public void dispose() {
+
+ }
+
+ /*
+ * SLC AGENT FACTORY
+ */
+ public SlcAgent getAgent(String uuid) {
+ return this;
+ }
+
+ public void pingAll(List<String> activeAgentIds) {
+ ping();
+ }
+
+ /*
+ * BEAN METHODS
+ */
+ public void setSession(Session session) {
+ this.session = session;
+ }
+
+}
import org.argeo.slc.execution.ExecutionContext;
import org.argeo.slc.execution.ExecutionFlow;
import org.argeo.slc.execution.ExecutionModulesListener;
+import org.argeo.slc.jcr.SlcJcrConstants;
+import org.argeo.slc.jcr.SlcNames;
+import org.argeo.slc.runtime.SlcAgent;
/**
- * Synchronizes the execution runtime with JCR. For the time being the state is
- * completely reset from one start to another.
+ * Synchronizes the local execution runtime with a JCR repository. For the time
+ * being the state is completely reset from one start to another.
*/
public class JcrExecutionModulesListener implements ExecutionModulesListener {
private final static Log log = LogFactory
.getLog(JcrExecutionModulesListener.class);
- private String modulesPath = "/slc/modules";
-
private Session session;
+ private SlcAgent agent;
public void init() {
try {
+ String modulesPath = getExecutionModulesPath();
// clean up previous state
if (session.nodeExists(modulesPath))
session.getNode(modulesPath).remove();
public void dispose() {
try {
+ String modulesPath = getExecutionModulesPath();
// clean up previous state
if (session.nodeExists(modulesPath))
session.getNode(modulesPath).remove();
public void executionModuleAdded(Module module,
ExecutionContext executionContext) {
try {
- Node base = session.getNode(modulesPath);
+ Node base = session.getNode(getExecutionModulesPath());
Node moduleName = base.hasNode(module.getName()) ? base
.getNode(module.getName()) : base.addNode(module.getName());
Node moduleVersion = moduleName.hasNode(module.getVersion()) ? moduleName
public void executionModuleRemoved(Module module,
ExecutionContext executionContext) {
try {
- Node base = session.getNode(modulesPath);
+ Node base = session.getNode(getExecutionModulesPath());
if (base.hasNode(module.getName())) {
Node moduleName = base.getNode(module.getName());
if (moduleName.hasNode(module.getVersion()))
try {
Node flowNode;
if (!session.nodeExists(path)) {
- Node base = session.getNode(modulesPath);
+ Node base = session.getNode(getExecutionModulesPath());
Node moduleNode = base.getNode(module.getName() + '/'
+ module.getVersion());
String relativePath = getExecutionFlowRelativePath(executionFlow);
protected String getExecutionFlowPath(Module module,
ExecutionFlow executionFlow) {
String relativePath = getExecutionFlowRelativePath(executionFlow);
- return modulesPath + '/' + module.getName() + '/' + module.getVersion()
- + '/' + relativePath;
+ return getExecutionModulesPath() + '/' + module.getName() + '/'
+ + module.getVersion() + '/' + relativePath;
}
/** @return the relative path, never starts with '/' */
return relativePath;
}
+ protected String getExecutionModulesPath() {
+ return SlcJcrConstants.VM_AGENT_FACTORY_PATH + '/'
+ + agent.getAgentUuid() + '/' + SlcNames.SLC_EXECUTION_MODULES;
+ }
+
public void setSession(Session session) {
this.session = session;
}
+ public void setAgent(SlcAgent agent) {
+ this.agent = agent;
+ }
+
}