Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
TimerInterceptor |
|
| 1.0;1 |
1 | /* | |
2 | * $Id: TimerInterceptor.java 7976 2007-08-21 14:26:13Z dirk.olmes $ | |
3 | * -------------------------------------------------------------------------------------- | |
4 | * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com | |
5 | * | |
6 | * The software in this package is published under the terms of the CPAL v1.0 | |
7 | * license, a copy of which has been included with this distribution in the | |
8 | * LICENSE.txt file. | |
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 | * <code>TimerInterceptor</code> simply times and displays the time taken to | |
23 | * process an event. | |
24 | * | |
25 | * @author <a href="mailto:ross.mason@symphonysoft.com">Ross Mason</a> | |
26 | * @version $Revision: 7976 $ | |
27 | */ | |
28 | 0 | public class TimerInterceptor implements UMOInterceptor |
29 | { | |
30 | /** | |
31 | * logger used by this class | |
32 | */ | |
33 | 0 | private static Log logger = LogFactory.getLog(TimerInterceptor.class); |
34 | ||
35 | /* | |
36 | * (non-Javadoc) | |
37 | * | |
38 | * @see org.mule.umo.UMOInterceptor#intercept(org.mule.umo.UMOEvent) | |
39 | */ | |
40 | public UMOMessage intercept(Invocation invocation) throws UMOException | |
41 | { | |
42 | 0 | long startTime = System.currentTimeMillis(); |
43 | 0 | UMOMessage result = invocation.execute(); |
44 | 0 | long executionTime = System.currentTimeMillis() - startTime; |
45 | 0 | logger.info(invocation.getDescriptor().getName() + " took " + executionTime + "ms to process event [" |
46 | + invocation.getEvent().getId() + "]"); | |
47 | 0 | return result; |
48 | } | |
49 | } |