## Levels
log4j.logger.org.argeo=DEBUG
-log4j.logger.org.argeo.slc.execution.ExecutionParameterPostProcessor=TRACE
-log4j.logger.org.argeo.slc.execution.ExecutionContext=DEBUG
-log4j.logger.org.argeo.slc.execution.SimpleExecutionSpec=DEBUG
-log4j.logger.org.argeo.security.mvc.ArgeoRememberMeServices=WARN
-log4j.logger.org.argeo.server.jackrabbit.webdav.ExtendedDispatcherServlet=WARN
-#log4j.logger.org.argeo.server.jcr.mvc.OpenSessionInViewJcrInterceptor=TRACE
-
-log4j.logger.org.argeo.slc.client.ui.views.ExecutionModulesContentProvider=TRACE
-
-#log4j.logger.org.argeo.slc.web.mvc=TRACE
-#log4j.logger.org.argeo.slc.jms=TRACE
-#log4j.logger.org.argeo.server.json=TRACE
+log4j.logger.org.argeo.slc.osgi.OsgiExecutionModulesManager=TRACE
log4j.logger.org.eclipse.rap=INFO
log4j.logger.org.springframework=WARN
#log4j.logger.org.springframework.web=DEBUG
-#log4j.logger.org.springframework.jms=WARN
-#log4j.logger.org.springframework.security=DEBUG
-#log4j.logger.org.springframework.ldap=TRACE
-#log4j.logger.org.springframework.osgi=INFO
log4j.logger.org.apache.activemq=INFO
#log4j.logger.org.apache.activemq.transport=WARN
argeo.osgi.start=\
org.springframework.osgi.extender,\
org.argeo.slc.client.rcp,\
+org.argeo.slc.server.jcr,\
org.argeo.slc.demo.ant,\
org.argeo.slc.demo.basic,\
<!-- Manager -->\r
<bean id="modulesManager" class="org.argeo.slc.osgi.OsgiExecutionModulesManager">\r
<property name="slcExecutionNotifiers" ref="slcExecutionListeners" />\r
- <property name="executionModulesListeners" ref="executionModulesListeners" />\r
<property name="bundlesManager" ref="bundlesManager" />\r
</bean>\r
\r
\r
<beans:import resource="classpath:org/argeo/slc/osgi/manager.xml" />\r
\r
- <service ref="modulesManager" interface="org.argeo.slc.execution.ExecutionModulesManager" />\r
+ <!-- REFERENCES -->\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
+ <list id="executionFlows" interface="org.argeo.slc.execution.ExecutionFlow"\r
+ cardinality="0..N">\r
+ <listener ref="modulesManager" bind-method="register"\r
+ unbind-method="unregister" />\r
+ </list>\r
\r
- <list id="slcExecutionListeners" interface="org.argeo.slc.process.SlcExecutionNotifier"\r
- cardinality="0..N" />\r
<list id="executionModulesListeners" interface="org.argeo.slc.execution.ExecutionModulesListener"\r
+ cardinality="0..N">\r
+ <listener ref="modulesManager" bind-method="register"\r
+ unbind-method="unregister" />\r
+ </list>\r
+\r
+ <list id="slcExecutionListeners" interface="org.argeo.slc.process.SlcExecutionNotifier"\r
cardinality="0..N" />\r
\r
+ <!-- SERVICES -->\r
+ <service ref="modulesManager" interface="org.argeo.slc.execution.ExecutionModulesManager" />\r
+\r
+\r
</beans:beans>
\ No newline at end of file
Import-Package: javax.jcr,
org.argeo.jcr,
org.argeo.jcr.mvc,
+ org.argeo.jcr.spring,
+ org.argeo.security,
+ org.argeo.security.jcr,
org.argeo.slc.core.attachment,
org.argeo.slc.core.execution,
org.argeo.slc.core.structure,
org.argeo.slc.dao.test.tree,
org.argeo.slc.execution,
org.argeo.slc.jcr.dao,
+ org.argeo.slc.jcr.execution,
org.argeo.slc.process,
org.argeo.slc.runtime,
org.argeo.slc.test,
http://www.springframework.org/schema/beans \r
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
\r
- <reference id="jcrRepository" interface="javax.jcr.Repository" />\r
+ <!-- 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
- <service interface="org.argeo.slc.dao.process.SlcExecutionDao"\r
- ref="slcExecutionDao" />\r
- <service interface="org.argeo.slc.dao.test.tree.TreeTestResultDao"\r
- ref="testResultDao" />\r
- <service interface="org.argeo.slc.dao.test.tree.TreeTestResultCollectionDao"\r
- ref="testResultCollectionDao" />\r
- <service interface="org.argeo.slc.dao.test.TestRunDescriptorDao"\r
- ref="testRunDescriptorDao" />\r
- <service interface="org.argeo.slc.dao.runtime.SlcAgentDescriptorDao"\r
- ref="slcAgentDescriptorDao" />\r
+ <!-- SERVICES -->\r
+ <service interface="org.argeo.slc.execution.ExecutionModulesListener"\r
+ ref="executionModulesListener" />\r
\r
- <service\r
- interface="org.springframework.web.context.request.WebRequestInterceptor"\r
- ref="osivInterceptor" />\r
+ <!-- <service interface="org.argeo.slc.dao.process.SlcExecutionDao" -->\r
+ <!-- ref="slcExecutionDao" /> -->\r
+ <!-- <service interface="org.argeo.slc.dao.test.tree.TreeTestResultDao" -->\r
+ <!-- ref="testResultDao" /> -->\r
+ <!-- <service interface="org.argeo.slc.dao.test.tree.TreeTestResultCollectionDao" -->\r
+ <!-- ref="testResultCollectionDao" /> -->\r
+ <!-- <service interface="org.argeo.slc.dao.test.TestRunDescriptorDao" -->\r
+ <!-- ref="testRunDescriptorDao" /> -->\r
+ <!-- <service interface="org.argeo.slc.dao.runtime.SlcAgentDescriptorDao" -->\r
+ <!-- ref="slcAgentDescriptorDao" /> -->\r
+\r
+ <!-- <service -->\r
+ <!-- interface="org.springframework.web.context.request.WebRequestInterceptor" -->\r
+ <!-- ref="osivInterceptor" /> -->\r
</beans:beans>
\ No newline at end of file
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
\r
- <bean\r
- class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">\r
- <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />\r
- <property name="ignoreUnresolvablePlaceholders" value="true" />\r
- </bean>\r
+ <!-- <bean -->\r
+ <!-- class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> -->\r
+ <!-- <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" \r
+ /> -->\r
+ <!-- <property name="locations"> -->\r
+ <!-- <value>osgibundle:jcr.properties</value> -->\r
+ <!-- </property> -->\r
+ <!-- </bean> -->\r
\r
- <bean id="slcAgentDescriptorDao" class="org.argeo.slc.jcr.dao.SlcAgentDescriptorDaoJcr"\r
- init-method="init">\r
- <property name="session" ref="jcrSession" />\r
- <property name="nodeMapperProvider" ref="nodeMapperProvider" />\r
+ <bean id="executionModulesListener" class="org.argeo.slc.jcr.execution.JcrExecutionModulesListener"\r
+ init-method="init" destroy-method="dispose">\r
+ <property name="session" ref="session" />\r
</bean>\r
\r
- <bean id="testRunDescriptorDao" class="org.argeo.slc.jcr.dao.TestRunDescriptorDaoJcr"\r
- init-method="init">\r
- <property name="session" ref="jcrSession" />\r
- <property name="nodeMapperProvider" ref="nodeMapperProvider" />\r
+ <bean id="session" class="org.argeo.security.jcr.SystemSession">\r
+ <property name="repository" ref="nodeRepository" />\r
+ <property name="systemExecutionService" ref="systemExecutionService" />\r
</bean>\r
\r
- <bean id="slcExecutionDao" class="org.argeo.slc.jcr.dao.SlcExecutionDaoJcr"\r
- init-method="init">\r
- <property name="session" ref="jcrSession" />\r
- <property name="nodeMapperProvider" ref="nodeMapperProvider" />\r
- </bean>\r
+ <!-- <bean id="slcAgentDescriptorDao" class="org.argeo.slc.jcr.dao.SlcAgentDescriptorDaoJcr" -->\r
+ <!-- init-method="init"> -->\r
+ <!-- <property name="session" ref="jcrSession" /> -->\r
+ <!-- <property name="nodeMapperProvider" ref="nodeMapperProvider" /> -->\r
+ <!-- </bean> -->\r
\r
- <bean id="nodeMapperProvider" class="org.argeo.slc.jcr.dao.SlcNodeMapperProvider"\r
- init-method="init">\r
- <property name="defaultNodeMapper" ref="nodeMapper" />\r
- <property name="treeTestResultNodeMapper" ref="treeTestResultNodeMapper" />\r
- </bean>\r
+ <!-- <bean id="testRunDescriptorDao" class="org.argeo.slc.jcr.dao.TestRunDescriptorDaoJcr" -->\r
+ <!-- init-method="init"> -->\r
+ <!-- <property name="session" ref="jcrSession" /> -->\r
+ <!-- <property name="nodeMapperProvider" ref="nodeMapperProvider" /> -->\r
+ <!-- </bean> -->\r
\r
- <bean id="testResultDao" class="org.argeo.slc.jcr.dao.TreeTestResultDaoJcr"\r
- init-method="init">\r
- <property name="session" ref="jcrSession" />\r
- <property name="nodeMapperProvider" ref="nodeMapperProvider" />\r
- </bean>\r
+ <!-- <bean id="slcExecutionDao" class="org.argeo.slc.jcr.dao.SlcExecutionDaoJcr" -->\r
+ <!-- init-method="init"> -->\r
+ <!-- <property name="session" ref="jcrSession" /> -->\r
+ <!-- <property name="nodeMapperProvider" ref="nodeMapperProvider" /> -->\r
+ <!-- </bean> -->\r
\r
- <bean id="testResultCollectionDao" class="org.argeo.slc.jcr.dao.TreeTestResultCollectionDaoJcr"\r
- init-method="init">\r
- <property name="session" ref="jcrSession" />\r
- <property name="nodeMapperProvider" ref="nodeMapperProvider" />\r
- </bean>\r
+ <!-- <bean id="nodeMapperProvider" class="org.argeo.slc.jcr.dao.SlcNodeMapperProvider" -->\r
+ <!-- init-method="init"> -->\r
+ <!-- <property name="defaultNodeMapper" ref="nodeMapper" /> -->\r
+ <!-- <property name="treeTestResultNodeMapper" ref="treeTestResultNodeMapper" \r
+ /> -->\r
+ <!-- </bean> -->\r
\r
- <bean id="osivInterceptor"\r
- class="org.argeo.server.jcr.mvc.OpenSessionInViewJcrInterceptor">\r
- <property name="session" ref="jcrSession" />\r
- </bean>\r
+ <!-- <bean id="testResultDao" class="org.argeo.slc.jcr.dao.TreeTestResultDaoJcr" -->\r
+ <!-- init-method="init"> -->\r
+ <!-- <property name="session" ref="jcrSession" /> -->\r
+ <!-- <property name="nodeMapperProvider" ref="nodeMapperProvider" /> -->\r
+ <!-- </bean> -->\r
\r
- <!-- JCR node mappers -->\r
- <bean id="bundleClassLoader"\r
- class="org.springframework.osgi.util.BundleDelegatingClassLoader"\r
- factory-method="createBundleClassLoaderFor">\r
- <constructor-arg>\r
- <bean factory-bean="bundleContext" factory-method="getBundle" />\r
- </constructor-arg>\r
- </bean>\r
+ <!-- <bean id="testResultCollectionDao" class="org.argeo.slc.jcr.dao.TreeTestResultCollectionDaoJcr" -->\r
+ <!-- init-method="init"> -->\r
+ <!-- <property name="session" ref="jcrSession" /> -->\r
+ <!-- <property name="nodeMapperProvider" ref="nodeMapperProvider" /> -->\r
+ <!-- </bean> -->\r
\r
- <bean id="nodeMapper" class="org.argeo.jcr.BeanNodeMapper">\r
- <property name="classLoader" ref="bundleClassLoader" />\r
- </bean>\r
+ <!-- <bean id="osivInterceptor" -->\r
+ <!-- class="org.argeo.server.jcr.mvc.OpenSessionInViewJcrInterceptor"> -->\r
+ <!-- <property name="session" ref="jcrSession" /> -->\r
+ <!-- </bean> -->\r
\r
- <bean id="treeTestResultNodeMapper" class="org.argeo.slc.jcr.dao.TreeTestResultNodeMapper">\r
- <property name="classLoader" ref="bundleClassLoader" />\r
- </bean>\r
- <!--\r
+ <!-- <bean id="bundleClassLoader" -->\r
+ <!-- class="org.springframework.osgi.util.BundleDelegatingClassLoader" -->\r
+ <!-- factory-method="createBundleClassLoaderFor"> -->\r
+ <!-- <constructor-arg> -->\r
+ <!-- <bean factory-bean="bundleContext" factory-method="getBundle" /> -->\r
+ <!-- </constructor-arg> -->\r
+ <!-- </bean> -->\r
\r
- <bean id="jcrSession" factory-bean="argeo.jcr.repository.inMemory"\r
- factory-method="login" destroy-method="logout" scope="request">\r
- <constructor-arg> <bean\r
- class="org.argeo.server.jcr.security.SpringSecurityCredentials" />\r
- </constructor-arg> </bean>\r
- -->\r
- <bean id="jcrSession"\r
- class="org.argeo.jcr.ThreadBoundJcrSessionFactory">\r
- <property name="repository" ref="jcrRepository" />\r
- </bean>\r
+ <!-- <bean id="nodeMapper" class="org.argeo.jcr.BeanNodeMapper"> -->\r
+ <!-- <property name="classLoader" ref="bundleClassLoader" /> -->\r
+ <!-- </bean> -->\r
+\r
+ <!-- <bean id="treeTestResultNodeMapper" class="org.argeo.slc.jcr.dao.TreeTestResultNodeMapper"> -->\r
+ <!-- <property name="classLoader" ref="bundleClassLoader" /> -->\r
+ <!-- </bean> -->\r
</beans>
\ No newline at end of file
import org.argeo.slc.execution.ExecutionContext;
import org.argeo.slc.execution.ExecutionFlow;
import org.argeo.slc.execution.ExecutionFlowDescriptorConverter;
-import org.argeo.slc.execution.ExecutionModulesListener;
import org.argeo.slc.execution.ExecutionModulesManager;
import org.argeo.slc.process.RealizedFlow;
import org.argeo.slc.process.SlcExecution;
.getLog(AbstractExecutionModulesManager.class);
private List<SlcExecutionNotifier> slcExecutionNotifiers = new ArrayList<SlcExecutionNotifier>();
- private List<ExecutionModulesListener> executionModulesListeners = new ArrayList<ExecutionModulesListener>();
private ThreadGroup processesThreadGroup = new ThreadGroup("Processes");
return processesThreadGroup;
}
- protected List<ExecutionModulesListener> getExecutionModulesListeners() {
- return executionModulesListeners;
- }
-
- public void setExecutionModulesListeners(
- List<ExecutionModulesListener> executionModulesListeners) {
- this.executionModulesListeners = executionModulesListeners;
- }
-
}
import org.aspectj.lang.annotation.Pointcut;
@Aspect
+/** Aspect intercepting calls on execution flows and contexts. */
public class ExecutionAspect {
private final static Log log = LogFactory.getLog(ExecutionAspect.class);
}
}
- @Around("runnableExecution()")
- public void aroundRunnable(ProceedingJoinPoint pjp) throws Throwable {
- ExecutionFlow executionFlow = (ExecutionFlow) pjp.getTarget();
- Runnable runnable = (Runnable) pjp.getArgs()[0];
- if (log.isDebugEnabled())
- logRunnableExecution(executionFlow, runnable);
- // Actually execute the runnable
- pjp.proceed();
- }
-
@Around("getVariable()")
public Object aroundGetVariable(ProceedingJoinPoint pjp) throws Throwable {
Object obj = pjp.proceed();
public void flowExecution() {
}
- @Pointcut("execution(void org.argeo.slc.execution.ExecutionFlow.doExecuteRunnable(..))")
- public void runnableExecution() {
- }
-
@Pointcut("execution(* org.argeo.slc.execution.ExecutionContext.getVariable(..))")
public void getVariable() {
}
}
public void run() {
- log.info("\n##\n## SLC Process " + slcProcess + " STARTED\n##");
+ log.info("\n##\n## SLC Process #" + slcProcess.getUuid()
+ + " STARTED\n##\n");
slcProcess.setStatus(SlcExecution.STATUS_RUNNING);
executionModulesManager.dispatchUpdateStatus(slcProcess,
executionModulesManager.dispatchUpdateStatus(slcProcess,
SlcExecution.STATUS_RUNNING, slcProcess.getStatus());
- log.info("## SLC Process " + slcProcess + " COMPLETED");
+ log.info("\n## SLC Process #" + slcProcess.getUuid() + " COMPLETED\n");
}
public void notifyError() {
package org.argeo.slc.execution;
+/** Abstraction of an execution that can be identified and configured. */
public interface ExecutionFlow extends Runnable {
+ /** Retrieve an immutable parameter */
public Object getParameter(String key);
+ /** Whether this immutable parameter is set */
public Boolean isSetAsParameter(String key);
+ /** The specifications of the execution flow. */
public ExecutionSpec getExecutionSpec();
+ /**
+ * The name of this execution flow. Can contains '/' which will be
+ * interpreted by UIs as a hierarchy;
+ */
public String getName();
- public String getPath();
-
/**
- * Actually performs the execution of the Runnable. This method should never
- * be called directly. The implementation should provide a reasonable
- * default, but it is meant to be intercepted either to analyze what is run
- * or to override the default behavior.
+ * @deprecated will be removed in SLC 2.0, the path should be the part of
+ * the name with '/'
*/
- public void doExecuteRunnable(Runnable runnable);
+ public String getPath();
}
*
* Generally, values object are either a <code>PrimitiveAccessor</code> or a
* <code>RefValue</code> but can be other objects.
- *
- * @author bsinou
- *
- *
*/
public class ExecutionFlowDescriptor implements Serializable {
private static final long serialVersionUID = 7101944857038041216L;
return name;
}
+ /**
+ * @deprecated will be removed in SLC 2.0, the path should be the part of
+ * the name with '/'
+ */
public String getPath() {
return path;
}
+ /**
+ * @deprecated will be removed in SLC 2.0, the path should be the part of
+ * the name with '/'
+ */
public void setPath(String path) {
this.path = path;
}
--- /dev/null
+package org.argeo.slc.jcr.execution;
+
+import java.util.Arrays;
+import java.util.Iterator;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.deploy.Module;
+import org.argeo.slc.execution.ExecutionContext;
+import org.argeo.slc.execution.ExecutionFlow;
+import org.argeo.slc.execution.ExecutionModulesListener;
+
+/**
+ * Synchronizes the execution runtime with JCR. 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;
+
+ public void init() {
+ try {
+ // clean up previous state
+ if (session.nodeExists(modulesPath))
+ session.getNode(modulesPath).remove();
+ JcrUtils.mkdirs(session, modulesPath);
+ session.save();
+ } catch (RepositoryException e) {
+ throw new SlcException(
+ "Cannot initialize JCR execution module listener", e);
+ } finally {
+ JcrUtils.discardQuietly(session);
+ }
+ }
+
+ public void dispose() {
+ try {
+ // clean up previous state
+ if (session.nodeExists(modulesPath))
+ session.getNode(modulesPath).remove();
+ session.save();
+ } catch (RepositoryException e) {
+ throw new SlcException(
+ "Cannot dispose JCR execution module listener", e);
+ } finally {
+ JcrUtils.discardQuietly(session);
+ }
+ }
+
+ public void executionModuleAdded(Module module,
+ ExecutionContext executionContext) {
+ try {
+ Node base = session.getNode(modulesPath);
+ Node moduleName = base.hasNode(module.getName()) ? base
+ .getNode(module.getName()) : base.addNode(module.getName());
+ Node moduleVersion = moduleName.hasNode(module.getVersion()) ? moduleName
+ .getNode(module.getVersion()) : moduleName.addNode(module
+ .getVersion());
+ session.save();
+ } catch (RepositoryException e) {
+ throw new SlcException("Cannot add module " + module, e);
+ }
+
+ }
+
+ public void executionModuleRemoved(Module module,
+ ExecutionContext executionContext) {
+ try {
+ Node base = session.getNode(modulesPath);
+ if (base.hasNode(module.getName())) {
+ Node moduleName = base.getNode(module.getName());
+ if (moduleName.hasNode(module.getVersion()))
+ moduleName.getNode(module.getVersion()).remove();
+ if (!moduleName.hasNodes())
+ moduleName.remove();
+ session.save();
+ }
+ } catch (RepositoryException e) {
+ throw new SlcException("Cannot remove module " + module, e);
+ }
+ }
+
+ public void executionFlowAdded(Module module, ExecutionFlow executionFlow) {
+ String path = getExecutionFlowPath(module, executionFlow);
+ log.debug("path=" + path);
+ try {
+ Node flowNode;
+ if (!session.nodeExists(path)) {
+ Node base = session.getNode(modulesPath);
+ Node moduleNode = base.getNode(module.getName() + '/'
+ + module.getVersion());
+ String relativePath = getExecutionFlowRelativePath(executionFlow);
+ log.debug("relativePath='" + relativePath + "'");
+ Iterator<String> names = Arrays.asList(relativePath.split("/"))
+ .iterator();
+ Node currNode = moduleNode;
+ while (names.hasNext()) {
+ String name = names.next();
+ if (currNode.hasNode(name))
+ currNode = currNode.getNode(name);
+ else {
+ if (names.hasNext())
+ currNode = currNode.addNode(name);
+ else
+ flowNode = currNode.addNode(name);
+ }
+ }
+ session.save();
+ } else {
+ flowNode = session.getNode(path);
+ }
+ } catch (RepositoryException e) {
+ throw new SlcException("Cannot add flow " + executionFlow
+ + " from module " + module, e);
+ }
+
+ }
+
+ public void executionFlowRemoved(Module module, ExecutionFlow executionFlow) {
+ String path = getExecutionFlowPath(module, executionFlow);
+ try {
+ if (session.nodeExists(path)) {
+ Node flowNode = session.getNode(path);
+ flowNode.remove();
+ session.save();
+ }
+ } catch (RepositoryException e) {
+ throw new SlcException("Cannot remove flow " + executionFlow
+ + " from module " + module, e);
+ }
+ }
+
+ protected String getExecutionFlowPath(Module module,
+ ExecutionFlow executionFlow) {
+ String relativePath = getExecutionFlowRelativePath(executionFlow);
+ return modulesPath + '/' + module.getName() + '/' + module.getVersion()
+ + '/' + relativePath;
+ }
+
+ /** @return the relative path, never starts with '/' */
+ @SuppressWarnings("deprecation")
+ protected String getExecutionFlowRelativePath(ExecutionFlow executionFlow) {
+ String relativePath = executionFlow.getPath() == null ? executionFlow
+ .getName() : executionFlow.getPath() + '/'
+ + executionFlow.getName();
+ // we assume that it is more than one char long
+ if (relativePath.charAt(0) == '/')
+ relativePath = relativePath.substring(1);
+ return relativePath;
+ }
+
+ public void setSession(Session session) {
+ this.session = session;
+ }
+
+}
import org.osgi.framework.Constants;
import org.springframework.osgi.service.importer.OsgiServiceLifecycleListener;
+/** Execution modules manager implementation based on an OSGi runtime. */
public class OsgiExecutionModulesManager extends
AbstractExecutionModulesManager implements OsgiServiceLifecycleListener {
private Map<OsgiBundle, Set<ExecutionFlow>> executionFlows = new HashMap<OsgiBundle, Set<ExecutionFlow>>();
private ExecutionFlowDescriptorConverter defaultDescriptorConverter = new DefaultExecutionFlowDescriptorConverter();
+ private List<ExecutionModulesListener> executionModulesListeners = new ArrayList<ExecutionModulesListener>();
+
public synchronized ExecutionModuleDescriptor getExecutionModuleDescriptor(
String moduleName, String version) {
ExecutionModuleDescriptor md = new ExecutionModuleDescriptor();
ExecutionFlowDescriptorConverter.class, filter);
}
- public void setBundlesManager(BundlesManager bundlesManager) {
- this.bundlesManager = bundlesManager;
- }
-
/**
* Builds a minimal realized flow, based on the provided information
* (typically from the command line).
return obj.toString();
}
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public synchronized void bind(Object service, Map properties)
- throws Exception {
- if (service instanceof ExecutionContext) {
- ExecutionContext executionContext = (ExecutionContext) service;
- OsgiBundle osgiBundle = asOsgiBundle(properties);
- Bundle bundle = bundlesManager.findRelatedBundle(osgiBundle);
- osgiBundle.setLabel(getHeaderSafe(bundle, Constants.BUNDLE_NAME));
- osgiBundle.setDescription(getHeaderSafe(bundle,
- Constants.BUNDLE_DESCRIPTION));
- executionContexts.put(osgiBundle, executionContext);
+ /*
+ * REGISTRATION
+ */
+
+ /** Registers an execution context. */
+ public synchronized void register(ExecutionContext executionContext,
+ Map<String, String> properties) {
+ OsgiBundle osgiBundle = asOsgiBundle(properties);
+ Bundle bundle = bundlesManager.findRelatedBundle(osgiBundle);
+ osgiBundle.setLabel(getHeaderSafe(bundle, Constants.BUNDLE_NAME));
+ osgiBundle.setDescription(getHeaderSafe(bundle,
+ Constants.BUNDLE_DESCRIPTION));
+ executionContexts.put(osgiBundle, executionContext);
+ if (log.isTraceEnabled())
+ log.trace("Registered execution context from " + osgiBundle);
+ // Notify
+ for (ExecutionModulesListener listener : executionModulesListeners)
+ listener.executionModuleAdded(osgiBundle, executionContext);
+ }
+
+ /** Unregisters an execution context. */
+ public synchronized void unregister(ExecutionContext executionContext,
+ Map<String, String> properties) {
+ OsgiBundle osgiBundle = asOsgiBundle(properties);
+ if (executionContexts.containsKey(osgiBundle)) {
+ executionContexts.remove(osgiBundle);
if (log.isTraceEnabled())
- log.debug("Registered execution context from " + osgiBundle);
+ log.trace("Removed execution context from " + osgiBundle);
// Notify
- for (ExecutionModulesListener listener : getExecutionModulesListeners())
- listener.executionModuleAdded(osgiBundle, executionContext);
+ for (ExecutionModulesListener listener : executionModulesListeners)
+ listener.executionModuleRemoved(osgiBundle, executionContext);
+ }
+ }
- } else if (service instanceof ExecutionFlow) {
- ExecutionFlow executionFlow = (ExecutionFlow) service;
- OsgiBundle osgiBundle = asOsgiBundle(properties);
- if (!executionFlows.containsKey(osgiBundle)) {
- executionFlows.put(osgiBundle, new HashSet());
- }
- executionFlows.get(osgiBundle).add(executionFlow);
+ /** Registers an execution flow. */
+ public synchronized void register(ExecutionFlow executionFlow,
+ Map<String, String> properties) {
+ OsgiBundle osgiBundle = asOsgiBundle(properties);
+ if (!executionFlows.containsKey(osgiBundle)) {
+ executionFlows.put(osgiBundle, new HashSet<ExecutionFlow>());
+ }
+ executionFlows.get(osgiBundle).add(executionFlow);
+ if (log.isTraceEnabled())
+ log.trace("Registered " + executionFlow + " from " + osgiBundle);
+
+ for (ExecutionModulesListener listener : executionModulesListeners)
+ listener.executionFlowAdded(osgiBundle, executionFlow);
+ }
+
+ /** Unregisters an execution flow. */
+ public synchronized void unregister(ExecutionFlow executionFlow,
+ Map<String, String> properties) {
+ OsgiBundle osgiBundle = asOsgiBundle(properties);
+ if (executionFlows.containsKey(osgiBundle)) {
+ Set<ExecutionFlow> flows = executionFlows.get(osgiBundle);
+ flows.remove(executionFlow);
if (log.isTraceEnabled())
- log.debug("Registered " + executionFlow + " from " + osgiBundle);
- for (ExecutionModulesListener listener : getExecutionModulesListeners())
- listener.executionFlowAdded(osgiBundle, executionFlow);
+ log.debug("Removed " + executionFlow + " from " + osgiBundle);
+ if (flows.size() == 0) {
+ executionFlows.remove(osgiBundle);
+ if (log.isTraceEnabled())
+ log.trace("Removed flows set from " + osgiBundle);
+ }
+ for (ExecutionModulesListener listener : executionModulesListeners)
+ listener.executionFlowRemoved(osgiBundle, executionFlow);
+ }
+ }
+
+ /** Registers an execution module listener. */
+ public synchronized void register(
+ ExecutionModulesListener executionModulesListener,
+ Map<String, String> properties) {
+ // sync with current state
+ for (OsgiBundle osgiBundle : executionContexts.keySet()) {
+ executionModulesListener.executionModuleAdded(osgiBundle,
+ executionContexts.get(osgiBundle));
+ }
+ for (OsgiBundle osgiBundle : executionFlows.keySet()) {
+ for (ExecutionFlow executionFlow : executionFlows.get(osgiBundle))
+ executionModulesListener.executionFlowAdded(osgiBundle,
+ executionFlow);
+ }
+ executionModulesListeners.add(executionModulesListener);
+ }
- } else if (service instanceof ExecutionFlowDescriptorConverter) {
+ /** Unregisters an execution module listener. */
+ public synchronized void unregister(
+ ExecutionModulesListener executionModulesListener,
+ Map<String, String> properties) {
+ executionModulesListeners.remove(executionModulesListener);
+ }
+
+ @SuppressWarnings({ "rawtypes" })
+ public synchronized void bind(Object service, Map properties)
+ throws Exception {
+ if (service instanceof ExecutionFlowDescriptorConverter) {
ExecutionFlowDescriptorConverter executionFlowDescriptorConverter = (ExecutionFlowDescriptorConverter) service;
OsgiBundle osgiBundle = asOsgiBundle(properties);
executionFlowDescriptorConverters.put(osgiBundle,
@SuppressWarnings("rawtypes")
public synchronized void unbind(Object service, Map properties)
throws Exception {
- if (service instanceof ExecutionContext) {
- OsgiBundle osgiBundle = asOsgiBundle(properties);
- if (executionContexts.containsKey(osgiBundle)) {
- ExecutionContext executionContext = executionContexts
- .remove(osgiBundle);
- if (log.isTraceEnabled())
- log.debug("Removed execution context from " + osgiBundle);
- // Notify
- for (ExecutionModulesListener listener : getExecutionModulesListeners())
- listener.executionModuleRemoved(osgiBundle,
- executionContext);
- }
- } else if (service instanceof ExecutionFlow) {
- ExecutionFlow executionFlow = (ExecutionFlow) service;
- OsgiBundle osgiBundle = asOsgiBundle(properties);
- if (executionFlows.containsKey(osgiBundle)) {
- Set flows = executionFlows.get(osgiBundle);
- flows.remove(executionFlow);
- if (log.isTraceEnabled())
- log.debug("Removed " + executionFlow + " from "
- + osgiBundle);
- if (flows.size() == 0) {
- executionFlows.remove(osgiBundle);
- if (log.isTraceEnabled())
- log.debug("Removed flows set from " + osgiBundle);
- }
- for (ExecutionModulesListener listener : getExecutionModulesListeners())
- listener.executionFlowRemoved(osgiBundle, executionFlow);
- }
- } else if (service instanceof ExecutionFlowDescriptorConverter) {
+ if (service instanceof ExecutionFlowDescriptorConverter) {
OsgiBundle osgiBundle = asOsgiBundle(properties);
if (executionFlowDescriptorConverters.containsKey(osgiBundle)) {
executionFlowDescriptorConverters.remove(osgiBundle);
return properties.get(key).toString();
}
+ public void setBundlesManager(BundlesManager bundlesManager) {
+ this.bundlesManager = bundlesManager;
+ }
+
public void setDefaultDescriptorConverter(
ExecutionFlowDescriptorConverter defaultDescriptorConverter) {
this.defaultDescriptorConverter = defaultDescriptorConverter;
}
+
}