Coverage Report - org.seasar.teeda.extension.annotation.handler.TigerScopeAnnotationHandler
 
Classes in this File Line Coverage Branch Coverage Complexity
TigerScopeAnnotationHandler
100%
20/20
100%
8/8
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.Field;
 19  
 import java.util.Map;
 20  
 
 21  
 import org.seasar.framework.beans.BeanDesc;
 22  
 import org.seasar.teeda.extension.ExtensionConstants;
 23  
 import org.seasar.teeda.extension.annotation.scope.PageScope;
 24  
 import org.seasar.teeda.extension.annotation.scope.RedirectScope;
 25  
 import org.seasar.teeda.extension.annotation.scope.SubapplicationScope;
 26  
 
 27  
 /**
 28  
  * @author higa
 29  
  * @author shot
 30  
  */
 31  2
 public class TigerScopeAnnotationHandler extends ConstantScopeAnnotationHandler {
 32  
 
 33  
         @Override
 34  
         @SuppressWarnings("unchecked")
 35  
         public void setupPropertyScopes(BeanDesc beanDesc, Map scopes) {
 36  4
                 for (int i = 0; i < beanDesc.getFieldSize(); ++i) {
 37  3
                         Field field = beanDesc.getField(i);
 38  3
                         handlePageScope(field, scopes);
 39  3
                         handleRedirectScope(field, scopes);
 40  3
                         handleSubapplicationScope(field, scopes);
 41  
                 }
 42  1
                 super.setupPropertyScopes(beanDesc, scopes);
 43  1
         }
 44  
 
 45  
         protected void handlePageScope(Field field, Map<String, Integer> scopes) {
 46  3
                 PageScope pageScope = field.getAnnotation(PageScope.class);
 47  3
                 if (pageScope != null) {
 48  1
                         scopes.put(field.getName(), ExtensionConstants.PAGE_SCOPE);
 49  
                 }
 50  3
         }
 51  
 
 52  
         protected void handleRedirectScope(Field field, Map<String, Integer> scopes) {
 53  3
                 RedirectScope redirectScope = field.getAnnotation(RedirectScope.class);
 54  3
                 if (redirectScope != null) {
 55  1
                         scopes.put(field.getName(), ExtensionConstants.REDIRECT_SCOPE);
 56  
                 }
 57  3
         }
 58  
 
 59  
         protected void handleSubapplicationScope(Field field,
 60  
                         Map<String, Integer> scopes) {
 61  3
                 SubapplicationScope subapplicationScope = field
 62  
                                 .getAnnotation(SubapplicationScope.class);
 63  3
                 if (subapplicationScope != null) {
 64  1
                         scopes.put(field.getName(), ExtensionConstants.SUBAPP_SCOPE);
 65  
                 }
 66  3
         }
 67  
 
 68  
 }