]> git.argeo.org Git - gpl/argeo-slc.git/commitdiff
Runtime improvements
authorMathieu Baudier <mbaudier@argeo.org>
Tue, 9 Jun 2009 16:31:43 +0000 (16:31 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Tue, 9 Jun 2009 16:31:43 +0000 (16:31 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@2521 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

13 files changed:
demo/pom.xml
demo/site/org.argeo.slc.demo.basic/pom.xml [deleted file]
runtime/org.argeo.slc.server/src/main/java/org/argeo/slc/server/client/impl/SlcServerHttpClientImpl.java
runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/DefaultDescriptorConverter.java
runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/ExecutionAspect.java
runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/ExecutionScope.java
runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/MapExecutionContext.java
runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/OsFileFactoryBean.java
runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/tasks/MergedLists.java [new file with mode: 0644]
runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/tasks/SystemCall.java
runtime/org.argeo.slc.support.simple/src/main/resources/org/argeo/slc/core/execution/defaults.xml
runtime/org.argeo.slc.support.simple/src/main/resources/org/argeo/slc/core/execution/spring.xml
runtime/org.argeo.slc.support.simple/src/main/resources/org/argeo/slc/core/execution/utils.xml [new file with mode: 0644]

index 5a0198f4fa1963d1e0839521ab9a2552fd2352b2..d9d0a0d8dd7f51505ea50b396fa609314fb5a37e 100644 (file)
@@ -22,7 +22,6 @@
                                <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>
diff --git a/demo/site/org.argeo.slc.demo.basic/pom.xml b/demo/site/org.argeo.slc.demo.basic/pom.xml
deleted file mode 100644 (file)
index 8cd5ec1..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-<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>
index 301afb5b1007327d1f440bc07d2e30ec586e4f31..666e7b7bc2f8d07493de357b110dd6078b833ec2 100644 (file)
@@ -110,6 +110,8 @@ public class SlcServerHttpClientImpl extends AbstractHttpServicesClient
                                .getUuid());
                ExecutionModuleDescriptor moduleDescMinimal = findModule(lst,
                                moduleName);
+               if (moduleDescMinimal == null)
+                       throw new SlcException("Cannot find module " + moduleName);
                String moduleVersion = moduleDescMinimal.getVersion();
 
                ExecutionModuleDescriptor moduleDesc = getModuleDescriptor(
index 4a234f9f9219fce0398aa9901795127c7bf20859..2ae1e3639b9b6aed274da6035e3870b847cdb7ce 100644 (file)
@@ -28,8 +28,10 @@ public class DefaultDescriptorConverter implements
                                        // 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());
                                }
                        }
                }
index c2abfed27005ebde3fbc4c37918005aa05f36287..29942817d4e2343808d6a010a491def5e47bc829 100644 (file)
@@ -1,23 +1,23 @@
 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;
        }
@@ -28,24 +28,32 @@ public class ExecutionAspect {
 
        @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() {
+       }
+
 }
index 36d951093a964c18b68fea9f0348a089e1f553ac..7deb9f5788923bef2c6a1368a7664be308cc140d 100644 (file)
@@ -27,9 +27,25 @@ public class ExecutionScope implements Scope {
                        // 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(
index f38342662852747f4f3aeba405e39bb813907010..9e6c2b5bd89736cc0ea64c879e40ba1f264bdf15 100644 (file)
@@ -27,8 +27,6 @@ public class MapExecutionContext implements ExecutionContext {
 
        public MapExecutionContext() {
                uuid = UUID.randomUUID().toString();
-               if (log.isDebugEnabled())
-                       log.debug("Execution context #" + uuid + " instantiated.");
        }
 
        public void addVariables(
index b566e57423fd1a5feb4feebc185c87ec83b10080..18a9f840be32ee0642c9b494e33680809c88a3ff 100644 (file)
@@ -6,25 +6,26 @@ import org.springframework.beans.factory.FactoryBean;
 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. */
diff --git a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/tasks/MergedLists.java b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/tasks/MergedLists.java
new file mode 100644 (file)
index 0000000..9e2817b
--- /dev/null
@@ -0,0 +1,32 @@
+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;
+       }
+
+}
index 2bb835b24accc14999f675f74fbec86cbf05382e..143bded2a904e9bc55a35bf640a3d26f08e7ad1c 100644 (file)
@@ -26,14 +26,14 @@ public class SystemCall implements Runnable {
        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>();
 
@@ -57,7 +57,7 @@ public class SystemCall implements Runnable {
 
                        // 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
@@ -110,9 +110,9 @@ public class SystemCall implements Runnable {
                                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();
@@ -200,11 +200,11 @@ public class SystemCall implements Runnable {
                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;
        }
 
index 09e7a5c1d61180d9e5cb2e8facaf5a4aa8e6dd7b..c6c3c64b3207c4c8250df67e5c4c373f0ac09e16 100644 (file)
@@ -1,11 +1,14 @@
 <?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>
 
index 3cfac026b5806f98429dd9c4e30661d9b5a6196a..33d4b7ef861d7257b23e96e394d7a51e16c7dd11 100644 (file)
@@ -10,6 +10,7 @@
        <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">
diff --git a/runtime/org.argeo.slc.support.simple/src/main/resources/org/argeo/slc/core/execution/utils.xml b/runtime/org.argeo.slc.support.simple/src/main/resources/org/argeo/slc/core/execution/utils.xml
new file mode 100644 (file)
index 0000000..e75bcb3
--- /dev/null
@@ -0,0 +1,12 @@
+<?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