1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.seasar.teeda.core.interceptor; |
17 | |
|
18 | |
import java.text.SimpleDateFormat; |
19 | |
import java.util.Date; |
20 | |
import java.util.Locale; |
21 | |
|
22 | |
import org.aopalliance.intercept.MethodInvocation; |
23 | |
import org.seasar.framework.aop.interceptors.AbstractInterceptor; |
24 | |
import org.seasar.framework.log.Logger; |
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | 0 | public class MeasurementInterceptor extends AbstractInterceptor { |
30 | |
|
31 | |
private static final long serialVersionUID = 1L; |
32 | |
|
33 | 0 | private static final Logger logger = Logger |
34 | 0 | .getLogger(MeasurementInterceptor.class); |
35 | |
|
36 | 0 | private static final SimpleDateFormat formatter = new SimpleDateFormat( |
37 | |
"yyyy/MM/dd hh:mm:ss SSS zzz", Locale.getDefault()); |
38 | |
|
39 | |
public Object invoke(MethodInvocation invocation) throws Throwable { |
40 | 0 | long start = System.currentTimeMillis(); |
41 | 0 | String startDate = formatter.format(new Date()); |
42 | 0 | final Class clazz = getTargetClass(invocation); |
43 | 0 | logger.debug("[measurement] start date = " + startDate + "(" |
44 | |
+ clazz.getName() + ")"); |
45 | |
try { |
46 | 0 | return invocation.proceed(); |
47 | |
} finally { |
48 | 0 | logger.debug("[measurement] perform ms:" |
49 | |
+ new Long(System.currentTimeMillis() - start)); |
50 | 0 | String endDate = formatter.format(new Date()); |
51 | 0 | logger.debug("[measurement] end date = " + endDate + "(" |
52 | |
+ clazz.getName() + ")"); |
53 | |
} |
54 | |
|
55 | |
} |
56 | |
|
57 | |
} |