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