1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
35
36 public class ManagedBean 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 private List<org.apache.myfaces.config.element.ManagedProperty> property = new ArrayList<org.apache.myfaces.config.element.ManagedProperty>();
45 private org.apache.myfaces.config.element.MapEntries mapEntries;
46 private org.apache.myfaces.config.element.ListEntries listEntries;
47 private ValueExpression scopeValueExpression;
48 private String eager;
49
50 public int getInitMode()
51 {
52 if (mapEntries != null) {
53 return INIT_MODE_MAP;
54 }
55 if (listEntries != null) {
56 return INIT_MODE_LIST;
57 }
58 if (! property.isEmpty()) {
59 return INIT_MODE_PROPERTIES;
60 }
61 return INIT_MODE_NO_INIT;
62 }
63
64
65
66 public org.apache.myfaces.config.element.MapEntries getMapEntries()
67 {
68 return mapEntries;
69 }
70
71
72 public void setMapEntries(org.apache.myfaces.config.element.MapEntries mapEntries)
73 {
74 this.mapEntries = mapEntries;
75 }
76
77
78 public org.apache.myfaces.config.element.ListEntries getListEntries()
79 {
80 return listEntries;
81 }
82
83
84 public void setListEntries(org.apache.myfaces.config.element.ListEntries listEntries)
85 {
86 this.listEntries = listEntries;
87 }
88
89
90 public String getDescription() {
91 return description;
92 }
93
94 public void setDescription(String description) {
95 this.description = description;
96 }
97
98 public String getManagedBeanName()
99 {
100 return name;
101 }
102
103
104 public void setName(String name)
105 {
106 this.name = name;
107 }
108
109
110 public String getManagedBeanClassName()
111 {
112 return beanClassName;
113 }
114
115
116 public Class<?> getManagedBeanClass()
117 {
118 if (beanClassName == null)
119 {
120 return null;
121 }
122
123 if (beanClass == null)
124 {
125 beanClass = ClassUtils.simpleClassForName(beanClassName);
126 }
127
128 return beanClass;
129 }
130
131
132 public void setBeanClass(String beanClass)
133 {
134 this.beanClassName = beanClass;
135 }
136
137
138 public String getManagedBeanScope()
139 {
140 return scope;
141 }
142
143
144 public void setScope(String scope)
145 {
146 this.scope = scope;
147 }
148
149
150 public void addProperty(org.apache.myfaces.config.element.ManagedProperty value)
151 {
152 property.add(value);
153 }
154
155
156 public Collection<? extends org.apache.myfaces.config.element.ManagedProperty> getManagedProperties()
157 {
158 return property;
159 }
160
161 public boolean isManagedBeanScopeValueExpression()
162 {
163 return (scope != null)
164 && (scopeValueExpression != null || !ELText.isLiteral(scope));
165 }
166
167 public ValueExpression getManagedBeanScopeValueExpression(FacesContext facesContext)
168 {
169 if (scopeValueExpression == null)
170 {
171
172
173
174 scopeValueExpression =
175 isManagedBeanScopeValueExpression()
176 ? facesContext.getApplication().getExpressionFactory()
177 .createValueExpression(facesContext.getELContext(), scope, Object.class)
178 : null;
179 }
180 return scopeValueExpression;
181 }
182
183 public String getEager()
184 {
185 return eager;
186 }
187
188 public void setEager(String eager)
189 {
190 this.eager = eager;
191 }
192
193 }