Coverage Report - org.seasar.teeda.core.interceptor.MeasurementInterceptor
 
Classes in this File Line Coverage Branch Coverage Complexity
MeasurementInterceptor
0%
0/12
N/A
2
 
 1  
 /*
 2  
  * Copyright 2004-2011 the Seasar Foundation and the Others.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 13  
  * either express or implied. See the License for the specific language
 14  
  * governing permissions and limitations under the License.
 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  
  * @author shot
 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  
 }