1
2
3
4
5
6
7
8
9
10
11 package org.mule.interceptors;
12
13 import org.mule.umo.Invocation;
14 import org.mule.umo.UMOException;
15 import org.mule.umo.UMOInterceptor;
16 import org.mule.umo.UMOMessage;
17
18 import org.apache.commons.logging.Log;
19 import org.apache.commons.logging.LogFactory;
20
21
22
23
24
25 public class TimerInterceptor implements UMOInterceptor
26 {
27
28
29
30 private static Log logger = LogFactory.getLog(TimerInterceptor.class);
31
32
33
34
35
36
37 public UMOMessage intercept(Invocation invocation) throws UMOException
38 {
39 long startTime = System.currentTimeMillis();
40 UMOMessage result = invocation.execute();
41 long executionTime = System.currentTimeMillis() - startTime;
42 logger.info(invocation.getDescriptor().getName() + " took " + executionTime + "ms to process event ["
43 + invocation.getEvent().getId() + "]");
44 return result;
45 }
46 }