1
2
3
4
5
6
7
8
9
10
11 package org.mule.config.spring;
12
13 import org.mule.api.interceptor.Interceptor;
14 import org.mule.api.interceptor.Invocation;
15 import org.mule.api.MuleMessage;
16 import org.mule.api.MuleException;
17
18 public class TimingInterceptor implements Interceptor
19 {
20
21 public static final long UNCALLED = -1L;
22 private long interval = UNCALLED;
23
24 public MuleMessage intercept(Invocation invocation) throws MuleException
25 {
26 long start = System.currentTimeMillis();
27 try
28 {
29
30 invocation.execute();
31
32 return null;
33 }
34 finally
35 {
36 interval = System.currentTimeMillis() - start;
37 }
38 }
39
40 public long getInterval()
41 {
42 return interval;
43 }
44
45 }