Do some clean up in SLC
authorMathieu Baudier <mbaudier@argeo.org>
Fri, 4 Nov 2011 21:57:01 +0000 (21:57 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Fri, 4 Nov 2011 21:57:01 +0000 (21:57 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@4884 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

17 files changed:
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/ExecutionParameterPostProcessor.java
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/InstantiationManager.java
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/ProcessThread.java
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/ProcessThreadGroup.java
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/tasks/SystemCall.java
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/xml/AsFlowDecorator.java
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/SimpleTestRun.java
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/CompositeTreeTestDefinition.java
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/dao/test/tree/TreeTestResultDao.java
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/dao/test/tree/TreeTestResultPersister.java
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/process/SlcExecutionRequest.java
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/process/SlcExecutionStatusRequest.java
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/process/SlcExecutionStepsRequest.java
runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/process/SlcExecutionAware.java
runtime/org.argeo.slc.support.activemq/src/main/java/org/argeo/slc/jms/JmsAgent.java
runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/BundleRegister.java
runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/FileSystemBundleRegister.java

index 2ba426e13ebd1fe0f411378c9a2941af5611cf1c..7771718edc2739beef6677ac74b327c3e7e253c2 100644 (file)
@@ -41,6 +41,12 @@ import org.springframework.beans.factory.support.ManagedSet;
 import org.springframework.util.ObjectUtils;\r
 import org.springframework.util.StringUtils;\r
 \r
+/**\r
+ * Spring post processor which ensures that execution parameters are properly\r
+ * set. It is used at two levels: first during instantiation for instantiation\r
+ * parameters which allow to implement templates, then at runtime in order to\r
+ * interpret @{} placeholders when object of scope execution are instantiated.\r
+ */\r
 public class ExecutionParameterPostProcessor extends\r
                InstantiationAwareBeanPostProcessorAdapter {\r
 \r
@@ -102,7 +108,7 @@ public class ExecutionParameterPostProcessor extends
                                        placeholder).toString();\r
 \r
                else {// execution\r
-                       // next call fail if no execution context available\r
+                               // next call fail if no execution context available\r
                        Object obj = executionContext.getVariable(placeholder);\r
                        if (obj != null) {\r
                                return obj.toString();\r
@@ -131,12 +137,12 @@ public class ExecutionParameterPostProcessor extends
                        return convertedValue.equals(originalValue) ? value\r
                                        : convertedValue;\r
                } else if (value instanceof ManagedMap) {\r
-                       Map mapVal = (Map) value;\r
+                       Map<?, ?> mapVal = (Map<?, ?>) value;\r
 \r
-                       Map newContent = new ManagedMap();\r
+                       Map<Object, Object> newContent = new ManagedMap();\r
                        boolean entriesModified = false;\r
-                       for (Iterator it = mapVal.entrySet().iterator(); it.hasNext();) {\r
-                               Map.Entry entry = (Map.Entry) it.next();\r
+                       for (Iterator<?> it = mapVal.entrySet().iterator(); it.hasNext();) {\r
+                               Map.Entry<?, ?> entry = (Map.Entry<?, ?>) it.next();\r
                                Object key = entry.getKey();\r
                                int keyHash = (key != null ? key.hashCode() : 0);\r
                                Object newKey = resolveValue(beanName, bean, key);\r
@@ -150,8 +156,8 @@ public class ExecutionParameterPostProcessor extends
 \r
                        return entriesModified ? newContent : value;\r
                } else if (value instanceof ManagedList) {\r
-                       List listVal = (List) value;\r
-                       List newContent = new ManagedList();\r
+                       List<?> listVal = (List<?>) value;\r
+                       List<Object> newContent = new ManagedList();\r
                        boolean valueModified = false;\r
 \r
                        for (int i = 0; i < listVal.size(); i++) {\r
@@ -164,10 +170,10 @@ public class ExecutionParameterPostProcessor extends
                        }\r
                        return valueModified ? newContent : value;\r
                } else if (value instanceof ManagedSet) {\r
-                       Set setVal = (Set) value;\r
-                       Set newContent = new ManagedSet();\r
+                       Set<?> setVal = (Set<?>) value;\r
+                       Set<Object> newContent = new ManagedSet();\r
                        boolean entriesModified = false;\r
-                       for (Iterator it = setVal.iterator(); it.hasNext();) {\r
+                       for (Iterator<?> it = setVal.iterator(); it.hasNext();) {\r
                                Object elem = it.next();\r
                                int elemHash = (elem != null ? elem.hashCode() : 0);\r
                                Object newVal = resolveValue(beanName, bean, elem);\r
@@ -257,8 +263,8 @@ public class ExecutionParameterPostProcessor extends
                                        // previously resolved placeholder value.\r
                                        propVal = parseStringValue(bean, propVal,\r
                                                        visitedPlaceholders);\r
-                                       buf.replace(startIndex, endIndex\r
-                                                       + placeholderSuffix.length(), propVal);\r
+                                       buf.replace(startIndex,\r
+                                                       endIndex + placeholderSuffix.length(), propVal);\r
                                        if (log.isTraceEnabled()) {\r
                                                log.trace("Resolved placeholder '" + placeholder + "'");\r
                                        }\r
index af2763d66ace105a944a7d76119a485750ad20a8..478077a2d37469bcc11c0a955a33ddbd81f221ea 100644 (file)
@@ -24,6 +24,7 @@ import org.argeo.slc.SlcException;
 import org.argeo.slc.execution.ExecutionFlow;\r
 import org.argeo.slc.execution.ExecutionSpecAttribute;\r
 \r
+/** Manage parameters that need to be set during the instantiation of a flow */\r
 public class InstantiationManager {\r
 \r
        private final static Log log = LogFactory\r
@@ -46,7 +47,7 @@ public class InstantiationManager {
                if (flow instanceof DefaultExecutionFlow) {\r
                        ((DefaultExecutionFlow) flow).setBeanName(flowName);\r
                }\r
-               \r
+\r
                if (log.isTraceEnabled())\r
                        log.trace("Start initialization of " + flow.hashCode() + " ("\r
                                        + flow + " - " + flow.getClass() + ")");\r
@@ -63,8 +64,8 @@ public class InstantiationManager {
                if (log.isTraceEnabled())\r
                        log.trace("Finish initialization of " + flow.hashCode() + " ("\r
                                        + flow + " - " + flow.getClass() + ")");\r
-               \r
-               if(flowStack.get() != null) {\r
+\r
+               if (flowStack.get() != null) {\r
                        ExecutionFlow registeredFlow = flowStack.get().pop();\r
                        if (registeredFlow != null) {\r
                                if (!flow.getName().equals(registeredFlow.getName()))\r
@@ -72,8 +73,7 @@ public class InstantiationManager {
                                // log.info("# flowInitializationFinished " + flowName);\r
                                // initializingFlow.set(null);\r
                        }\r
-               }\r
-               else {\r
+               } else {\r
                        // happens for flows imported as services\r
                        log.warn("flowInitializationFinished - Flow Stack is null");\r
                }\r
index 61ff30789edbd3eee2e2cf22105c1cc5a36dbc46..b116696f16ee15a2227db219f7e7ca54622a265e 100644 (file)
@@ -21,8 +21,6 @@ import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -34,6 +32,7 @@ import org.argeo.slc.process.RealizedFlow;
 import org.argeo.slc.process.SlcExecution;
 
 /** Thread of the SLC Process, starting the sub executions. */
+@SuppressWarnings("deprecation")
 public class ProcessThread extends Thread {
        private final static Log log = LogFactory.getLog(ProcessThread.class);
 
@@ -47,10 +46,6 @@ public class ProcessThread extends Thread {
        private Boolean hadAnError = false;
        private Boolean killed = false;
 
-       private final static Integer STEPS_BUFFER_CAPACITY = 10000;
-       private BlockingQueue<ExecutionStep> steps = new ArrayBlockingQueue<ExecutionStep>(
-                       STEPS_BUFFER_CAPACITY);
-
        public ProcessThread(ThreadGroup processesThreadGroup,
                        ExecutionModulesManager executionModulesManager,
                        ExecutionProcess process) {
@@ -130,7 +125,6 @@ public class ProcessThread extends Thread {
         * Implementation specific execution. To be overridden in order to deal with
         * custom process types. Default expects an {@link SlcExecution}.
         */
-       @SuppressWarnings("deprecation")
        protected void process() throws InterruptedException {
                if (!(process instanceof SlcExecution))
                        throw new SlcException("Unsupported process type "
index 993f679040fe757335533689ac01693848e10146..893d878fd99ae6ff8d9a427bc140ecc58abdaeef 100644 (file)
@@ -28,6 +28,7 @@ import org.argeo.slc.process.SlcExecution;
 import org.argeo.slc.process.SlcExecutionStep;
 
 /** The thread group attached to a given {@link SlcExecution}. */
+@SuppressWarnings("deprecation")
 public class ProcessThreadGroup extends ThreadGroup {
        private final ExecutionModulesManager executionModulesManager;
        private final ProcessThread processThread;
@@ -45,10 +46,6 @@ public class ProcessThreadGroup extends ThreadGroup {
                this.processThread = processThread;
        }
 
-       // public SlcExecution getSlcProcess() {
-       // return processThread.getSlcProcess();
-       // }
-
        public void dispatchAddStep(ExecutionStep step) {
                // legacy
                ExecutionProcess slcProcess = processThread.getProcess();
index 49ccc9c57f3d22f7ecfc891519bfea7343f0a40b..b631276176c492fbc5181d460ed93d5f006d01c7 100644 (file)
@@ -420,19 +420,10 @@ public class SystemCall implements Runnable {
         */
        protected String getExecDirToUse() {
                try {
-                       File dir = null;
                        if (execDir != null) {
                                return execDir;
-                               // Replace '/' by local file separator, for portability
-                               // execDir.replace('/', File.separatorChar);
-                               // dir = new File(execDir).getCanonicalFile();
-                               // dir = execDir.;
                        }
-
-                       if (dir == null)
-                               return System.getProperty("user.dir");
-                       else
-                               return dir.getPath();
+                       return System.getProperty("user.dir");
                } catch (Exception e) {
                        throw new SlcException("Cannot find exec dir", e);
                }
index 0a23b37a032f5cd990159ed28c9dccc81a6d9f4d..d88792d9e68a78e496c2f285146670510071f39f 100644 (file)
@@ -20,6 +20,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.argeo.slc.SlcException;
 import org.argeo.slc.core.execution.DefaultExecutionFlow;
+import org.argeo.slc.execution.ExecutionFlow;
 import org.springframework.beans.factory.config.BeanDefinitionHolder;
 import org.springframework.beans.factory.config.RuntimeBeanReference;
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
@@ -29,6 +30,7 @@ import org.springframework.beans.factory.xml.ParserContext;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Node;
 
+/** Publishes a {@link Runnable} as an {@link ExecutionFlow} */
 public class AsFlowDecorator implements BeanDefinitionDecorator {
        private Log log = LogFactory.getLog(AsFlowDecorator.class);
 
@@ -38,25 +40,10 @@ public class AsFlowDecorator implements BeanDefinitionDecorator {
                String attrValue = ((Attr) node).getValue();
                if (attrValue.charAt(attrValue.length() - 1) == '/')
                        throw new SlcException(attrValue + " cannot end with a path");
-               // int lastSlash = attrValue.lastIndexOf('/');
-               // String path;
-               // String flowBeanName;
-               // if (lastSlash > 0) {
-               // flowBeanName = attrValue.substring(lastSlash + 1);
-               // path = attrValue.substring(0, lastSlash);
-               // } else if (lastSlash == 0) {
-               // flowBeanName = attrValue.substring(lastSlash + 1);
-               // path = null;
-               // } else {
-               // flowBeanName = attrValue;
-               // path = null;
-               // }
-               //
                final String flowBeanName = attrValue;
-               final String path = null;
 
                if (log.isTraceEnabled())
-                       log.debug("path=" + path + ", flowBeanName=" + flowBeanName);
+                       log.trace("flowBeanName=" + flowBeanName);
 
                if (ctx.getRegistry().containsBeanDefinition(flowBeanName))
                        throw new SlcException("A bean named " + flowBeanName
@@ -71,8 +58,8 @@ public class AsFlowDecorator implements BeanDefinitionDecorator {
                else
                        executables.add(new RuntimeBeanReference(beanName));
 
-               if (path != null)
-                       flow.addPropertyValue("path", path);
+               // if (path != null)
+               // flow.addPropertyValue("path", path);
                flow.addPropertyValue("executables", executables);
 
                if (beanName != null)
index 9a37269e570bc6330eec187daa2fe354a8d31307..a7a4d5990cfc1b971a3d2c77a5ff418f027dc965 100644 (file)
@@ -35,6 +35,7 @@ import org.argeo.slc.test.WritableTestRun;
  * A basic bean implementation of a <code>WritableTestRun</code>, holding\r
  * references to the various parts of a test run.\r
  */\r
+@SuppressWarnings("deprecation")\r
 public class SimpleTestRun implements WritableTestRun, ExecutableTestRun,\r
                SlcExecutionRelated, StructureAware<TreeSPath> {\r
        private String uuid;\r
@@ -130,6 +131,7 @@ public class SimpleTestRun implements WritableTestRun, ExecutableTestRun,
                this.slcExecutionStepUuid = slcExecutionStepUuid;\r
        }\r
 \r
+       @Deprecated\r
        public void notifySlcExecution(SlcExecution slcExecution) {\r
                if (slcExecution != null) {\r
                        slcExecutionUuid = slcExecution.getUuid();\r
index 36462c365d0997d98aa33dd3f7bf6a235188ef21..4be0c798e17ccf39326fca9ab9e50c3948d019cd 100644 (file)
@@ -44,7 +44,7 @@ public class CompositeTreeTestDefinition implements TestDefinition,
        private TreeSPath path;\r
        private StructureRegistry<TreeSPath> registry;\r
 \r
-       @SuppressWarnings("unchecked")\r
+       @SuppressWarnings({ "unchecked", "rawtypes" })\r
        public void execute(TestRun testRun) {\r
                if (log.isTraceEnabled())\r
                        log.trace("Execute sequence of test definitions...");\r
@@ -53,8 +53,8 @@ public class CompositeTreeTestDefinition implements TestDefinition,
                for (TestDefinition task : tasks) {\r
                        TestResult result = testRun.getTestResult();\r
                        if (result instanceof StructureAware) {\r
-                               ((StructureAware) result).notifyCurrentPath(registry, taskPaths\r
-                                               .get(i));\r
+                               ((StructureAware) result).notifyCurrentPath(registry,\r
+                                               taskPaths.get(i));\r
                        }\r
 \r
                        task.execute(testRun);\r
index 6ccaafaae3bdb05e272b58182062584505cc184c..4baf2733a1ee51018a3e849adc50243c689964cf 100644 (file)
@@ -32,6 +32,7 @@ import org.argeo.slc.structure.StructureElement;
  * \r
  * @see TreeTestResult\r
  */\r
+@Deprecated\r
 public interface TreeTestResultDao extends TestResultDao<TreeTestResult> {\r
        /** Lists results containing this path */\r
        public List<TreeTestResult> listResults(TreeSPath path);\r
index dfd556f26065f3728c753ff9807eba8daa3ed547..113fa9475289b9a912563d461d522fe2667766c4 100644 (file)
@@ -28,6 +28,7 @@ import org.argeo.slc.test.TestResultPart;
  * \r
  * @see TreeTestResult\r
  */\r
+@Deprecated\r
 public class TreeTestResultPersister implements\r
                TestResultListener<TreeTestResult> {\r
        private static Log log = LogFactory.getLog(TreeTestResultPersister.class);\r
index b747916d51b88d9097672a55d75852c5102f36e2..c5d36286166d87f9383cf945e3251970d2e15102 100644 (file)
@@ -20,6 +20,7 @@ import java.io.Serializable;
 
 import org.argeo.slc.process.SlcExecution;
 
+@Deprecated
 public class SlcExecutionRequest implements Serializable {
        private static final long serialVersionUID = 4448081961875614441L;
        private SlcExecution slcExecution;
index 74bf5e7bc5055b6248a2acdb8edbc3c9243673ed..a23152786d2c06016348ada814b3c32dac90419c 100644 (file)
@@ -18,6 +18,7 @@ package org.argeo.slc.msg.process;
 \r
 import java.io.Serializable;\r
 \r
+@Deprecated\r
 public class SlcExecutionStatusRequest implements Serializable {\r
        private static final long serialVersionUID = -6495004680978575999L;\r
        private String slcExecutionUuid;\r
index 5ae4727fa799f495a2bb0cac50a23f9402cd6dbe..8ede69fb3863a903a791a72c65fe6b1b2b0f8cbf 100644 (file)
@@ -23,6 +23,7 @@ import java.util.List;
 import org.argeo.slc.execution.ExecutionStep;\r
 import org.argeo.slc.process.SlcExecutionStep;\r
 \r
+@Deprecated\r
 public class SlcExecutionStepsRequest implements Serializable {\r
        private static final long serialVersionUID = 6243880315234605390L;\r
        private String slcExecutionUuid;\r
index 07296c011eb07611ee4054f5a01fe7238ecaf79a..3d85038ed006e7fda8de2544e609a39d94e76b68 100644 (file)
@@ -16,6 +16,7 @@
 \r
 package org.argeo.slc.process;\r
 \r
+@Deprecated\r
 public interface SlcExecutionAware {\r
        public void notifySlcExecution(SlcExecution slcExecution);\r
 }\r
index 33584bb00ca30d9f56544020dbd4bf448d7ef6a8..11ead0308354851232225a636573206b20ae37e9 100644 (file)
@@ -162,7 +162,7 @@ public class JmsAgent extends DefaultAgent implements MessageListener {
                                final SlcExecution slcExecution = (SlcExecution) convertFrom(message);
                                new Thread() {
                                        public void run() {
-                                               runSlcExecution(slcExecution);
+                                               process(slcExecution);
                                        }
                                }.start();
                                return ExecutionAnswer.ok("Execution started on agent "
index 8d3dfce7380f84e613d6a363aeeccbbb3e3733bf..b04395cc6e32d7525e69ea3f494155b03f06a836 100644 (file)
@@ -1,6 +1,6 @@
 package org.argeo.slc.osgi;
 
-/** A structured set of OSGi bundles. */
+/** <b>Experimental</b> A structured set of OSGi bundles. */
 public interface BundleRegister {
        /**
         * @param pkg
index fc272693d5fc67bd46056c84d35d03dbcd72b0cd..a7d49aca77d028ae1a4bb5d048224b5969f5d555 100644 (file)
@@ -4,7 +4,6 @@ import java.io.File;
 import java.util.HashSet;
 import java.util.Properties;
 import java.util.Set;
-import java.util.StringTokenizer;
 import java.util.jar.JarFile;
 import java.util.jar.Manifest;
 
@@ -12,12 +11,10 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.osgi.framework.Constants;
 
+/** <b>Experimental</b> */
 public class FileSystemBundleRegister implements BundleRegister {
        private final static Log log = LogFactory
                        .getLog(FileSystemBundleRegister.class);
-
-       private File baseDirectory;
-
        private Properties packagesBundles = null;
 
        public String bundleProvidingPackage(String pkg, String version) {