]> git.somenet.org - pub/jan/dst18.git/blob - ass2-aop/src/test/java/dst/ass2/aop/sample/AbstractPluginExecutable.java
Add template for assignment 2
[pub/jan/dst18.git] / ass2-aop / src / test / java / dst / ass2 / aop / sample / AbstractPluginExecutable.java
1 package dst.ass2.aop.sample;
2
3 import org.springframework.aop.support.AopUtils;
4
5 import dst.ass2.aop.IPluginExecutable;
6 import dst.ass2.aop.event.EventBus;
7 import dst.ass2.aop.event.EventType;
8
9 public abstract class AbstractPluginExecutable implements IPluginExecutable {
10     @Override
11     public void execute() {
12         EventBus eventBus = EventBus.getInstance();
13         eventBus.add(EventType.PLUGIN_START, this, AopUtils.getTargetClass(this).getSimpleName() + " is executed!");
14
15         try {
16             Thread.sleep(1000);
17         } catch (InterruptedException e) {
18             // Should not happen but is not critical so the stack trace is printed to grab some attention ;-)
19             e.printStackTrace();
20         }
21
22         eventBus.add(EventType.PLUGIN_END, this, AopUtils.getTargetClass(this).getSimpleName() + " is finished!");
23     }
24
25     @Override
26     public void interrupted() {
27     }
28 }