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.interceptor.Interceptor; |
16 | |
import org.mule.processor.AbstractInterceptingMessageProcessor; |
17 | |
|
18 | |
import org.apache.commons.logging.Log; |
19 | |
import org.apache.commons.logging.LogFactory; |
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | 0 | public class TimerInterceptor extends AbstractInterceptingMessageProcessor implements Interceptor |
26 | |
{ |
27 | |
|
28 | |
|
29 | |
|
30 | 0 | private static Log logger = LogFactory.getLog(TimerInterceptor.class); |
31 | |
|
32 | |
public MuleEvent process(MuleEvent event) throws MuleException |
33 | |
{ |
34 | 0 | long startTime = System.currentTimeMillis(); |
35 | |
|
36 | 0 | MuleEvent resultEvent = processNext(event); |
37 | |
|
38 | 0 | if (logger.isInfoEnabled()) |
39 | |
{ |
40 | 0 | long executionTime = System.currentTimeMillis() - startTime; |
41 | 0 | logger.info(resultEvent.getFlowConstruct().getName() + " took " + executionTime |
42 | |
+ "ms to process event [" + resultEvent.getId() + "]"); |
43 | |
} |
44 | |
|
45 | 0 | return resultEvent; |
46 | |
} |
47 | |
} |