Coverage Report - org.seasar.teeda.extension.annotation.handler.TigerRedirectDescAnnotationHandler
 
Classes in this File Line Coverage Branch Coverage Complexity
TigerRedirectDescAnnotationHandler
88%
15/17
75%
12/16
0
 
 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.extension.annotation.handler;
 17  
 
 18  
 import java.lang.reflect.Method;
 19  
 import java.util.Map;
 20  
 
 21  
 import org.seasar.framework.beans.BeanDesc;
 22  
 import org.seasar.framework.container.ComponentDef;
 23  
 import org.seasar.framework.container.S2Container;
 24  
 import org.seasar.framework.util.tiger.CollectionsUtil;
 25  
 import org.seasar.teeda.extension.annotation.transition.Redirect;
 26  
 import org.seasar.teeda.extension.html.RedirectDesc;
 27  
 
 28  
 /**
 29  
  * 
 30  
  * @author koichik
 31  
  */
 32  2
 public class TigerRedirectDescAnnotationHandler extends
 33  
                 ConstantRedirectDescAnnotationHandler {
 34  
 
 35  
         @SuppressWarnings("unchecked")
 36  
         @Override
 37  
         protected Map getRedirectDescs(final S2Container container,
 38  
                         final ComponentDef componentDef, final Class componentClass,
 39  
                         final String componentName, final BeanDesc beanDesc) {
 40  1
                 final Map<String, RedirectDesc> ret = CollectionsUtil.newHashMap();
 41  14
                 for (final Method method : componentClass.getMethods()) {
 42  13
                         if (method.isBridge() || method.isSynthetic()) {
 43  0
                                 continue;
 44  
                         }
 45  13
                         final String methodName = method.getName();
 46  13
                         if (!methodName.equals("initialize")
 47  
                                         && !methodName.equals("prerender")
 48  
                                         && !methodName.startsWith("do")) {
 49  9
                                 continue;
 50  
                         }
 51  4
                         final Redirect redirect = method.getAnnotation(Redirect.class);
 52  4
                         if (redirect == null) {
 53  0
                                 continue;
 54  
                         }
 55  4
                         final RedirectDesc redirectDesc = createRedirectDesc(redirect
 56  
                                         .protocol().getExternalForm(), redirect.port());
 57  4
                         ret.put(methodName, redirectDesc);
 58  
                 }
 59  1
                 final Map<String, RedirectDesc> m = super.getRedirectDescs(container,
 60  
                                 componentDef, componentClass, componentName, beanDesc);
 61  1
                 if (!m.isEmpty()) {
 62  1
                         ret.putAll(m);
 63  
                 }
 64  1
                 return ret;
 65  
         }
 66  
 }