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
26
27
28 public class TimerInterceptor implements UMOInterceptor
29 {
30
31
32
33 private static Log logger = LogFactory.getLog(TimerInterceptor.class);
34
35
36
37
38
39
40 public UMOMessage intercept(Invocation invocation) throws UMOException
41 {
42 long startTime = System.currentTimeMillis();
43 UMOMessage result = invocation.execute();
44 long executionTime = System.currentTimeMillis() - startTime;
45 logger.info(invocation.getDescriptor().getName() + " took " + executionTime + "ms to process event ["
46 + invocation.getEvent().getId() + "]");
47 return result;
48 }
49 }