Coverage Report - org.apache.myfaces.config.impl.digester.elements.ManagedBeanImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ManagedBeanImpl
0%
0/42
0%
0/20
1.65
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *   http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing,
 13  
  * software distributed under the License is distributed on an
 14  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  * KIND, either express or implied.  See the License for the
 16  
  * specific language governing permissions and limitations
 17  
  * under the License.
 18  
  */
 19  
 package org.apache.myfaces.config.impl.digester.elements;
 20  
 
 21  
 import java.io.Serializable;
 22  
 import java.util.ArrayList;
 23  
 import java.util.Collection;
 24  
 import java.util.List;
 25  
 
 26  
 import javax.el.ValueExpression;
 27  
 import javax.faces.context.FacesContext;
 28  
 
 29  
 import org.apache.myfaces.shared.util.ClassUtils;
 30  
 import org.apache.myfaces.view.facelets.el.ELText;
 31  
 
 32  
 
 33  
 /**
 34  
  * @author <a href="mailto:oliver@rossmueller.com">Oliver Rossmueller</a>
 35  
  */
 36  0
 public class ManagedBeanImpl extends org.apache.myfaces.config.element.ManagedBean implements Serializable
 37  
 {
 38  
 
 39  
     private String description;
 40  
     private String name;
 41  
     private String beanClassName;
 42  
     private Class<?> beanClass;
 43  
     private String scope;
 44  0
     private List<org.apache.myfaces.config.element.ManagedProperty> property
 45  
             = new ArrayList<org.apache.myfaces.config.element.ManagedProperty>();
 46  
     private org.apache.myfaces.config.element.MapEntries mapEntries;
 47  
     private org.apache.myfaces.config.element.ListEntries listEntries;
 48  
     private ValueExpression scopeValueExpression;
 49  
     private String eager;
 50  
 
 51  
     public int getInitMode()
 52  
     {
 53  0
         if (mapEntries != null)
 54  
         {
 55  0
             return INIT_MODE_MAP;
 56  
         }
 57  0
         if (listEntries != null)
 58  
         {
 59  0
             return INIT_MODE_LIST;
 60  
         }
 61  0
         if (! property.isEmpty())
 62  
         {
 63  0
             return INIT_MODE_PROPERTIES;
 64  
         }
 65  0
         return INIT_MODE_NO_INIT;
 66  
     }
 67  
 
 68  
 
 69  
 
 70  
     public org.apache.myfaces.config.element.MapEntries getMapEntries()
 71  
     {
 72  0
         return mapEntries;
 73  
     }
 74  
 
 75  
 
 76  
     public void setMapEntries(org.apache.myfaces.config.element.MapEntries mapEntries)
 77  
     {
 78  0
         this.mapEntries = mapEntries;
 79  0
     }
 80  
 
 81  
 
 82  
     public org.apache.myfaces.config.element.ListEntries getListEntries()
 83  
     {
 84  0
         return listEntries;
 85  
     }
 86  
 
 87  
 
 88  
     public void setListEntries(org.apache.myfaces.config.element.ListEntries listEntries)
 89  
     {
 90  0
         this.listEntries = listEntries;
 91  0
     }
 92  
 
 93  
 
 94  
     public String getDescription()
 95  
     {
 96  0
         return description;
 97  
     }
 98  
     
 99  
     public void setDescription(String description)
 100  
     {
 101  0
         this.description = description;
 102  0
     }
 103  
     
 104  
     public String getManagedBeanName()
 105  
     {
 106  0
         return name;
 107  
     }
 108  
 
 109  
 
 110  
     public void setName(String name)
 111  
     {
 112  0
         this.name = name;
 113  0
     }
 114  
 
 115  
 
 116  
     public String getManagedBeanClassName()
 117  
     {
 118  0
         return beanClassName;
 119  
     }
 120  
 
 121  
 
 122  
     public Class<?> getManagedBeanClass()
 123  
     {
 124  0
         if (beanClassName == null)
 125  
         {
 126  0
             return null;
 127  
         }
 128  
         
 129  0
         if (beanClass == null)
 130  
         {
 131  0
             beanClass = ClassUtils.simpleClassForName(beanClassName);
 132  
         }
 133  
         
 134  0
         return beanClass;
 135  
     }
 136  
 
 137  
 
 138  
     public void setBeanClass(String beanClass)
 139  
     {
 140  0
         this.beanClassName = beanClass;
 141  0
     }
 142  
 
 143  
 
 144  
     public String getManagedBeanScope()
 145  
     {
 146  0
         return scope;
 147  
     }
 148  
 
 149  
 
 150  
     public void setScope(String scope)
 151  
     {
 152  0
         this.scope = scope;
 153  0
     }
 154  
 
 155  
 
 156  
     public void addProperty(org.apache.myfaces.config.element.ManagedProperty value)
 157  
     {
 158  0
         property.add(value);
 159  0
     }
 160  
 
 161  
 
 162  
     public Collection<? extends org.apache.myfaces.config.element.ManagedProperty> getManagedProperties()
 163  
     {
 164  0
         return property;
 165  
     }
 166  
     
 167  
     public boolean isManagedBeanScopeValueExpression()
 168  
     {
 169  0
         return (scope != null) 
 170  
                    && (scopeValueExpression != null || !ELText.isLiteral(scope));
 171  
     }
 172  
     
 173  
     public ValueExpression getManagedBeanScopeValueExpression(FacesContext facesContext)
 174  
     {
 175  0
         if (scopeValueExpression == null)
 176  
         {
 177  
             // we need to set the expected type to Object, because we have to generate a 
 178  
             // Exception text with the actual value and the actual type of the expression,
 179  
             // if the expression does not resolve to java.util.Map
 180  0
             scopeValueExpression = 
 181  
                 isManagedBeanScopeValueExpression()
 182  
                 ? facesContext.getApplication().getExpressionFactory()
 183  
                         .createValueExpression(facesContext.getELContext(), scope, Object.class)
 184  
                 : null;
 185  
         }
 186  0
         return scopeValueExpression;
 187  
     }
 188  
 
 189  
     public String getEager()
 190  
     {
 191  0
         return eager;
 192  
     }
 193  
     
 194  
     public void setEager(String eager)
 195  
     {
 196  0
         this.eager = eager;
 197  0
     }
 198  
     
 199  
 }