1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.interceptor; |
12 | |
|
13 | |
import org.mule.api.MuleEvent; |
14 | |
import org.mule.api.MuleException; |
15 | |
import org.mule.api.construct.FlowConstruct; |
16 | |
import org.mule.api.construct.FlowConstructAware; |
17 | |
import org.mule.api.interceptor.Interceptor; |
18 | |
import org.mule.management.stats.ProcessingTime; |
19 | |
import org.mule.processor.AbstractInterceptingMessageProcessor; |
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | 0 | public abstract class AbstractEnvelopeInterceptor extends AbstractInterceptingMessageProcessor |
26 | |
implements Interceptor, FlowConstructAware |
27 | |
{ |
28 | |
|
29 | |
protected FlowConstruct flowConstruct; |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
public abstract MuleEvent before(MuleEvent event) throws MuleException; |
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
public abstract MuleEvent after(MuleEvent event) throws MuleException; |
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
public abstract MuleEvent last(MuleEvent event, ProcessingTime time, long startTime, boolean exceptionWasThrown) throws MuleException; |
45 | |
|
46 | |
public MuleEvent process(MuleEvent event) throws MuleException |
47 | |
{ |
48 | 0 | boolean exceptionWasThrown = true; |
49 | 0 | long startTime = System.currentTimeMillis(); |
50 | 0 | ProcessingTime time = event.getProcessingTime(); |
51 | 0 | MuleEvent resultEvent = event; |
52 | |
try |
53 | |
{ |
54 | 0 | resultEvent = before(event); |
55 | 0 | resultEvent = processNext(resultEvent); |
56 | 0 | resultEvent = after(resultEvent); |
57 | 0 | exceptionWasThrown = false; |
58 | |
} |
59 | |
finally |
60 | |
{ |
61 | 0 | resultEvent = last(resultEvent, time, startTime, exceptionWasThrown); |
62 | 0 | } |
63 | 0 | return resultEvent; |
64 | |
} |
65 | |
|
66 | |
public void setFlowConstruct(FlowConstruct flowConstruct) |
67 | |
{ |
68 | 0 | this.flowConstruct = flowConstruct; |
69 | 0 | } |
70 | |
} |