]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/ExecutionAspect.java
Improve SSH support
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.simple / src / main / java / org / argeo / slc / core / execution / ExecutionAspect.java
index aae2e80c60568e07626d59cedd4324d351141e18..29942817d4e2343808d6a010a491def5e47bc829 100644 (file)
@@ -1,38 +1,59 @@
 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;
+       }
+
+       public void setExecutionContext(ExecutionContext executionContext) {
+               this.executionContext = 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);
+               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);
+               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.execute())")
+       @Pointcut("execution(void org.argeo.slc.execution.ExecutionFlow.run())")
        public void flowExecution() {
        }
+
+       @Pointcut("execution(void org.argeo.slc.execution.ExecutionModule.execute(..))")
+       public void moduleExecution() {
+       }
+
 }