<configuration>
<argsToAppend>
<arg>-clean</arg>
- <arg>-noExit</arg>
</argsToAppend>
<systemProperties>
<slc.osgi.bundles>${basedir}/site;in=*;ex=**/.svn/**,${basedir}/../server/org.argeo.slc.siteserver/bundles;in=*;ex=**/.svn/**</slc.osgi.bundles>
+++ /dev/null
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.argeo.slc</groupId>
- <artifactId>argeo-slc-demo</artifactId>
- <version>0.11.3-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <groupId>org.argeo.slc.demo</groupId>
- <artifactId>org.argeo.slc.demo.basic</artifactId>
- <name>Argeo SLC Demo Basic Test Module</name>
- <packaging>jar</packaging>
- <properties></properties>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifestFile>META-INF/MANIFEST.MF</manifestFile>
- </archive>
- <classesDirectory>.</classesDirectory>
- <includes>
- <include>conf/**</include>
- </includes>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
-
- <dependency>
- <groupId>org.argeo.slc.runtime</groupId>
- <artifactId>org.argeo.slc.support.equinox</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc.runtime</groupId>
- <artifactId>org.argeo.slc.support.simple</artifactId>
- </dependency>
- </dependencies>
-</project>
.getUuid());
ExecutionModuleDescriptor moduleDescMinimal = findModule(lst,
moduleName);
+ if (moduleDescMinimal == null)
+ throw new SlcException("Cannot find module " + moduleName);
String moduleVersion = moduleDescMinimal.getVersion();
ExecutionModuleDescriptor moduleDesc = getModuleDescriptor(
// the primitiveValue.type
convertedValues.put(key, primitiveValue.getValue());
} else if (value instanceof RefValue) {
- RefValue refValue = (RefValue) value;
- convertedValues.put(key, refValue.getLabel());
+ // not yet implemented
+
+// RefValue refValue = (RefValue) value;
+// convertedValues.put(key, refValue.getLabel());
}
}
}
package org.argeo.slc.core.execution;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.argeo.slc.execution.ExecutionContext;
import org.argeo.slc.execution.ExecutionFlow;
import org.aspectj.lang.JoinPoint;
-import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
-import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
@Aspect
public class ExecutionAspect {
- private static Log log = LogFactory.getLog(ExecutionAspect.class);
+ static ThreadLocal<Boolean> inModuleExecution = new ThreadLocal<Boolean>() {
+ protected Boolean initialValue() {
+ return false;
+ }
+ };
private ExecutionContext executionContext;
-
+
public ExecutionContext getExecutionContext() {
return executionContext;
}
@Before("flowExecution()")
public void beforeFlow(JoinPoint jp) throws Throwable {
- //log.debug("this " + jp.getThis().getClass());
- //log.debug("target " + jp.getTarget().getClass());
- // Thread.dumpStack();
ExecutionFlow executionFlow = (ExecutionFlow) jp.getTarget();
executionContext.enterFlow(executionFlow);
}
@After("flowExecution()")
public void afterFlow(JoinPoint jp) throws Throwable {
- //log.debug("this " + jp.getThis().getClass());
- //log.debug("target " + jp.getTarget().getClass());
ExecutionFlow executionFlow = (ExecutionFlow) jp.getTarget();
executionContext.leaveFlow(executionFlow);
}
+ @Before("moduleExecution()")
+ public void beforeModuleExecution(JoinPoint jp) throws Throwable {
+ inModuleExecution.set(true);
+ }
+
+ @After("moduleExecution()")
+ public void afterModuleExecution(JoinPoint jp) throws Throwable {
+ inModuleExecution.set(false);
+ }
+
@Pointcut("execution(void org.argeo.slc.execution.ExecutionFlow.run())")
public void flowExecution() {
}
-
-
+
+ @Pointcut("execution(void org.argeo.slc.execution.ExecutionModule.execute(..))")
+ public void moduleExecution() {
+ }
+
}
// if not, we expect objectFactory to produce an ExecutionContext
Object obj = objectFactory.getObject();
if (obj instanceof ExecutionContext) {
+ // Check whether we are in an execution
+ // FIXME: do it more properly (not static)
+ // see https://www.argeo.org/bugzilla/show_bug.cgi?id=82
+ if (!ExecutionAspect.inModuleExecution.get())
+ log
+ .error("An execution context is being instatiated outside an execution."
+ + " Please check that your references to execution contexts."
+ + " This may lead to unexpected behaviour and will be rejected in the future.");
+
// store the ExecutionContext in the ThreadLocal
executionContext.set((ExecutionContext) obj);
executionContextBeanName.set(name);
+ if (log.isDebugEnabled()) {
+ log.debug("Execution context #"
+ + executionContext.get().getUuid()
+ + " instantiated. (beanName="
+ + executionContextBeanName.get() + ")");
+// Thread.dumpStack();
+ }
return obj;
} else {
throw new SlcException(
public MapExecutionContext() {
uuid = UUID.randomUUID().toString();
- if (log.isDebugEnabled())
- log.debug("Execution context #" + uuid + " instantiated.");
}
public void addVariables(
import org.springframework.core.io.Resource;
import org.springframework.util.Assert;
-/** Workaround when execution placedholders needs to be passed. */
+/** Retrieve an OS File from the given resource. */
public class OsFileFactoryBean implements FactoryBean {
private ExecutionResources executionResources;
private Resource resource;
private Boolean overwrite = false;
- /** Return an existing file on the fiel system. */
+ /** Return an existing file on the file system. */
public Object getObject() throws Exception {
Assert.notNull(executionResources, "executionResources is null");
Assert.notNull(resource, "relativePath is null");
return executionResources.getAsOsPath(resource, overwrite);
}
+ /** Return {@link Object} because CGLIB is unable to proxy {@link File}.*/
public Class<? extends Object> getObjectType() {
- return File.class;
+ return CharSequence.class;
}
public boolean isSingleton() {
- return true;
+ return false;
}
/** The execution resources object. */
--- /dev/null
+package org.argeo.slc.core.execution.tasks;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.beans.factory.FactoryBean;
+
+/** Merge the provided lists in one single list, in the order provided. */
+public class MergedLists implements FactoryBean {
+ private List<List<Object>> lists = new ArrayList<List<Object>>();
+
+ public void setLists(List<List<Object>> lists) {
+ this.lists = lists;
+ }
+
+ public Object getObject() throws Exception {
+ List<Object> merged = new ArrayList<Object>();
+ for (List<Object> lst : lists) {
+ merged.addAll(lst);
+ }
+ return merged;
+ }
+
+ public Class<?> getObjectType() {
+ return List.class;
+ }
+
+ public boolean isSingleton() {
+ return false;
+ }
+
+}
private String execDir;
private String cmd = null;
- private List<String> command = null;
+ private List<Object> command = null;
private Boolean synchronous = true;
private String stdErrLogLevel = "ERROR";
private String stdOutLogLevel = "INFO";
- private Map<String, List<String>> osCommands = new HashMap<String, List<String>>();
+ private Map<String, List<Object>> osCommands = new HashMap<String, List<Object>>();
private Map<String, String> osCmds = new HashMap<String, String>();
private Map<String, String> environmentVariables = new HashMap<String, String>();
// Check if an OS specific command overrides
String osName = System.getProperty("os.name");
- List<String> commandToUse = null;
+ List<Object> commandToUse = null;
if (osCommands.containsKey(osName))
commandToUse = osCommands.get(osName);
else
if (commandToUse.size() == 0)
throw new SlcException("Command line is empty.");
- commandLine = new CommandLine(commandToUse.get(0));
+ commandLine = new CommandLine(commandToUse.get(0).toString());
for (int i = 1; i < commandToUse.size(); i++)
- commandLine.addArgument(commandToUse.get(i));
+ commandLine.addArgument(commandToUse.get(i).toString());
} else {
// all cases covered previously
throw new NotImplementedException();
this.synchronous = synchronous;
}
- public void setCommand(List<String> command) {
+ public void setCommand(List<Object> command) {
this.command = command;
}
- public void setOsCommands(Map<String, List<String>> osCommands) {
+ public void setOsCommands(Map<String, List<Object>> osCommands) {
this.osCommands = osCommands;
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+ xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
<bean id="slcDefault.executionResources" parent="slcTemplate.fileResources"
- lazy-init="true">
+ scope="execution" lazy-init="true">
+ <aop:scoped-proxy />
<property name="executionContext" ref="executionContext" />
</bean>
<import resource="specs.xml" />
<import resource="templates.xml" />
<import resource="defaults.xml" />
+ <import resource="utils.xml" />
<import resource="tasks/core.xml" />
<bean class="org.springframework.beans.factory.config.CustomScopeConfigurer">
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+ xmlns:aop="http://www.springframework.org/schema/aop"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
+
+ <bean id="mergedLists" class="org.argeo.slc.core.execution.tasks.MergedLists"
+ abstract="true">
+ </bean>
+</beans>
\ No newline at end of file