| 38 | import java.util.Vector; |
| 39 | |
| 40 | @CreoleResource(icon = "application") |
| 41 | public abstract class AbstractController extends AbstractResource |
| 42 | implements Controller, ProcessingResource, Benchmarkable { |
| 43 | |
| 44 | private static final long serialVersionUID = 6466829205468662382L; |
| 45 | |
| 46 | /** |
| 47 | * Benchmark ID of this resource. |
| 48 | */ |
| 49 | protected String benchmarkID; |
| 50 | |
| 51 | /** |
| 52 | * Shared featureMap |
| 53 | */ |
| 54 | protected Map<Object,Object> benchmarkFeatures = new HashMap<Object,Object>(); |
| 55 | |
| 56 | // executable code |
| 57 | /** |
| 58 | * Execute this controller. This implementation takes care of informing any |
| 59 | * {@link ControllerAwarePR}s of the start and end of execution, and |
| 60 | * delegates to the {@link #executeImpl()} method to do the real work. |
| 61 | * Subclasses should override {@link #executeImpl()} rather than this method. |
| 62 | */ |
| 63 | @Override |
| 64 | public void execute() throws ExecutionException { |
| 65 | |
| 66 | // inform ControllerAware PRs that execution has started, if automatic callbacks are enabled |
| 67 | if(controllerCallbacksEnabled) { |
| 68 | invokeControllerExecutionStarted(); |
| 69 | } |
| 70 | Throwable thrown = null; |
| 71 | try { |
| 72 | if(Benchmark.isBenchmarkingEnabled()) { |
| 73 | // write a start marker to the benchmark log for this |
| 74 | // controller as a whole |
| 75 | Benchmark.startPoint(getBenchmarkId()); |
| 76 | } |
| 77 | // do the real work |
| 78 | this.executeImpl(); |
| 79 | } |
| 80 | catch(Throwable t) { |
| 81 | thrown = t; |
| 82 | } |
| 83 | finally { |
| 84 | if(thrown == null) { |
| 85 | // successfully completed |
| 86 | if(controllerCallbacksEnabled) { |
| 87 | invokeControllerExecutionFinished(); |
| 88 | } |
| 89 | } |
| 90 | else { |
| 91 | // aborted |
| 92 | if(controllerCallbacksEnabled) { |
| 93 | invokeControllerExecutionAborted(thrown); |
| 94 | } |
| 95 | |
| 96 | // rethrow the aborting exception or error |
| 97 | if(thrown instanceof Error) { |
nothing calls this directly
no outgoing calls
no test coverage detected