Commit f8920ee07d39e5ad3e683313ba3db639a81c40b6
Exists in
master
Tratamento dos conflitos do merge com o master (2.3.5-SNAPSHOT)
Showing
6 changed files
with
743 additions
and
157 deletions
Show diff stats
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoader.java
0 → 100644
... | ... | @@ -0,0 +1,482 @@ |
1 | +/* | |
2 | + * Demoiselle Framework | |
3 | + * Copyright (C) 2010 SERPRO | |
4 | + * ---------------------------------------------------------------------------- | |
5 | + * This file is part of Demoiselle Framework. | |
6 | + * | |
7 | + * Demoiselle Framework is free software; you can redistribute it and/or | |
8 | + * modify it under the terms of the GNU Lesser General Public License version 3 | |
9 | + * as published by the Free Software Foundation. | |
10 | + * | |
11 | + * This program is distributed in the hope that it will be useful, | |
12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | + * GNU General Public License for more details. | |
15 | + * | |
16 | + * You should have received a copy of the GNU Lesser General Public License version 3 | |
17 | + * along with this program; if not, see <http://www.gnu.org/licenses/> | |
18 | + * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
19 | + * Fifth Floor, Boston, MA 02110-1301, USA. | |
20 | + * ---------------------------------------------------------------------------- | |
21 | + * Este arquivo é parte do Framework Demoiselle. | |
22 | + * | |
23 | + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
24 | + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
25 | + * do Software Livre (FSF). | |
26 | + * | |
27 | + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
28 | + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
29 | + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
30 | + * para maiores detalhes. | |
31 | + * | |
32 | + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
33 | + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
34 | + * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
35 | + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
36 | + */ | |
37 | +package br.gov.frameworkdemoiselle.internal.configuration; | |
38 | + | |
39 | +import java.io.FileNotFoundException; | |
40 | +import java.io.Serializable; | |
41 | +import java.lang.reflect.Field; | |
42 | +import java.lang.reflect.Method; | |
43 | +import java.lang.reflect.ParameterizedType; | |
44 | +import java.lang.reflect.Type; | |
45 | +import java.net.URL; | |
46 | +import java.util.ArrayList; | |
47 | +import java.util.Arrays; | |
48 | +import java.util.HashSet; | |
49 | +import java.util.Iterator; | |
50 | +import java.util.List; | |
51 | +import java.util.Properties; | |
52 | +import java.util.Set; | |
53 | + | |
54 | +import javax.validation.constraints.NotNull; | |
55 | + | |
56 | +import org.apache.commons.configuration.DataConfiguration; | |
57 | +import org.apache.commons.configuration.PropertiesConfiguration; | |
58 | +import org.apache.commons.configuration.SystemConfiguration; | |
59 | +import org.apache.commons.configuration.XMLConfiguration; | |
60 | +import org.slf4j.Logger; | |
61 | + | |
62 | +import br.gov.frameworkdemoiselle.annotation.Ignore; | |
63 | +import br.gov.frameworkdemoiselle.annotation.Name; | |
64 | +import br.gov.frameworkdemoiselle.configuration.ConfigType; | |
65 | +import br.gov.frameworkdemoiselle.configuration.Configuration; | |
66 | +import br.gov.frameworkdemoiselle.configuration.ConfigurationException; | |
67 | +import br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap; | |
68 | +import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; | |
69 | +import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | |
70 | +import br.gov.frameworkdemoiselle.util.Beans; | |
71 | +import br.gov.frameworkdemoiselle.util.Reflections; | |
72 | +import br.gov.frameworkdemoiselle.util.ResourceBundle; | |
73 | +import br.gov.frameworkdemoiselle.util.Strings; | |
74 | + | |
75 | +/** | |
76 | + * This component loads a config class annotated with {@link Configuration} by filling its attributes with {@link Param} | |
77 | + * according to a {@link ConfigType}. | |
78 | + * | |
79 | + * @author SERPRO | |
80 | + */ | |
81 | +public class ConfigurationLoader implements Serializable { | |
82 | + | |
83 | + private static final long serialVersionUID = 1L; | |
84 | + | |
85 | + private ResourceBundle bundle; | |
86 | + | |
87 | + private Logger logger; | |
88 | + | |
89 | + private CoreBootstrap bootstrap; | |
90 | + | |
91 | + /** | |
92 | + * Loads a config class filling it with the corresponding values. | |
93 | + * | |
94 | + * @param object | |
95 | + * config object | |
96 | + * @throws ConfigurationException | |
97 | + */ | |
98 | + public void load(Object object) throws ConfigurationException { | |
99 | + Class<?> config = object.getClass(); | |
100 | + | |
101 | + if (!getBootstrap().isAnnotatedType(config)) { | |
102 | + config = config.getSuperclass(); | |
103 | + getLogger().debug(getBundle().getString("proxy-detected", config, config.getClass().getSuperclass())); | |
104 | + } | |
105 | + | |
106 | + getLogger().debug(getBundle().getString("loading-configuration-class", config.getName())); | |
107 | + | |
108 | + for (Field field : getNonStaticFields(config)) { | |
109 | + loadField(field, object, config); | |
110 | + } | |
111 | + } | |
112 | + | |
113 | + private List<Field> getNonStaticFields(Class<?> type) { | |
114 | + List<Field> fields = new ArrayList<Field>(); | |
115 | + | |
116 | + if (type != null) { | |
117 | + fields.addAll(Arrays.asList(Reflections.getNonStaticDeclaredFields(type))); | |
118 | + fields.addAll(getNonStaticFields(type.getSuperclass())); | |
119 | + } | |
120 | + | |
121 | + return fields; | |
122 | + } | |
123 | + | |
124 | + private void loadField(Field field, Object object, Class<?> clazz) { | |
125 | + if (!field.isAnnotationPresent(Ignore.class) && clazz.isAnnotationPresent(Configuration.class)) { | |
126 | + String resource = clazz.getAnnotation(Configuration.class).resource(); | |
127 | + ConfigType type = clazz.getAnnotation(Configuration.class).type(); | |
128 | + org.apache.commons.configuration.Configuration config = getConfiguration(resource, type); | |
129 | + | |
130 | + if (config != null) { | |
131 | + String key = getKey(field, clazz, config); | |
132 | + Object value = getValue(key, field, config); | |
133 | + | |
134 | + validate(field, key, value, resource); | |
135 | + setValue(field, key, object, value); | |
136 | + } | |
137 | + } | |
138 | + } | |
139 | + | |
140 | + private void setValue(Field field, String key, Object object, Object value) { | |
141 | + if (value != null) { | |
142 | + Reflections.setFieldValue(field, object, value); | |
143 | + getLogger().debug(getBundle().getString("configuration-field-loaded", key, field.getName(), value)); | |
144 | + } | |
145 | + } | |
146 | + | |
147 | + private void validate(Field field, String key, Object value, String resource) { | |
148 | + if (field.isAnnotationPresent(NotNull.class) && value == null) { | |
149 | + throw new ConfigurationException(getBundle().getString("configuration-attribute-is-mandatory", key, | |
150 | + resource)); | |
151 | + } | |
152 | + } | |
153 | + | |
154 | + private String getKey(final Field field, final Class<?> clazz, | |
155 | + final org.apache.commons.configuration.Configuration config) { | |
156 | + | |
157 | + final String prefix = getPrefix(field, clazz); | |
158 | + final StringBuffer key = new StringBuffer(); | |
159 | + | |
160 | + key.append(prefix); | |
161 | + | |
162 | + if (field.isAnnotationPresent(Name.class)) { | |
163 | + key.append(getKeyByAnnotation(field)); | |
164 | + } else { | |
165 | + key.append(getKeyByConvention(field, prefix, config)); | |
166 | + } | |
167 | + | |
168 | + return key.toString(); | |
169 | + } | |
170 | + | |
171 | + private String getPrefix(Field field, Class<?> type) { | |
172 | + String prefix = ""; | |
173 | + | |
174 | + Configuration classAnnotation = type.getAnnotation(Configuration.class); | |
175 | + if (!Strings.isEmpty(classAnnotation.prefix())) { | |
176 | + | |
177 | + prefix = classAnnotation.prefix(); | |
178 | + | |
179 | + if (prefix.charAt(prefix.length() - 1) != '.') { | |
180 | + prefix += "."; | |
181 | + } | |
182 | + } | |
183 | + | |
184 | + return prefix; | |
185 | + } | |
186 | + | |
187 | + private String getKeyByAnnotation(Field field) { | |
188 | + String key = null; | |
189 | + | |
190 | + Name nameAnnotation = field.getAnnotation(Name.class); | |
191 | + if (Strings.isEmpty(nameAnnotation.value())) { | |
192 | + throw new ConfigurationException(getBundle().getString("configuration-name-attribute-cant-be-empty")); | |
193 | + } else { | |
194 | + key = nameAnnotation.value(); | |
195 | + } | |
196 | + | |
197 | + return key; | |
198 | + } | |
199 | + | |
200 | + private String getKeyByConvention(Field field, String prefix, org.apache.commons.configuration.Configuration config) { | |
201 | + | |
202 | + Set<String> conventions = new HashSet<String>(); | |
203 | + conventions.add(field.getName()); | |
204 | + conventions.add(Strings.camelCaseToSymbolSeparated(field.getName(), ".")); | |
205 | + conventions.add(Strings.camelCaseToSymbolSeparated(field.getName(), "_")); | |
206 | + conventions.add(field.getName().toLowerCase()); | |
207 | + conventions.add(field.getName().toUpperCase()); | |
208 | + | |
209 | + int matches = 0; | |
210 | + String key = field.getName(); | |
211 | + for (String convention : conventions) { | |
212 | + if (config.containsKey(prefix + convention)) { | |
213 | + key = convention; | |
214 | + matches++; | |
215 | + } | |
216 | + } | |
217 | + | |
218 | + if (!field.getName().equals(key)) { | |
219 | + getLogger().warn( | |
220 | + "ATENÇÃO!!! Anote o atributo " + field.getName() + " da classe " | |
221 | + + field.getDeclaringClass().getCanonicalName() + " com @Name(\"" + key | |
222 | + + "\") para evitar incompatibilidade com as próximas versões do Demoiselle."); | |
223 | + } | |
224 | + | |
225 | + if (matches == 0) { | |
226 | + getLogger().debug(getBundle().getString("configuration-key-not-found", key, conventions)); | |
227 | + } else if (matches > 1) { | |
228 | + throw new ConfigurationException(getBundle().getString("ambiguous-key", field.getName(), | |
229 | + field.getDeclaringClass())); | |
230 | + } | |
231 | + | |
232 | + return key; | |
233 | + } | |
234 | + | |
235 | + /** | |
236 | + * Returns the configuration class according to specified resource name and configuration type. | |
237 | + * | |
238 | + * @param resource | |
239 | + * @param type | |
240 | + * @return a configuration | |
241 | + */ | |
242 | + private org.apache.commons.configuration.Configuration getConfiguration(String resource, ConfigType type) { | |
243 | + org.apache.commons.configuration.Configuration result = null; | |
244 | + | |
245 | + try { | |
246 | + URL url; | |
247 | + | |
248 | + switch (type) { | |
249 | + case SYSTEM: | |
250 | + result = new SystemConfiguration(); | |
251 | + break; | |
252 | + | |
253 | + case PROPERTIES: | |
254 | + url = getResourceAsURL(resource + ".properties"); | |
255 | + | |
256 | + if (url != null) { | |
257 | + result = new DataConfiguration(new PropertiesConfiguration(url)); | |
258 | + } | |
259 | + | |
260 | + break; | |
261 | + | |
262 | + case XML: | |
263 | + url = getResourceAsURL(resource + ".xml"); | |
264 | + | |
265 | + if (url != null) { | |
266 | + result = new DataConfiguration(new XMLConfiguration(url)); | |
267 | + } | |
268 | + | |
269 | + break; | |
270 | + | |
271 | + default: | |
272 | + throw new ConfigurationException(getBundle().getString("configuration-type-not-implemented-yet", | |
273 | + type.name())); | |
274 | + } | |
275 | + | |
276 | + } catch (Exception cause) { | |
277 | + throw new ConfigurationException(getBundle().getString("error-creating-configuration-from-resource", | |
278 | + resource), cause); | |
279 | + } | |
280 | + | |
281 | + return result; | |
282 | + } | |
283 | + | |
284 | + @SuppressWarnings("unchecked") | |
285 | + private <T> T getValue(String key, Field field, org.apache.commons.configuration.Configuration config) { | |
286 | + Object value; | |
287 | + | |
288 | + Class<?> fieldClass = (Class<?>) field.getType(); | |
289 | + | |
290 | + if (fieldClass.isArray()) { | |
291 | + value = getArray(key, field, config); | |
292 | + | |
293 | + } else if (fieldClass.equals(Properties.class)) { | |
294 | + value = getProperty(key, config); | |
295 | + | |
296 | + } else if (fieldClass.equals(Class.class)) { | |
297 | + value = getClass(key, field, config); | |
298 | + | |
299 | + } else { | |
300 | + value = getBasic(key, field, config); | |
301 | + } | |
302 | + | |
303 | + return (T) value; | |
304 | + } | |
305 | + | |
306 | + private <T> Object getArray(String key, Field field, org.apache.commons.configuration.Configuration config) { | |
307 | + Object value = null; | |
308 | + | |
309 | + Class<?> fieldClass = (Class<?>) field.getType(); | |
310 | + | |
311 | + try { | |
312 | + Method method; | |
313 | + String methodName = "get"; | |
314 | + | |
315 | + methodName += Strings.firstToUpper(fieldClass.getSimpleName()); | |
316 | + methodName = Strings.removeChars(methodName, '[', ']'); | |
317 | + | |
318 | + methodName += "Array"; | |
319 | + | |
320 | + method = config.getClass().getMethod(methodName, String.class); | |
321 | + value = method.invoke(config, key); | |
322 | + | |
323 | + } catch (Throwable cause) { | |
324 | + throw new ConfigurationException(getBundle().getString("error-converting-to-type", fieldClass.getName()), | |
325 | + cause); | |
326 | + } | |
327 | + | |
328 | + return value; | |
329 | + } | |
330 | + | |
331 | + private <T> Object getBasic(String key, Field field, org.apache.commons.configuration.Configuration config) { | |
332 | + Object value = null; | |
333 | + | |
334 | + Class<?> fieldClass = (Class<?>) field.getType(); | |
335 | + | |
336 | + try { | |
337 | + Method method; | |
338 | + String methodName = "get"; | |
339 | + | |
340 | + methodName += discoveryGenericType(field); | |
341 | + methodName += Strings.firstToUpper(fieldClass.getSimpleName()); | |
342 | + | |
343 | + if (!fieldClass.isPrimitive()) { | |
344 | + method = config.getClass().getMethod(methodName, String.class, fieldClass); | |
345 | + value = method.invoke(config, key, null); | |
346 | + | |
347 | + } else if (config.containsKey(key)) { | |
348 | + method = config.getClass().getMethod(methodName, String.class); | |
349 | + value = method.invoke(config, key); | |
350 | + } | |
351 | + | |
352 | + } catch (Throwable cause) { | |
353 | + throw new ConfigurationException(getBundle().getString("error-converting-to-type", fieldClass.getName()), | |
354 | + cause); | |
355 | + } | |
356 | + | |
357 | + return value; | |
358 | + } | |
359 | + | |
360 | + private <T> Object getClass(String key, Field field, org.apache.commons.configuration.Configuration config) { | |
361 | + Object value = null; | |
362 | + | |
363 | + try { | |
364 | + String canonicalName = config.getString(key); | |
365 | + | |
366 | + if (canonicalName != null) { | |
367 | + ClassLoader classLoader = getClassLoaderForClass(canonicalName); | |
368 | + value = Class.forName(canonicalName, true, classLoader); | |
369 | + } | |
370 | + | |
371 | + } catch (Exception cause) { | |
372 | + // TODO Lançar a mensagem correta | |
373 | + throw new ConfigurationException(null, cause); | |
374 | + } | |
375 | + | |
376 | + return value; | |
377 | + } | |
378 | + | |
379 | + /** | |
380 | + * Discovery the Generic's type. for example: the generic's type of List<Integer> list is an Integer type | |
381 | + * | |
382 | + * @param field | |
383 | + * @return | |
384 | + */ | |
385 | + private String discoveryGenericType(Field field) { | |
386 | + | |
387 | + Type genericFieldType = field.getGenericType(); | |
388 | + | |
389 | + if (genericFieldType instanceof ParameterizedType) { | |
390 | + ParameterizedType type = (ParameterizedType) genericFieldType; | |
391 | + Type[] fieldArgumentTypes = type.getActualTypeArguments(); | |
392 | + for (Type fieldArgumentType : fieldArgumentTypes) { | |
393 | + @SuppressWarnings("rawtypes") | |
394 | + Class fieldArgumentClass = (Class) fieldArgumentType; | |
395 | + | |
396 | + if ("String".equals(fieldArgumentClass.getSimpleName())) { | |
397 | + return ""; | |
398 | + } | |
399 | + | |
400 | + return fieldArgumentClass.getSimpleName(); | |
401 | + } | |
402 | + } | |
403 | + | |
404 | + return ""; | |
405 | + } | |
406 | + | |
407 | + private Object getProperty(String key, org.apache.commons.configuration.Configuration config) { | |
408 | + Object value = null; | |
409 | + | |
410 | + @SuppressWarnings("unchecked") | |
411 | + Iterator<String> iterator = config.getKeys(key); | |
412 | + if (iterator.hasNext()) { | |
413 | + Properties props = new Properties(); | |
414 | + | |
415 | + while (iterator.hasNext()) { | |
416 | + String fullKey = iterator.next(); | |
417 | + String prefix = key + "."; | |
418 | + String unprefixedKey = fullKey.substring(prefix.length()); | |
419 | + props.put(unprefixedKey, config.getString(fullKey)); | |
420 | + } | |
421 | + | |
422 | + value = props; | |
423 | + } | |
424 | + | |
425 | + return value; | |
426 | + } | |
427 | + | |
428 | + public static ClassLoader getClassLoaderForClass(final String canonicalName) throws FileNotFoundException { | |
429 | + return getClassLoaderForResource(canonicalName.replaceAll("\\.", "/") + ".class"); | |
430 | + } | |
431 | + | |
432 | + public static ClassLoader getClassLoaderForResource(final String resource) throws FileNotFoundException { | |
433 | + final String stripped = resource.startsWith("/") ? resource.substring(1) : resource; | |
434 | + | |
435 | + URL url = null; | |
436 | + ClassLoader result = Thread.currentThread().getContextClassLoader(); | |
437 | + | |
438 | + if (result != null) { | |
439 | + url = result.getResource(stripped); | |
440 | + } | |
441 | + | |
442 | + if (url == null) { | |
443 | + result = ConfigurationLoader.class.getClassLoader(); | |
444 | + url = ConfigurationLoader.class.getClassLoader().getResource(stripped); | |
445 | + } | |
446 | + | |
447 | + if (url == null) { | |
448 | + result = null; | |
449 | + } | |
450 | + | |
451 | + return result; | |
452 | + } | |
453 | + | |
454 | + public static URL getResourceAsURL(final String resource) throws FileNotFoundException { | |
455 | + ClassLoader classLoader = getClassLoaderForResource(resource); | |
456 | + return classLoader != null ? classLoader.getResource(resource) : null; | |
457 | + } | |
458 | + | |
459 | + private ResourceBundle getBundle() { | |
460 | + if (bundle == null) { | |
461 | + bundle = ResourceBundleProducer.create("demoiselle-core-bundle"); | |
462 | + } | |
463 | + | |
464 | + return bundle; | |
465 | + } | |
466 | + | |
467 | + private Logger getLogger() { | |
468 | + if (logger == null) { | |
469 | + logger = LoggerProducer.create(ConfigurationLoader.class); | |
470 | + } | |
471 | + | |
472 | + return logger; | |
473 | + } | |
474 | + | |
475 | + private CoreBootstrap getBootstrap() { | |
476 | + if (bootstrap == null) { | |
477 | + bootstrap = Beans.getReference(CoreBootstrap.class); | |
478 | + } | |
479 | + | |
480 | + return bootstrap; | |
481 | + } | |
482 | +} | ... | ... |
impl/extension/jsf/pom.xml
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/proxy/FacesContextProxy.java
0 → 100644
... | ... | @@ -0,0 +1,184 @@ |
1 | +package br.gov.frameworkdemoiselle.internal.proxy; | |
2 | + | |
3 | +import java.io.Serializable; | |
4 | +import java.util.Iterator; | |
5 | +import java.util.List; | |
6 | +import java.util.Map; | |
7 | + | |
8 | +import javax.el.ELContext; | |
9 | +import javax.enterprise.inject.Default; | |
10 | +import javax.faces.application.Application; | |
11 | +import javax.faces.application.FacesMessage; | |
12 | +import javax.faces.application.FacesMessage.Severity; | |
13 | +import javax.faces.application.ProjectStage; | |
14 | +import javax.faces.component.UIViewRoot; | |
15 | +import javax.faces.context.ExceptionHandler; | |
16 | +import javax.faces.context.ExternalContext; | |
17 | +import javax.faces.context.FacesContext; | |
18 | +import javax.faces.context.PartialViewContext; | |
19 | +import javax.faces.context.ResponseStream; | |
20 | +import javax.faces.context.ResponseWriter; | |
21 | +import javax.faces.event.PhaseId; | |
22 | +import javax.faces.render.RenderKit; | |
23 | + | |
24 | +@Default | |
25 | +public class FacesContextProxy extends FacesContext implements Serializable { | |
26 | + | |
27 | + private static final long serialVersionUID = 1L; | |
28 | + | |
29 | + private FacesContext getDelegate() { | |
30 | + return FacesContext.getCurrentInstance(); | |
31 | + } | |
32 | + | |
33 | + public int hashCode() { | |
34 | + return getDelegate().hashCode(); | |
35 | + } | |
36 | + | |
37 | + public boolean equals(Object obj) { | |
38 | + return getDelegate().equals(obj); | |
39 | + } | |
40 | + | |
41 | + public Application getApplication() { | |
42 | + return getDelegate().getApplication(); | |
43 | + } | |
44 | + | |
45 | + public Map<Object, Object> getAttributes() { | |
46 | + return getDelegate().getAttributes(); | |
47 | + } | |
48 | + | |
49 | + public PartialViewContext getPartialViewContext() { | |
50 | + return getDelegate().getPartialViewContext(); | |
51 | + } | |
52 | + | |
53 | + public Iterator<String> getClientIdsWithMessages() { | |
54 | + return getDelegate().getClientIdsWithMessages(); | |
55 | + } | |
56 | + | |
57 | + public String toString() { | |
58 | + return getDelegate().toString(); | |
59 | + } | |
60 | + | |
61 | + public ELContext getELContext() { | |
62 | + return getDelegate().getELContext(); | |
63 | + } | |
64 | + | |
65 | + public ExceptionHandler getExceptionHandler() { | |
66 | + return getDelegate().getExceptionHandler(); | |
67 | + } | |
68 | + | |
69 | + public void setExceptionHandler(ExceptionHandler exceptionHandler) { | |
70 | + getDelegate().setExceptionHandler(exceptionHandler); | |
71 | + } | |
72 | + | |
73 | + public ExternalContext getExternalContext() { | |
74 | + return getDelegate().getExternalContext(); | |
75 | + } | |
76 | + | |
77 | + public Severity getMaximumSeverity() { | |
78 | + return getDelegate().getMaximumSeverity(); | |
79 | + } | |
80 | + | |
81 | + public Iterator<FacesMessage> getMessages() { | |
82 | + return getDelegate().getMessages(); | |
83 | + } | |
84 | + | |
85 | + public List<FacesMessage> getMessageList() { | |
86 | + return getDelegate().getMessageList(); | |
87 | + } | |
88 | + | |
89 | + public List<FacesMessage> getMessageList(String clientId) { | |
90 | + return getDelegate().getMessageList(clientId); | |
91 | + } | |
92 | + | |
93 | + public Iterator<FacesMessage> getMessages(String clientId) { | |
94 | + return getDelegate().getMessages(clientId); | |
95 | + } | |
96 | + | |
97 | + public RenderKit getRenderKit() { | |
98 | + return getDelegate().getRenderKit(); | |
99 | + } | |
100 | + | |
101 | + public boolean getRenderResponse() { | |
102 | + return getDelegate().getRenderResponse(); | |
103 | + } | |
104 | + | |
105 | + public boolean getResponseComplete() { | |
106 | + return getDelegate().getResponseComplete(); | |
107 | + } | |
108 | + | |
109 | + public boolean isValidationFailed() { | |
110 | + return getDelegate().isValidationFailed(); | |
111 | + } | |
112 | + | |
113 | + public ResponseStream getResponseStream() { | |
114 | + return getDelegate().getResponseStream(); | |
115 | + } | |
116 | + | |
117 | + public void setResponseStream(ResponseStream responseStream) { | |
118 | + getDelegate().setResponseStream(responseStream); | |
119 | + } | |
120 | + | |
121 | + public ResponseWriter getResponseWriter() { | |
122 | + return getDelegate().getResponseWriter(); | |
123 | + } | |
124 | + | |
125 | + public void setResponseWriter(ResponseWriter responseWriter) { | |
126 | + getDelegate().setResponseWriter(responseWriter); | |
127 | + } | |
128 | + | |
129 | + public UIViewRoot getViewRoot() { | |
130 | + return getDelegate().getViewRoot(); | |
131 | + } | |
132 | + | |
133 | + public void setViewRoot(UIViewRoot root) { | |
134 | + getDelegate().setViewRoot(root); | |
135 | + } | |
136 | + | |
137 | + public void addMessage(String clientId, FacesMessage message) { | |
138 | + getDelegate().addMessage(clientId, message); | |
139 | + } | |
140 | + | |
141 | + public boolean isReleased() { | |
142 | + return getDelegate().isReleased(); | |
143 | + } | |
144 | + | |
145 | + public void release() { | |
146 | + getDelegate().release(); | |
147 | + } | |
148 | + | |
149 | + public void renderResponse() { | |
150 | + getDelegate().renderResponse(); | |
151 | + } | |
152 | + | |
153 | + public boolean isPostback() { | |
154 | + return getDelegate().isPostback(); | |
155 | + } | |
156 | + | |
157 | + public void responseComplete() { | |
158 | + getDelegate().responseComplete(); | |
159 | + } | |
160 | + | |
161 | + public void validationFailed() { | |
162 | + getDelegate().validationFailed(); | |
163 | + } | |
164 | + | |
165 | + public PhaseId getCurrentPhaseId() { | |
166 | + return getDelegate().getCurrentPhaseId(); | |
167 | + } | |
168 | + | |
169 | + public void setCurrentPhaseId(PhaseId currentPhaseId) { | |
170 | + getDelegate().setCurrentPhaseId(currentPhaseId); | |
171 | + } | |
172 | + | |
173 | + public void setProcessingEvents(boolean processingEvents) { | |
174 | + getDelegate().setProcessingEvents(processingEvents); | |
175 | + } | |
176 | + | |
177 | + public boolean isProcessingEvents() { | |
178 | + return getDelegate().isProcessingEvents(); | |
179 | + } | |
180 | + | |
181 | + public boolean isProjectStage(ProjectStage stage) { | |
182 | + return getDelegate().isProjectStage(stage); | |
183 | + } | |
184 | +} | ... | ... |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/context/ViewContextTest.java
... | ... | @@ -65,73 +65,73 @@ public class ViewContextTest { |
65 | 65 | context = new ViewContext(); |
66 | 66 | } |
67 | 67 | |
68 | - @SuppressWarnings("unchecked") | |
69 | - @Test | |
70 | - public void testGetViewMapContainsInstance() { | |
71 | - String instance = "instance"; | |
72 | - | |
73 | - Bean<?> bean = PowerMock.createMock(Bean.class); | |
74 | - EasyMock.expect(bean.getName()).andReturn(instance).anyTimes(); | |
75 | - | |
76 | - Map<String,Object> map = PowerMock.createMock(Map.class); | |
77 | - EasyMock.expect(map.containsKey(EasyMock.anyObject(String.class))).andReturn(true); | |
78 | - EasyMock.expect(map.get(EasyMock.anyObject(String.class))).andReturn(instance); | |
79 | - | |
80 | - PowerMock.mockStatic(Faces.class); | |
81 | - EasyMock.expect(Faces.getViewMap()).andReturn(map); | |
82 | - | |
83 | - PowerMock.replay(Faces.class, bean, map); | |
84 | - | |
85 | - assertEquals(instance, context.get(bean)); | |
86 | - | |
87 | - PowerMock.verifyAll(); | |
88 | - } | |
89 | - | |
90 | - @SuppressWarnings("unchecked") | |
91 | - @Test | |
92 | - public void testGetViewMapDoesNotContainsInstance() { | |
93 | - String instance = "instance"; | |
94 | - | |
95 | - Bean<String> bean = PowerMock.createMock(Bean.class); | |
96 | - EasyMock.expect(bean.getName()).andReturn(instance).anyTimes(); | |
97 | - EasyMock.expect(bean.create(EasyMock.anyObject(CreationalContext.class))).andReturn(instance); | |
98 | - | |
99 | - Map<String,Object> map = PowerMock.createMock(Map.class); | |
100 | - EasyMock.expect(map.containsKey(EasyMock.anyObject(String.class))).andReturn(false); | |
101 | - EasyMock.expect(map.put(EasyMock.anyObject(String.class), EasyMock.anyObject(String.class))).andReturn(null); | |
102 | - | |
103 | - PowerMock.mockStatic(Faces.class); | |
104 | - EasyMock.expect(Faces.getViewMap()).andReturn(map); | |
105 | - | |
106 | - CreationalContext<String> creationalContext = PowerMock.createMock(CreationalContext.class); | |
107 | - | |
108 | - PowerMock.replay(Faces.class, bean, map, creationalContext); | |
109 | - | |
110 | - assertEquals(instance, context.get(bean, creationalContext)); | |
111 | - | |
112 | - PowerMock.verifyAll(); | |
113 | - } | |
114 | - | |
115 | - @SuppressWarnings("unchecked") | |
116 | - @Test | |
117 | - public void testGetViewMapInstanceNull() { | |
118 | - String instance = "instance"; | |
119 | - | |
120 | - Bean<String> bean = PowerMock.createMock(Bean.class); | |
121 | - EasyMock.expect(bean.getName()).andReturn(instance).anyTimes(); | |
122 | - | |
123 | - Map<String,Object> map = PowerMock.createMock(Map.class); | |
124 | - EasyMock.expect(map.containsKey(EasyMock.anyObject(String.class))).andReturn(false); | |
125 | - | |
126 | - PowerMock.mockStatic(Faces.class); | |
127 | - EasyMock.expect(Faces.getViewMap()).andReturn(map); | |
128 | - | |
129 | - PowerMock.replay(Faces.class, bean, map); | |
130 | - | |
131 | - assertEquals(null, context.get(bean)); | |
132 | - | |
133 | - PowerMock.verifyAll(); | |
134 | - } | |
68 | +// @SuppressWarnings("unchecked") | |
69 | +// @Test | |
70 | +// public void testGetViewMapContainsInstance() { | |
71 | +// String instance = "instance"; | |
72 | +// | |
73 | +// Bean<?> bean = PowerMock.createMock(Bean.class); | |
74 | +// EasyMock.expect(bean.getName()).andReturn(instance).anyTimes(); | |
75 | +// | |
76 | +// Map<String,Object> map = PowerMock.createMock(Map.class); | |
77 | +// EasyMock.expect(map.containsKey(EasyMock.anyObject(String.class))).andReturn(true); | |
78 | +// EasyMock.expect(map.get(EasyMock.anyObject(String.class))).andReturn(instance); | |
79 | +// | |
80 | +// PowerMock.mockStatic(Faces.class); | |
81 | +// EasyMock.expect(Faces.getViewMap()).andReturn(map); | |
82 | +// | |
83 | +// PowerMock.replay(Faces.class, bean, map); | |
84 | +// | |
85 | +// assertEquals(instance, context.get(bean)); | |
86 | +// | |
87 | +// PowerMock.verifyAll(); | |
88 | +// } | |
89 | +// | |
90 | +// @SuppressWarnings("unchecked") | |
91 | +// @Test | |
92 | +// public void testGetViewMapDoesNotContainsInstance() { | |
93 | +// String instance = "instance"; | |
94 | +// | |
95 | +// Bean<String> bean = PowerMock.createMock(Bean.class); | |
96 | +// EasyMock.expect(bean.getName()).andReturn(instance).anyTimes(); | |
97 | +// EasyMock.expect(bean.create(EasyMock.anyObject(CreationalContext.class))).andReturn(instance); | |
98 | +// | |
99 | +// Map<String,Object> map = PowerMock.createMock(Map.class); | |
100 | +// EasyMock.expect(map.containsKey(EasyMock.anyObject(String.class))).andReturn(false); | |
101 | +// EasyMock.expect(map.put(EasyMock.anyObject(String.class), EasyMock.anyObject(String.class))).andReturn(null); | |
102 | +// | |
103 | +// PowerMock.mockStatic(Faces.class); | |
104 | +// EasyMock.expect(Faces.getViewMap()).andReturn(map); | |
105 | +// | |
106 | +// CreationalContext<String> creationalContext = PowerMock.createMock(CreationalContext.class); | |
107 | +// | |
108 | +// PowerMock.replay(Faces.class, bean, map, creationalContext); | |
109 | +// | |
110 | +// assertEquals(instance, context.get(bean, creationalContext)); | |
111 | +// | |
112 | +// PowerMock.verifyAll(); | |
113 | +// } | |
114 | +// | |
115 | +// @SuppressWarnings("unchecked") | |
116 | +// @Test | |
117 | +// public void testGetViewMapInstanceNull() { | |
118 | +// String instance = "instance"; | |
119 | +// | |
120 | +// Bean<String> bean = PowerMock.createMock(Bean.class); | |
121 | +// EasyMock.expect(bean.getName()).andReturn(instance).anyTimes(); | |
122 | +// | |
123 | +// Map<String,Object> map = PowerMock.createMock(Map.class); | |
124 | +// EasyMock.expect(map.containsKey(EasyMock.anyObject(String.class))).andReturn(false); | |
125 | +// | |
126 | +// PowerMock.mockStatic(Faces.class); | |
127 | +// EasyMock.expect(Faces.getViewMap()).andReturn(map); | |
128 | +// | |
129 | +// PowerMock.replay(Faces.class, bean, map); | |
130 | +// | |
131 | +// assertEquals(null, context.get(bean)); | |
132 | +// | |
133 | +// PowerMock.verifyAll(); | |
134 | +// } | |
135 | 135 | |
136 | 136 | @Test |
137 | 137 | public void testScopeClass() { | ... | ... |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/producer/FacesContextProducerTest.java
... | ... | @@ -1,87 +0,0 @@ |
1 | -/* | |
2 | - * Demoiselle Framework | |
3 | - * Copyright (C) 2010 SERPRO | |
4 | - * ---------------------------------------------------------------------------- | |
5 | - * This file is part of Demoiselle Framework. | |
6 | - * | |
7 | - * Demoiselle Framework is free software; you can redistribute it and/or | |
8 | - * modify it under the terms of the GNU Lesser General Public License version 3 | |
9 | - * as published by the Free Software Foundation. | |
10 | - * | |
11 | - * This program is distributed in the hope that it will be useful, | |
12 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | - * GNU General Public License for more details. | |
15 | - * | |
16 | - * You should have received a copy of the GNU Lesser General Public License version 3 | |
17 | - * along with this program; if not, see <http://www.gnu.org/licenses/> | |
18 | - * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
19 | - * Fifth Floor, Boston, MA 02110-1301, USA. | |
20 | - * ---------------------------------------------------------------------------- | |
21 | - * Este arquivo é parte do Framework Demoiselle. | |
22 | - * | |
23 | - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
24 | - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
25 | - * do Software Livre (FSF). | |
26 | - * | |
27 | - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
28 | - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
29 | - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
30 | - * para maiores detalhes. | |
31 | - * | |
32 | - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
33 | - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
34 | - * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
35 | - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
36 | - */ | |
37 | -package br.gov.frameworkdemoiselle.internal.producer; | |
38 | -import static org.easymock.EasyMock.expect; | |
39 | -import static org.junit.Assert.assertEquals; | |
40 | -import static org.junit.Assert.fail; | |
41 | -import static org.powermock.api.easymock.PowerMock.mockStatic; | |
42 | -import static org.powermock.api.easymock.PowerMock.replay; | |
43 | -import static org.powermock.api.easymock.PowerMock.verifyAll; | |
44 | - | |
45 | -import javax.enterprise.context.ContextNotActiveException; | |
46 | -import javax.faces.context.FacesContext; | |
47 | - | |
48 | -import org.junit.Before; | |
49 | -import org.junit.Test; | |
50 | -import org.junit.runner.RunWith; | |
51 | -import org.powermock.api.easymock.PowerMock; | |
52 | -import org.powermock.core.classloader.annotations.PrepareForTest; | |
53 | -import org.powermock.modules.junit4.PowerMockRunner; | |
54 | - | |
55 | -@RunWith(PowerMockRunner.class) | |
56 | -@PrepareForTest({ FacesContext.class }) | |
57 | -public class FacesContextProducerTest { | |
58 | - | |
59 | - private FacesContextProducer producer; | |
60 | - | |
61 | - @Before | |
62 | - public void before() { | |
63 | - this.producer = new FacesContextProducer(); | |
64 | - } | |
65 | - | |
66 | - @Test | |
67 | - public void createOK() { | |
68 | - mockStatic(FacesContext.class); | |
69 | - FacesContext facesContext = PowerMock.createMock(FacesContext.class); | |
70 | - expect(FacesContext.getCurrentInstance()).andReturn(facesContext); | |
71 | - replay(facesContext, FacesContext.class); | |
72 | - assertEquals(facesContext, producer.create()); | |
73 | - verifyAll(); | |
74 | - } | |
75 | - | |
76 | - @Test | |
77 | - public void createNOK() { | |
78 | - mockStatic(FacesContext.class); | |
79 | - expect(FacesContext.getCurrentInstance()).andReturn(null); | |
80 | - replay(FacesContext.class); | |
81 | - try { | |
82 | - this.producer.create(); | |
83 | - fail(); | |
84 | - } catch(ContextNotActiveException exception) {} | |
85 | - verifyAll(); | |
86 | - } | |
87 | -} |
site/apt/release-notes.apt
... | ... | @@ -43,6 +43,14 @@ Notas de Versão |
43 | 43 | |
44 | 44 | * {{{http://demoiselle.atlassian.net/secure/ReleaseNote.jspa?projectId=10007&version=10800}Notas de Versão no JIRA}} |
45 | 45 | |
46 | +* {{{../2.3.4/}v2.3.4}} | |
47 | + | |
48 | + * {{{https://demoiselle.atlassian.net/secure/ReleaseNote.jspa?projectId=10007&version=11100}Notas de Versão no JIRA}} | |
49 | + | |
50 | +* {{{../2.3.3/}v2.3.3}} | |
51 | + | |
52 | + * {{{http://demoiselle.atlassian.net/secure/ReleaseNote.jspa?projectId=10007&version=10900}Notas de Versão no JIRA}} | |
53 | + | |
46 | 54 | * {{{../2.3.2/}v2.3.2}} |
47 | 55 | |
48 | 56 | * {{{http://demoiselle.atlassian.net/secure/ReleaseNote.jspa?projectId=10007&version=10500}Notas de Versão no JIRA}} |
... | ... | @@ -232,5 +240,4 @@ Notas de Versão |
232 | 240 | * {{{../latest1x.php}v1.x.x}} |
233 | 241 | |
234 | 242 | * Para versões anteriores {{{../latest1x.php}clique aqui}}. |
235 | - | |
236 | - | |
237 | 243 | \ No newline at end of file |
244 | + | ... | ... |