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