]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/ExecutionAspect.java
Remove eclipse project definitions
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.simple / src / main / java / org / argeo / slc / core / execution / ExecutionAspect.java
1 package org.argeo.slc.core.execution;
2
3 import org.argeo.slc.execution.ExecutionContext;
4 import org.argeo.slc.execution.ExecutionFlow;
5 import org.aspectj.lang.JoinPoint;
6 import org.aspectj.lang.annotation.After;
7 import org.aspectj.lang.annotation.Aspect;
8 import org.aspectj.lang.annotation.Before;
9 import org.aspectj.lang.annotation.Pointcut;
10
11 @Aspect
12 public class ExecutionAspect {
13 static ThreadLocal<Boolean> inModuleExecution = new ThreadLocal<Boolean>() {
14 protected Boolean initialValue() {
15 return false;
16 }
17 };
18
19 private ExecutionContext executionContext;
20
21 public ExecutionContext getExecutionContext() {
22 return executionContext;
23 }
24
25 public void setExecutionContext(ExecutionContext executionContext) {
26 this.executionContext = executionContext;
27 }
28
29 @Before("flowExecution()")
30 public void beforeFlow(JoinPoint jp) throws Throwable {
31 ExecutionFlow executionFlow = (ExecutionFlow) jp.getTarget();
32 executionContext.enterFlow(executionFlow);
33 }
34
35 @After("flowExecution()")
36 public void afterFlow(JoinPoint jp) throws Throwable {
37 ExecutionFlow executionFlow = (ExecutionFlow) jp.getTarget();
38 executionContext.leaveFlow(executionFlow);
39 }
40
41 @Before("moduleExecution()")
42 public void beforeModuleExecution(JoinPoint jp) throws Throwable {
43 inModuleExecution.set(true);
44 }
45
46 @After("moduleExecution()")
47 public void afterModuleExecution(JoinPoint jp) throws Throwable {
48 inModuleExecution.set(false);
49 }
50
51 @Pointcut("execution(void org.argeo.slc.execution.ExecutionFlow.run())")
52 public void flowExecution() {
53 }
54
55 @Pointcut("execution(void org.argeo.slc.execution.ExecutionModule.execute(..))")
56 public void moduleExecution() {
57 }
58
59 }