Commit b14e654fdaa20ff57099e15ea2b7acef557e07ac
1 parent
6a09fdf9
Exists in
master
Aplicando o padrão de formatação do código-fonte
Showing
62 changed files
with
408 additions
and
488 deletions
Show diff stats
impl/core/src/main/java/br/gov/frameworkdemoiselle/annotation/Ignore.java
impl/core/src/main/java/br/gov/frameworkdemoiselle/annotation/ManagedOperation.java
... | ... | @@ -47,24 +47,28 @@ import javax.enterprise.util.Nonbinding; |
47 | 47 | import br.gov.frameworkdemoiselle.DemoiselleException; |
48 | 48 | |
49 | 49 | /** |
50 | - * <p>Indicates that a method is a <b>managed operation</b>, meaning you can manage some aspect of the application by calling it from a external management client.</p> | |
51 | - * <p>This annotation can't be used together with {@link ManagedProperty}, doing so will throw a {@link DemoiselleException}.</p> | |
50 | + * <p> | |
51 | + * Indicates that a method is a <b>managed operation</b>, meaning you can manage some aspect of the application by | |
52 | + * calling it from a external management client. | |
53 | + * </p> | |
54 | + * <p> | |
55 | + * This annotation can't be used together with {@link ManagedProperty}, doing so will throw a | |
56 | + * {@link DemoiselleException}. | |
57 | + * </p> | |
52 | 58 | * |
53 | 59 | * @author SERPRO |
54 | - * | |
55 | 60 | */ |
56 | 61 | @Documented |
57 | -@Target({ElementType.METHOD}) | |
62 | +@Target({ ElementType.METHOD }) | |
58 | 63 | @Retention(RetentionPolicy.RUNTIME) |
59 | 64 | public @interface ManagedOperation { |
60 | - | |
65 | + | |
61 | 66 | /** |
62 | - * Description that will be used to publish the operation to clients. | |
63 | - * Defaults to an empty description. | |
67 | + * Description that will be used to publish the operation to clients. Defaults to an empty description. | |
64 | 68 | */ |
65 | 69 | @Nonbinding |
66 | 70 | String description() default ""; |
67 | - | |
71 | + | |
68 | 72 | /** |
69 | 73 | * Type of operation. Defaults to {@link OperationType#UNKNOWN}. |
70 | 74 | */ | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/annotation/ManagedProperty.java
... | ... | @@ -45,57 +45,65 @@ import java.lang.annotation.Target; |
45 | 45 | import javax.enterprise.util.Nonbinding; |
46 | 46 | |
47 | 47 | /** |
48 | - * <p>Indicates that a field must be exposed as a property to management clients.</p> | |
49 | - * <p>The property will be writable if there's a public setter method | |
50 | - * declared for the field and readable if there's a getter method. You can override this behaviour by passing a value | |
51 | - * to the {@link #accessLevel()} property.</p> | |
52 | - * <p>It's a runtime error to annotate a field with no getter and no setter method.</p> | |
53 | - * <p>It's also a runtime error to declare a field as a property and one or both of it's getter and setter | |
54 | - * methods as an operation using the {@link ManagedOperation} annotation.</p> | |
48 | + * <p> | |
49 | + * Indicates that a field must be exposed as a property to management clients. | |
50 | + * </p> | |
51 | + * <p> | |
52 | + * The property will be writable if there's a public setter method declared for the field and readable if there's a | |
53 | + * getter method. You can override this behaviour by passing a value to the {@link #accessLevel()} property. | |
54 | + * </p> | |
55 | + * <p> | |
56 | + * It's a runtime error to annotate a field with no getter and no setter method. | |
57 | + * </p> | |
58 | + * <p> | |
59 | + * It's also a runtime error to declare a field as a property and one or both of it's getter and setter methods as an | |
60 | + * operation using the {@link ManagedOperation} annotation. | |
61 | + * </p> | |
55 | 62 | * |
56 | 63 | * @author SERPRO |
57 | - * | |
58 | 64 | */ |
59 | 65 | @Documented |
60 | -@Target({ElementType.FIELD}) | |
66 | +@Target({ ElementType.FIELD }) | |
61 | 67 | @Retention(RetentionPolicy.RUNTIME) |
62 | 68 | public @interface ManagedProperty { |
63 | - | |
69 | + | |
64 | 70 | /** |
65 | 71 | * @return The description of this property exposed to management clients. |
66 | 72 | */ |
67 | 73 | @Nonbinding |
68 | 74 | String description() default ""; |
69 | - | |
75 | + | |
70 | 76 | @Nonbinding |
71 | 77 | ManagedPropertyAccess accessLevel() default ManagedPropertyAccess.DEFAULT; |
72 | - | |
78 | + | |
73 | 79 | /** |
74 | - * <p>Access level of a managed property.</p> | |
75 | - * | |
76 | - * <p>These values only affect access via external management clients, the application is still able to inject and use the normal visibility of the property | |
77 | - * by Java standards.</p> | |
80 | + * <p> | |
81 | + * Access level of a managed property. | |
82 | + * </p> | |
83 | + * <p> | |
84 | + * These values only affect access via external management clients, the application is still able to inject and use | |
85 | + * the normal visibility of the property by Java standards. | |
86 | + * </p> | |
78 | 87 | * |
79 | 88 | * @author serpro |
80 | - * | |
81 | 89 | */ |
82 | - enum ManagedPropertyAccess{ | |
83 | - | |
90 | + enum ManagedPropertyAccess { | |
91 | + | |
84 | 92 | /** |
85 | 93 | * Restricts a property to be only readable even if a setter method exists. |
86 | 94 | */ |
87 | 95 | READ_ONLY |
88 | - | |
96 | + | |
89 | 97 | /** |
90 | 98 | * Restricts a property to be only writeable even if a getter method exists. |
91 | 99 | */ |
92 | - ,WRITE_ONLY | |
93 | - | |
100 | + , WRITE_ONLY | |
101 | + | |
94 | 102 | /** |
95 | - * Says that the read or write access will | |
96 | - * be determined by the presence of a getter method <code>(getProperty())</code> or setter method <code>(setProperty(propertyValue))</code> for a property. | |
103 | + * Says that the read or write access will be determined by the presence of a getter method | |
104 | + * <code>(getProperty())</code> or setter method <code>(setProperty(propertyValue))</code> for a property. | |
97 | 105 | */ |
98 | - ,DEFAULT; | |
106 | + , DEFAULT; | |
99 | 107 | } |
100 | 108 | |
101 | 109 | } | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/annotation/OperationParameter.java
... | ... | @@ -45,29 +45,31 @@ import java.lang.annotation.Target; |
45 | 45 | import javax.enterprise.util.Nonbinding; |
46 | 46 | |
47 | 47 | /** |
48 | - * <p>Optional annotation to write additional detail about an operation's parameter.</p> | |
49 | - * <p>This annotation is ignored for non-operation methods.</p> | |
48 | + * <p> | |
49 | + * Optional annotation to write additional detail about an operation's parameter. | |
50 | + * </p> | |
51 | + * <p> | |
52 | + * This annotation is ignored for non-operation methods. | |
53 | + * </p> | |
50 | 54 | * |
51 | 55 | * @author SERPRO |
52 | - * | |
53 | 56 | */ |
54 | 57 | @Documented |
55 | -@Target({ElementType.PARAMETER}) | |
58 | +@Target({ ElementType.PARAMETER }) | |
56 | 59 | @Retention(RetentionPolicy.RUNTIME) |
57 | 60 | public @interface OperationParameter { |
58 | - | |
61 | + | |
59 | 62 | /** |
60 | 63 | * Name that will be used to publish this operation's parameter to clients. |
61 | 64 | */ |
62 | 65 | @Nonbinding |
63 | 66 | String name(); |
64 | - | |
67 | + | |
65 | 68 | /** |
66 | - * Optional description that will be used to publish this operation's parameter to clients. | |
67 | - * Defaults to an empty description. | |
69 | + * Optional description that will be used to publish this operation's parameter to clients. Defaults to an empty | |
70 | + * description. | |
68 | 71 | */ |
69 | 72 | @Nonbinding |
70 | 73 | String description() default ""; |
71 | - | |
72 | 74 | |
73 | 75 | } | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/annotation/OperationType.java
... | ... | @@ -38,52 +38,50 @@ package br.gov.frameworkdemoiselle.annotation; |
38 | 38 | |
39 | 39 | import javax.management.MBeanOperationInfo; |
40 | 40 | |
41 | - | |
42 | 41 | /** |
43 | - * <p>Define the operation type for an operation inside a ManagementController class.</p> | |
44 | - * | |
45 | - * <p>This is an optional annotation and it's significanse will change based on the management extension | |
46 | - * used. Most extensions will just publish this information to the client so it can better show to the user the inner | |
47 | - * workings of the annotated operation.</p> | |
48 | - * | |
42 | + * <p> | |
43 | + * Define the operation type for an operation inside a ManagementController class. | |
44 | + * </p> | |
45 | + * <p> | |
46 | + * This is an optional annotation and it's significanse will change based on the management extension used. Most | |
47 | + * extensions will just publish this information to the client so it can better show to the user the inner workings of | |
48 | + * the annotated operation. | |
49 | + * </p> | |
49 | 50 | * |
50 | 51 | * @author SERPRO |
51 | - * | |
52 | 52 | */ |
53 | 53 | public enum OperationType { |
54 | - | |
54 | + | |
55 | 55 | /** |
56 | - * ManagedOperation is write-only, it causes the application | |
57 | - * to change some of it's behaviour but doesn't return any kind of information | |
56 | + * ManagedOperation is write-only, it causes the application to change some of it's behaviour but doesn't return any | |
57 | + * kind of information | |
58 | 58 | */ |
59 | - ACTION(MBeanOperationInfo.ACTION) | |
60 | - , | |
59 | + ACTION(MBeanOperationInfo.ACTION), | |
61 | 60 | /** |
62 | 61 | * ManagedOperation is read-only, it will operate over data provided by the application and return some information, |
63 | 62 | * but will not change the application in any way. |
64 | 63 | */ |
65 | - INFO(MBeanOperationInfo.INFO) | |
66 | - , | |
64 | + INFO(MBeanOperationInfo.INFO), | |
67 | 65 | /** |
68 | - * ManagedOperation is read-write, it will both change the way the application work and return some information regarding | |
69 | - * the result of the operation. | |
66 | + * ManagedOperation is read-write, it will both change the way the application work and return some information | |
67 | + * regarding the result of the operation. | |
70 | 68 | */ |
71 | - ACTION_INFO(MBeanOperationInfo.ACTION_INFO) | |
72 | - , | |
69 | + ACTION_INFO(MBeanOperationInfo.ACTION_INFO), | |
73 | 70 | /** |
74 | - * The effect of calling this operation is unknown. This is the default type and if this type is assigned to an operation, | |
75 | - * the user must rely on the {@link ManagedOperation#description()} attribute to learn about how the operation works. | |
71 | + * The effect of calling this operation is unknown. This is the default type and if this type is assigned to an | |
72 | + * operation, the user must rely on the {@link ManagedOperation#description()} attribute to learn about how the | |
73 | + * operation works. | |
76 | 74 | */ |
77 | 75 | UNKNOWN(MBeanOperationInfo.UNKNOWN); |
78 | - | |
76 | + | |
79 | 77 | private int operationTypeValue; |
80 | - | |
81 | - private OperationType(int type){ | |
78 | + | |
79 | + private OperationType(int type) { | |
82 | 80 | this.operationTypeValue = type; |
83 | 81 | } |
84 | - | |
85 | - public int getValue(){ | |
82 | + | |
83 | + public int getValue() { | |
86 | 84 | return operationTypeValue; |
87 | 85 | } |
88 | - | |
86 | + | |
89 | 87 | } | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/configuration/ConfigType.java
impl/core/src/main/java/br/gov/frameworkdemoiselle/exception/ExceptionHandlerInterceptor.java
... | ... | @@ -52,9 +52,9 @@ import javax.interceptor.InvocationContext; |
52 | 52 | import org.slf4j.Logger; |
53 | 53 | |
54 | 54 | import br.gov.frameworkdemoiselle.DemoiselleException; |
55 | -import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; | |
56 | -import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | |
57 | 55 | import br.gov.frameworkdemoiselle.stereotype.Controller; |
56 | +import br.gov.frameworkdemoiselle.util.Beans; | |
57 | +import br.gov.frameworkdemoiselle.util.NameQualifier; | |
58 | 58 | import br.gov.frameworkdemoiselle.util.ResourceBundle; |
59 | 59 | |
60 | 60 | @Interceptor |
... | ... | @@ -63,9 +63,9 @@ public class ExceptionHandlerInterceptor implements Serializable { |
63 | 63 | |
64 | 64 | private static final long serialVersionUID = 1L; |
65 | 65 | |
66 | - private static ResourceBundle bundle; | |
66 | + private static transient ResourceBundle bundle; | |
67 | 67 | |
68 | - private static Logger logger; | |
68 | + private static transient Logger logger; | |
69 | 69 | |
70 | 70 | private final Map<Class<?>, Map<Class<?>, Method>> cache = new HashMap<Class<?>, Map<Class<?>, Method>>(); |
71 | 71 | |
... | ... | @@ -199,7 +199,7 @@ public class ExceptionHandlerInterceptor implements Serializable { |
199 | 199 | |
200 | 200 | private static ResourceBundle getBundle() { |
201 | 201 | if (bundle == null) { |
202 | - bundle = ResourceBundleProducer.create("demoiselle-core-bundle"); | |
202 | + bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle")); | |
203 | 203 | } |
204 | 204 | |
205 | 205 | return bundle; |
... | ... | @@ -207,7 +207,7 @@ public class ExceptionHandlerInterceptor implements Serializable { |
207 | 207 | |
208 | 208 | private static Logger getLogger() { |
209 | 209 | if (logger == null) { |
210 | - logger = LoggerProducer.create(ExceptionHandlerInterceptor.class); | |
210 | + logger = Beans.getReference(Logger.class, new NameQualifier(ExceptionHandlerInterceptor.class.getName())); | |
211 | 211 | } |
212 | 212 | |
213 | 213 | return logger; | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/AbstractLifecycleBootstrap.java
... | ... | @@ -110,10 +110,10 @@ public abstract class AbstractLifecycleBootstrap<A extends Annotation> implement |
110 | 110 | } |
111 | 111 | |
112 | 112 | public void loadTempContexts(@Observes final AfterBeanDiscovery event) { |
113 | - //Caso este bootstrap rode antes do CoreBootstrap. Não há problemas em chamar este método várias vezes, ele | |
114 | - //ignora chamadas adicionais. | |
113 | + // Caso este bootstrap rode antes do CoreBootstrap. Não há problemas em chamar este método várias vezes, ele | |
114 | + // ignora chamadas adicionais. | |
115 | 115 | ContextManager.initialize(event); |
116 | - | |
116 | + | |
117 | 117 | // Não registrar o contexto de aplicação pq ele já é registrado pela implementação do CDI |
118 | 118 | ContextManager.add(new ThreadLocalContext(ViewScoped.class), event); |
119 | 119 | ContextManager.add(new ThreadLocalContext(SessionScoped.class), event); | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/CustomInjectionPoint.java
... | ... | @@ -1,136 +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.bootstrap; | |
38 | - | |
39 | -import java.lang.annotation.Annotation; | |
40 | -import java.lang.reflect.Member; | |
41 | -import java.lang.reflect.Type; | |
42 | -import java.util.Arrays; | |
43 | -import java.util.HashSet; | |
44 | -import java.util.Set; | |
45 | - | |
46 | -import javax.enterprise.inject.spi.Annotated; | |
47 | -import javax.enterprise.inject.spi.Bean; | |
48 | -import javax.enterprise.inject.spi.InjectionPoint; | |
49 | - | |
50 | -public class CustomInjectionPoint implements InjectionPoint { | |
51 | - | |
52 | - private final Bean<?> bean; | |
53 | - | |
54 | - private final Type beanType; | |
55 | - | |
56 | - private final Set<Annotation> qualifiers; | |
57 | - | |
58 | - public CustomInjectionPoint(Bean<?> bean, Type beanType, Annotation... qualifiers) { | |
59 | - this.bean = bean; | |
60 | - this.beanType = beanType; | |
61 | - this.qualifiers = new HashSet<Annotation>(Arrays.asList(qualifiers)); | |
62 | - } | |
63 | - | |
64 | - @Override | |
65 | - public Type getType() { | |
66 | - return this.beanType; | |
67 | - } | |
68 | - | |
69 | - @Override | |
70 | - public Set<Annotation> getQualifiers() { | |
71 | - return this.qualifiers; | |
72 | - } | |
73 | - | |
74 | - @Override | |
75 | - public Bean<?> getBean() { | |
76 | - return this.bean; | |
77 | - } | |
78 | - | |
79 | - @Override | |
80 | - public Member getMember() { | |
81 | - return null; | |
82 | - } | |
83 | - | |
84 | - @Override | |
85 | - public boolean isDelegate() { | |
86 | - return false; | |
87 | - } | |
88 | - | |
89 | - @Override | |
90 | - public boolean isTransient() { | |
91 | - return false; | |
92 | - } | |
93 | - | |
94 | - @Override | |
95 | - public Annotated getAnnotated() { | |
96 | - return new Annotated() { | |
97 | - | |
98 | - @Override | |
99 | - public Type getBaseType() { | |
100 | - // TODO Auto-generated method stub | |
101 | - return null; | |
102 | - } | |
103 | - | |
104 | - @Override | |
105 | - public Set<Type> getTypeClosure() { | |
106 | - // TODO Auto-generated method stub | |
107 | - return null; | |
108 | - } | |
109 | - | |
110 | - @Override | |
111 | - @SuppressWarnings("unchecked") | |
112 | - public <T extends Annotation> T getAnnotation(Class<T> annotationType) { | |
113 | - T result = null; | |
114 | - | |
115 | - for (Annotation annotation : getAnnotations()) { | |
116 | - if (annotation.annotationType() == annotationType) { | |
117 | - result = (T) annotation; | |
118 | - break; | |
119 | - } | |
120 | - } | |
121 | - | |
122 | - return result; | |
123 | - } | |
124 | - | |
125 | - @Override | |
126 | - public Set<Annotation> getAnnotations() { | |
127 | - return qualifiers; | |
128 | - } | |
129 | - | |
130 | - @Override | |
131 | - public boolean isAnnotationPresent(Class<? extends Annotation> annotationType) { | |
132 | - return qualifiers.contains(annotationType); | |
133 | - } | |
134 | - }; | |
135 | - } | |
136 | -} |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ManagementBootstrap.java
... | ... | @@ -32,8 +32,8 @@ public class ManagementBootstrap implements Extension { |
32 | 32 | |
33 | 33 | protected static List<AnnotatedType<?>> types = Collections.synchronizedList(new ArrayList<AnnotatedType<?>>()); |
34 | 34 | |
35 | - private List<Class<? extends ManagementExtension>> managementExtensionCache = Collections.synchronizedList(new ArrayList<Class<? extends ManagementExtension>>()); | |
36 | - | |
35 | + private List<Class<? extends ManagementExtension>> managementExtensionCache = Collections | |
36 | + .synchronizedList(new ArrayList<Class<? extends ManagementExtension>>()); | |
37 | 37 | |
38 | 38 | public <T> void detectAnnotation(@Observes final ProcessAnnotatedType<T> event, final BeanManager beanManager) { |
39 | 39 | if (event.getAnnotatedType().isAnnotationPresent(ManagementController.class)) { |
... | ... | @@ -47,27 +47,28 @@ public class ManagementBootstrap implements Extension { |
47 | 47 | } |
48 | 48 | |
49 | 49 | @SuppressWarnings("unchecked") |
50 | - public void registerAvailableManagedTypes(@Observes final AfterDeploymentValidation event,BeanManager beanManager) { | |
50 | + public void registerAvailableManagedTypes(@Observes final AfterDeploymentValidation event, BeanManager beanManager) { | |
51 | 51 | ResourceBundle bundle = ResourceBundleProducer.create("demoiselle-core-bundle", Locale.getDefault()); |
52 | 52 | |
53 | 53 | Management monitoringManager = Beans.getReference(Management.class); |
54 | 54 | for (AnnotatedType<?> type : types) { |
55 | - if (type.getJavaClass().isInterface() || Modifier.isAbstract(type.getJavaClass().getModifiers()) ){ | |
56 | - throw new DemoiselleException(bundle.getString("management-abstract-class-defined" , type.getJavaClass().getCanonicalName())); | |
55 | + if (type.getJavaClass().isInterface() || Modifier.isAbstract(type.getJavaClass().getModifiers())) { | |
56 | + throw new DemoiselleException(bundle.getString("management-abstract-class-defined", type.getJavaClass() | |
57 | + .getCanonicalName())); | |
57 | 58 | } |
58 | 59 | |
59 | 60 | ManagedType managedType = new ManagedType(type.getJavaClass()); |
60 | 61 | monitoringManager.addManagedType(managedType); |
61 | 62 | } |
62 | - | |
63 | + | |
63 | 64 | Set<Bean<?>> extensionBeans = beanManager.getBeans(ManagementExtension.class); |
64 | - if (extensionBeans!=null){ | |
65 | - for (Bean<?> bean : extensionBeans){ | |
65 | + if (extensionBeans != null) { | |
66 | + for (Bean<?> bean : extensionBeans) { | |
66 | 67 | Class<?> extensionConcreteClass = bean.getBeanClass(); |
67 | 68 | managementExtensionCache.add((Class<? extends ManagementExtension>) extensionConcreteClass); |
68 | 69 | } |
69 | 70 | } |
70 | - | |
71 | + | |
71 | 72 | monitoringManager.initialize(managementExtensionCache); |
72 | 73 | } |
73 | 74 | |
... | ... | @@ -75,7 +76,7 @@ public class ManagementBootstrap implements Extension { |
75 | 76 | |
76 | 77 | Management manager = Beans.getReference(Management.class); |
77 | 78 | manager.shutdown(managementExtensionCache); |
78 | - | |
79 | + | |
79 | 80 | managementExtensionCache.clear(); |
80 | 81 | types.clear(); |
81 | 82 | } | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/ContextManager.java
... | ... | @@ -51,8 +51,9 @@ public class ContextManager { |
51 | 51 | private static ResourceBundle bundle; |
52 | 52 | |
53 | 53 | private static Logger logger; |
54 | - | |
55 | - private ContextManager(){} | |
54 | + | |
55 | + private ContextManager() { | |
56 | + } | |
56 | 57 | |
57 | 58 | /** |
58 | 59 | * <p> |
... | ... | @@ -105,9 +106,9 @@ public class ContextManager { |
105 | 106 | } |
106 | 107 | |
107 | 108 | ContextManager.getLogger().trace( |
108 | - ContextManager.getBundle().getString("bootstrap-context-added", | |
109 | - context.getClass().getCanonicalName(), context.getScope().getCanonicalName())); | |
110 | - | |
109 | + ContextManager.getBundle().getString("bootstrap-context-added", context.getClass().getCanonicalName(), | |
110 | + context.getScope().getCanonicalName())); | |
111 | + | |
111 | 112 | context.setActive(false); |
112 | 113 | event.addContext(context); |
113 | 114 | contexts.add(new CustomContextCounter(context)); |
... | ... | @@ -194,8 +195,10 @@ public class ContextManager { |
194 | 195 | } |
195 | 196 | |
196 | 197 | /** |
197 | - * <p>This method should be called when the application is shutting down, usually by observing | |
198 | - * the {@link BeforeShutdown} event.</p> | |
198 | + * <p> | |
199 | + * This method should be called when the application is shutting down, usually by observing the | |
200 | + * {@link BeforeShutdown} event. | |
201 | + * </p> | |
199 | 202 | */ |
200 | 203 | public static synchronized void shutdown() { |
201 | 204 | for (CustomContextCounter context : contexts) { |
... | ... | @@ -252,7 +255,7 @@ class CustomContextCounter { |
252 | 255 | public CustomContext getInternalContext() { |
253 | 256 | return this.context; |
254 | 257 | } |
255 | - | |
258 | + | |
256 | 259 | public void setInternalContext(CustomContext context) { |
257 | 260 | this.context = context; |
258 | 261 | } |
... | ... | @@ -261,19 +264,14 @@ class CustomContextCounter { |
261 | 264 | try { |
262 | 265 | BeanManager beanManager = Beans.getReference(BeanManager.class); |
263 | 266 | Context c = beanManager.getContext(context.getScope()); |
264 | - | |
265 | - | |
267 | + | |
266 | 268 | if (c == context) { |
267 | 269 | activationCounter++; |
268 | - } | |
269 | - else{ | |
270 | + } else { | |
270 | 271 | ContextManager.getLogger().trace( |
271 | 272 | ContextManager.getBundle().getString("custom-context-already-activated", |
272 | - context.getClass().getCanonicalName() | |
273 | - ,c.getScope().getCanonicalName() | |
274 | - ,c.getClass().getCanonicalName() | |
275 | - ) | |
276 | - ); | |
273 | + context.getClass().getCanonicalName(), c.getScope().getCanonicalName(), | |
274 | + c.getClass().getCanonicalName())); | |
277 | 275 | } |
278 | 276 | } catch (ContextNotActiveException ce) { |
279 | 277 | context.setActive(true); |
... | ... | @@ -299,10 +297,10 @@ class CustomContextCounter { |
299 | 297 | } catch (ContextNotActiveException ce) { |
300 | 298 | } |
301 | 299 | } |
302 | - | |
300 | + | |
303 | 301 | public synchronized void shutdown() { |
304 | 302 | context.setActive(false); |
305 | - context=null; | |
306 | - activationCounter=0; | |
303 | + context = null; | |
304 | + activationCounter = 0; | |
307 | 305 | } |
308 | 306 | } | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/ManagedContext.java
... | ... | @@ -5,14 +5,13 @@ import javax.enterprise.context.RequestScoped; |
5 | 5 | import br.gov.frameworkdemoiselle.stereotype.ManagementController; |
6 | 6 | |
7 | 7 | /** |
8 | - * Context that stores {@link RequestScoped} beans during client calls to {@link ManagementController} classes. | |
9 | - * This context is only activated when no other context is active for {@link RequestScoped}. | |
8 | + * Context that stores {@link RequestScoped} beans during client calls to {@link ManagementController} classes. This | |
9 | + * context is only activated when no other context is active for {@link RequestScoped}. | |
10 | 10 | * |
11 | 11 | * @author serpro |
12 | - * | |
13 | 12 | */ |
14 | 13 | public class ManagedContext extends ThreadLocalContext { |
15 | - | |
14 | + | |
16 | 15 | /** |
17 | 16 | * Constructs a new context. |
18 | 17 | */ | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/ThreadLocalContext.java
... | ... | @@ -51,10 +51,9 @@ package br.gov.frameworkdemoiselle.internal.context; |
51 | 51 | import java.lang.annotation.Annotation; |
52 | 52 | |
53 | 53 | /** |
54 | - * Base context that has a separated store for each thread | |
54 | + * Base context that has a separated store for each thread | |
55 | 55 | * |
56 | 56 | * @author serpro |
57 | - * | |
58 | 57 | */ |
59 | 58 | public class ThreadLocalContext extends AbstractCustomContext { |
60 | 59 | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/TransactionContextImpl.java
... | ... | @@ -55,7 +55,8 @@ public class TransactionContextImpl implements TransactionContext { |
55 | 55 | |
56 | 56 | private Transaction transaction; |
57 | 57 | |
58 | - private Transaction getTransaction() { | |
58 | + @Override | |
59 | + public Transaction getCurrentTransaction() { | |
59 | 60 | if (this.transaction == null) { |
60 | 61 | Class<? extends Transaction> clazz = getConfig().getTransactionClass(); |
61 | 62 | |
... | ... | @@ -69,11 +70,6 @@ public class TransactionContextImpl implements TransactionContext { |
69 | 70 | return this.transaction; |
70 | 71 | } |
71 | 72 | |
72 | - @Override | |
73 | - public Transaction getCurrentTransaction() { | |
74 | - return getTransaction(); | |
75 | - } | |
76 | - | |
77 | 73 | private TransactionConfig getConfig() { |
78 | 74 | return Beans.getReference(TransactionConfig.class); |
79 | 75 | } | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/interceptor/ExceptionHandlerInterceptor.java
... | ... | @@ -57,7 +57,7 @@ public class ExceptionHandlerInterceptor extends br.gov.frameworkdemoiselle.exce |
57 | 57 | |
58 | 58 | @Inject |
59 | 59 | private Logger logger; |
60 | - | |
60 | + | |
61 | 61 | @Override |
62 | 62 | @AroundInvoke |
63 | 63 | public Object manage(InvocationContext ic) throws Exception { |
... | ... | @@ -65,4 +65,3 @@ public class ExceptionHandlerInterceptor extends br.gov.frameworkdemoiselle.exce |
65 | 65 | return super.manage(ic); |
66 | 66 | } |
67 | 67 | } |
68 | - | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/proxy/Slf4jLoggerProxy.java
... | ... | @@ -61,12 +61,12 @@ public class Slf4jLoggerProxy implements Logger, Serializable { |
61 | 61 | private transient Logger delegate; |
62 | 62 | |
63 | 63 | private final Class<?> type; |
64 | - | |
64 | + | |
65 | 65 | private Logger getDelegate() { |
66 | - if(delegate == null) { | |
66 | + if (delegate == null) { | |
67 | 67 | delegate = LoggerFactory.getLogger(type); |
68 | 68 | } |
69 | - | |
69 | + | |
70 | 70 | return delegate; |
71 | 71 | } |
72 | 72 | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/lifecycle/ManagementExtension.java
... | ... | @@ -42,34 +42,36 @@ import br.gov.frameworkdemoiselle.internal.management.ManagedType; |
42 | 42 | import br.gov.frameworkdemoiselle.stereotype.ManagementController; |
43 | 43 | |
44 | 44 | /** |
45 | - * | |
46 | - * <p>Interface defining the lifecycle of a <b>management extension</b>, an extension | |
47 | - * capable of exposing {@link ManagementController}'s to external clients in one | |
48 | - * of the available management technologies, such as JMX or SNMP.</p> | |
49 | - * | |
50 | - * <p>To include a management extension into the management lifecycle, it just needs | |
51 | - * to implement this interface and be a CDI bean (have a <b>beans.xml</b> file inside | |
52 | - * the META-INF folder of it's java package). The Demoiselle Core lifecycle controller | |
53 | - * will call the {@link #initialize(List managedTypes)} and {@link #shutdown(List managedTypes)} methods at the apropriate times.</p> | |
45 | + * <p> | |
46 | + * Interface defining the lifecycle of a <b>management extension</b>, an extension capable of exposing | |
47 | + * {@link ManagementController}'s to external clients in one of the available management technologies, such as JMX or | |
48 | + * SNMP. | |
49 | + * </p> | |
50 | + * <p> | |
51 | + * To include a management extension into the management lifecycle, it just needs to implement this interface and be a | |
52 | + * CDI bean (have a <b>beans.xml</b> file inside the META-INF folder of it's java package). The Demoiselle Core | |
53 | + * lifecycle controller will call the {@link #initialize(List managedTypes)} and {@link #shutdown(List managedTypes)} | |
54 | + * methods at the apropriate times. | |
55 | + * </p> | |
54 | 56 | * |
55 | 57 | * @author serpro |
56 | - * | |
57 | 58 | */ |
58 | 59 | public interface ManagementExtension { |
59 | 60 | |
60 | 61 | /** |
61 | - * This method is called during the application initialization process for each concrete | |
62 | - * implementation of this interface. | |
62 | + * This method is called during the application initialization process for each concrete implementation of this | |
63 | + * interface. | |
63 | 64 | * |
64 | - * @param managedTypes The list of discovered {@link ManagementController} classes. | |
65 | + * @param managedTypes | |
66 | + * The list of discovered {@link ManagementController} classes. | |
65 | 67 | */ |
66 | 68 | void initialize(List<ManagedType> managedTypes); |
67 | 69 | |
68 | 70 | /** |
69 | - * This method is called during the application shutdown process for each concrete | |
70 | - * implementation of this interface. | |
71 | + * This method is called during the application shutdown process for each concrete implementation of this interface. | |
71 | 72 | * |
72 | - * @param managedTypes The list of discovered {@link ManagementController} classes. | |
73 | + * @param managedTypes | |
74 | + * The list of discovered {@link ManagementController} classes. | |
73 | 75 | */ |
74 | 76 | void shutdown(List<ManagedType> managedTypes); |
75 | 77 | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/lifecycle/Shutdown.java
... | ... | @@ -48,17 +48,20 @@ import java.lang.annotation.Target; |
48 | 48 | * Take a look at the following usage sample: |
49 | 49 | * <p> |
50 | 50 | * <blockquote> |
51 | + * | |
51 | 52 | * <pre> |
52 | 53 | * public class Finalizer { |
53 | 54 | * |
54 | - * @Shutdown | |
55 | + * @Shutdown | |
55 | 56 | * @Priority(5) |
56 | 57 | * public void finalize() { |
57 | 58 | * ... |
58 | 59 | * } |
59 | 60 | * } |
60 | 61 | * |
62 | + * | |
61 | 63 | * </pre> |
64 | + * | |
62 | 65 | * </blockquote> |
63 | 66 | * <p> |
64 | 67 | * | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/lifecycle/Startup.java
... | ... | @@ -48,17 +48,20 @@ import java.lang.annotation.Target; |
48 | 48 | * Take a look at the following usage sample: |
49 | 49 | * <p> |
50 | 50 | * <blockquote> |
51 | + * | |
51 | 52 | * <pre> |
52 | 53 | * public class Finalizer { |
53 | 54 | * |
54 | - * @Startup | |
55 | + * @Startup | |
55 | 56 | * @Priority(1) |
56 | 57 | * public void init() { |
57 | 58 | * ... |
58 | 59 | * } |
59 | 60 | * } |
60 | 61 | * |
62 | + * | |
61 | 63 | * </pre> |
64 | + * | |
62 | 65 | * </blockquote> |
63 | 66 | * <p> |
64 | 67 | * | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/pagination/Pagination.java
impl/core/src/main/java/br/gov/frameworkdemoiselle/pagination/PaginationContext.java
... | ... | @@ -51,7 +51,8 @@ public interface PaginationContext { |
51 | 51 | /** |
52 | 52 | * Retrieves the pagination according to the class type specified. |
53 | 53 | * |
54 | - * @param clazz a {@code Class} type | |
54 | + * @param clazz | |
55 | + * a {@code Class} type | |
55 | 56 | * @return Pagination |
56 | 57 | */ |
57 | 58 | Pagination getPagination(Class<?> clazz); |
... | ... | @@ -60,8 +61,10 @@ public interface PaginationContext { |
60 | 61 | * Retrieves the pagination according to the class type specified. If not existing, creates the pagination whenever |
61 | 62 | * {@code create} parameter is true. |
62 | 63 | * |
63 | - * @param clazz a {@code Class} type | |
64 | - * @param create determines whether pagination must always be returned | |
64 | + * @param clazz | |
65 | + * a {@code Class} type | |
66 | + * @param create | |
67 | + * determines whether pagination must always be returned | |
65 | 68 | * @return Pagination |
66 | 69 | */ |
67 | 70 | Pagination getPagination(Class<?> clazz, boolean create); | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/security/Authenticator.java
... | ... | @@ -49,7 +49,8 @@ public interface Authenticator extends Serializable { |
49 | 49 | /** |
50 | 50 | * Executes the necessary steps to authenticate an user. |
51 | 51 | * |
52 | - * @throws AuthenticationException When the authentication process fails, this exception is thrown. | |
52 | + * @throws AuthenticationException | |
53 | + * When the authentication process fails, this exception is thrown. | |
53 | 54 | */ |
54 | 55 | void authenticate() throws AuthenticationException; |
55 | 56 | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/security/RequiredPermissionInterceptor.java
... | ... | @@ -46,9 +46,8 @@ import javax.interceptor.InvocationContext; |
46 | 46 | import org.slf4j.Logger; |
47 | 47 | |
48 | 48 | import br.gov.frameworkdemoiselle.annotation.Name; |
49 | -import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; | |
50 | -import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | |
51 | 49 | import br.gov.frameworkdemoiselle.util.Beans; |
50 | +import br.gov.frameworkdemoiselle.util.NameQualifier; | |
52 | 51 | import br.gov.frameworkdemoiselle.util.ResourceBundle; |
53 | 52 | import br.gov.frameworkdemoiselle.util.Strings; |
54 | 53 | |
... | ... | @@ -63,9 +62,9 @@ public class RequiredPermissionInterceptor implements Serializable { |
63 | 62 | |
64 | 63 | private static final long serialVersionUID = 1L; |
65 | 64 | |
66 | - private static ResourceBundle bundle; | |
65 | + private static transient ResourceBundle bundle; | |
67 | 66 | |
68 | - private static Logger logger; | |
67 | + private static transient Logger logger; | |
69 | 68 | |
70 | 69 | /** |
71 | 70 | * Gets the values for both resource and operation properties of {@code @RequiredPermission}. Delegates to |
... | ... | @@ -168,7 +167,7 @@ public class RequiredPermissionInterceptor implements Serializable { |
168 | 167 | |
169 | 168 | private static ResourceBundle getBundle() { |
170 | 169 | if (bundle == null) { |
171 | - bundle = ResourceBundleProducer.create("demoiselle-core-bundle"); | |
170 | + bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle")); | |
172 | 171 | } |
173 | 172 | |
174 | 173 | return bundle; |
... | ... | @@ -176,7 +175,7 @@ public class RequiredPermissionInterceptor implements Serializable { |
176 | 175 | |
177 | 176 | private static Logger getLogger() { |
178 | 177 | if (logger == null) { |
179 | - logger = LoggerProducer.create(RequiredPermissionInterceptor.class); | |
178 | + logger = Beans.getReference(Logger.class, new NameQualifier(RequiredPermissionInterceptor.class.getName())); | |
180 | 179 | } |
181 | 180 | |
182 | 181 | return logger; | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/security/RequiredRoleInterceptor.java
... | ... | @@ -47,9 +47,8 @@ import javax.interceptor.InvocationContext; |
47 | 47 | |
48 | 48 | import org.slf4j.Logger; |
49 | 49 | |
50 | -import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; | |
51 | -import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | |
52 | 50 | import br.gov.frameworkdemoiselle.util.Beans; |
51 | +import br.gov.frameworkdemoiselle.util.NameQualifier; | |
53 | 52 | import br.gov.frameworkdemoiselle.util.ResourceBundle; |
54 | 53 | |
55 | 54 | /** |
... | ... | @@ -63,9 +62,9 @@ public class RequiredRoleInterceptor implements Serializable { |
63 | 62 | |
64 | 63 | private static final long serialVersionUID = 1L; |
65 | 64 | |
66 | - private static ResourceBundle bundle; | |
65 | + private static transient ResourceBundle bundle; | |
67 | 66 | |
68 | - private static Logger logger; | |
67 | + private static transient Logger logger; | |
69 | 68 | |
70 | 69 | /** |
71 | 70 | * Gets the value property of {@code @RequiredRole}. Delegates to {@code SecurityContext} check role. If the user |
... | ... | @@ -102,7 +101,6 @@ public class RequiredRoleInterceptor implements Serializable { |
102 | 101 | .error(getBundle().getString("does-not-have-role", getSecurityContext().getCurrentUser().getName(), |
103 | 102 | roles)); |
104 | 103 | |
105 | - // AuthorizationException a = new AuthorizationException(null); | |
106 | 104 | throw new AuthorizationException(getBundle().getString("does-not-have-role-ui", roles)); |
107 | 105 | } |
108 | 106 | |
... | ... | @@ -139,7 +137,7 @@ public class RequiredRoleInterceptor implements Serializable { |
139 | 137 | |
140 | 138 | private static ResourceBundle getBundle() { |
141 | 139 | if (bundle == null) { |
142 | - bundle = ResourceBundleProducer.create("demoiselle-core-bundle"); | |
140 | + bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle")); | |
143 | 141 | } |
144 | 142 | |
145 | 143 | return bundle; |
... | ... | @@ -147,7 +145,7 @@ public class RequiredRoleInterceptor implements Serializable { |
147 | 145 | |
148 | 146 | private static Logger getLogger() { |
149 | 147 | if (logger == null) { |
150 | - logger = LoggerProducer.create(RequiredRoleInterceptor.class); | |
148 | + logger = Beans.getReference(Logger.class, new NameQualifier(RequiredRoleInterceptor.class.getName())); | |
151 | 149 | } |
152 | 150 | |
153 | 151 | return logger; | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/security/User.java
impl/core/src/main/java/br/gov/frameworkdemoiselle/stereotype/ManagementController.java
... | ... | @@ -49,17 +49,23 @@ import javax.enterprise.inject.Stereotype; |
49 | 49 | import javax.enterprise.util.Nonbinding; |
50 | 50 | |
51 | 51 | /** |
52 | - * <p>Identifies a <b>management controller</b> bean. What it means is that an external client can manage the application | |
53 | - * this class is in by reading or writing it's attributes and calling it's operations.</p> | |
54 | 52 | * <p> |
55 | - * Only fields annotated with {@link br.gov.frameworkdemoiselle.annotation.ManagedProperty} or | |
56 | - * methods annotated with {@link br.gov.frameworkdemoiselle.annotation.ManagedOperation} will be exposed | |
57 | - * to clients.</p> | |
58 | - * <p>Only bean implementations (concrete classes) can be management controllers. It's a runtime error to mark an interface | |
59 | - * or abstract class with this annotation.</p> | |
60 | - * <p>This stereotype only defines a class as managed, you need to choose an extension that will expose this managed class | |
53 | + * Identifies a <b>management controller</b> bean. What it means is that an external client can manage the application | |
54 | + * this class is in by reading or writing it's attributes and calling it's operations. | |
55 | + * </p> | |
56 | + * <p> | |
57 | + * Only fields annotated with {@link br.gov.frameworkdemoiselle.annotation.ManagedProperty} or methods annotated with | |
58 | + * {@link br.gov.frameworkdemoiselle.annotation.ManagedOperation} will be exposed to clients. | |
59 | + * </p> | |
60 | + * <p> | |
61 | + * Only bean implementations (concrete classes) can be management controllers. It's a runtime error to mark an interface | |
62 | + * or abstract class with this annotation. | |
63 | + * </p> | |
64 | + * <p> | |
65 | + * This stereotype only defines a class as managed, you need to choose an extension that will expose this managed class | |
61 | 66 | * to external clients using any technology available. One example is the Demoiselle JMX extension, that will expose |
62 | - * managed classes as MBeans.</p> | |
67 | + * managed classes as MBeans. | |
68 | + * </p> | |
63 | 69 | * |
64 | 70 | * @author SERPRO |
65 | 71 | */ |
... | ... | @@ -71,7 +77,7 @@ import javax.enterprise.util.Nonbinding; |
71 | 77 | @Retention(RUNTIME) |
72 | 78 | @Target({ TYPE }) |
73 | 79 | public @interface ManagementController { |
74 | - | |
80 | + | |
75 | 81 | /** |
76 | 82 | * @return Human readable description of this managed class. |
77 | 83 | */ | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/template/Crud.java
... | ... | @@ -43,16 +43,18 @@ import java.util.List; |
43 | 43 | * Interface containing basic methods for creating, updating and deleting entities (the CRUD design pattern). |
44 | 44 | * |
45 | 45 | * @author serpro |
46 | - * | |
47 | - * @param <T> Type of the entity | |
48 | - * @param <I> Type of the identification attribute of the entity | |
46 | + * @param <T> | |
47 | + * Type of the entity | |
48 | + * @param <I> | |
49 | + * Type of the identification attribute of the entity | |
49 | 50 | */ |
50 | 51 | public interface Crud<T, I> extends Serializable { |
51 | 52 | |
52 | 53 | /** |
53 | 54 | * Find an entity by it's identification attribute and make it transient. |
54 | 55 | * |
55 | - * @param id The unique identification to find the entity to be deleted. | |
56 | + * @param id | |
57 | + * The unique identification to find the entity to be deleted. | |
56 | 58 | */ |
57 | 59 | void delete(I id); |
58 | 60 | |
... | ... | @@ -66,24 +68,27 @@ public interface Crud<T, I> extends Serializable { |
66 | 68 | /** |
67 | 69 | * Insert an entity and return the inserted instance of the entity |
68 | 70 | * |
69 | - * @param bean The bean to be inserted | |
71 | + * @param bean | |
72 | + * The bean to be inserted | |
70 | 73 | * @return The inserted instance of the entity |
71 | 74 | */ |
72 | 75 | T insert(T bean); |
73 | 76 | |
74 | 77 | /** |
75 | 78 | * Find an entity's instance by it's identification attribute and return it |
76 | - * @param id Value of the identification attribute of the desired entity's instance | |
77 | - * @return The entity's instance whose identification attribute's value matches | |
78 | - * the one passed as argument. | |
79 | + * | |
80 | + * @param id | |
81 | + * Value of the identification attribute of the desired entity's instance | |
82 | + * @return The entity's instance whose identification attribute's value matches the one passed as argument. | |
79 | 83 | */ |
80 | 84 | T load(I id); |
81 | 85 | |
82 | 86 | /** |
83 | - * Update an instance of the entity with the bean's attributes as new values. | |
87 | + * Update an instance of the entity with the bean's attributes as new values. | |
84 | 88 | * |
85 | - * @param bean The bean instance containing both the identification value to find the old | |
86 | - * instance and the new values for the instance's attributes. | |
89 | + * @param bean | |
90 | + * The bean instance containing both the identification value to find the old instance and the new values | |
91 | + * for the instance's attributes. | |
87 | 92 | * @return The updated entity's instance |
88 | 93 | */ |
89 | 94 | T update(T bean); | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/template/DelegateCrud.java
... | ... | @@ -39,20 +39,15 @@ package br.gov.frameworkdemoiselle.template; |
39 | 39 | import java.util.List; |
40 | 40 | import java.util.ListIterator; |
41 | 41 | |
42 | -import br.gov.frameworkdemoiselle.internal.implementation.DefaultTransaction; | |
43 | -import br.gov.frameworkdemoiselle.transaction.Transaction; | |
44 | -import br.gov.frameworkdemoiselle.transaction.TransactionContext; | |
45 | -import br.gov.frameworkdemoiselle.transaction.Transactional; | |
46 | 42 | import br.gov.frameworkdemoiselle.util.Beans; |
47 | 43 | import br.gov.frameworkdemoiselle.util.Reflections; |
48 | 44 | |
49 | 45 | /** |
50 | - * An implementation of the {@link Crud} interface that delegates it's operations | |
51 | - * to another {@link Crud} implementation. | |
46 | + * An implementation of the {@link Crud} interface that delegates it's operations to another {@link Crud} | |
47 | + * implementation. | |
52 | 48 | * |
53 | 49 | * @author serpro |
54 | - * | |
55 | - * @param <T> | |
50 | + * @param <T> | |
56 | 51 | * bean object type |
57 | 52 | * @param <I> |
58 | 53 | * bean id type |
... | ... | @@ -75,19 +70,6 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { |
75 | 70 | */ |
76 | 71 | @Override |
77 | 72 | public void delete(final I id) { |
78 | - if (isRunningTransactionalOperations()) { | |
79 | - transactionalDelete(id); | |
80 | - } else { | |
81 | - nonTransactionalDelete(id); | |
82 | - } | |
83 | - } | |
84 | - | |
85 | - @Transactional | |
86 | - private void transactionalDelete(final I id) { | |
87 | - nonTransactionalDelete(id); | |
88 | - } | |
89 | - | |
90 | - private void nonTransactionalDelete(final I id) { | |
91 | 73 | getDelegate().delete(id); |
92 | 74 | } |
93 | 75 | |
... | ... | @@ -98,20 +80,8 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { |
98 | 80 | * List of entities identifiers |
99 | 81 | */ |
100 | 82 | public void delete(final List<I> ids) { |
101 | - if (isRunningTransactionalOperations()) { | |
102 | - transactionalDelete(ids); | |
103 | - } else { | |
104 | - nonTransactionalDelete(ids); | |
105 | - } | |
106 | - } | |
107 | - | |
108 | - @Transactional | |
109 | - private void transactionalDelete(final List<I> ids) { | |
110 | - nonTransactionalDelete(ids); | |
111 | - } | |
112 | - | |
113 | - private void nonTransactionalDelete(final List<I> ids) { | |
114 | 83 | ListIterator<I> iter = ids.listIterator(); |
84 | + | |
115 | 85 | while (iter.hasNext()) { |
116 | 86 | this.delete(iter.next()); |
117 | 87 | } |
... | ... | @@ -151,19 +121,6 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { |
151 | 121 | */ |
152 | 122 | @Override |
153 | 123 | public T insert(final T bean) { |
154 | - if (isRunningTransactionalOperations()) { | |
155 | - return transactionalInsert(bean); | |
156 | - } else { | |
157 | - return nonTransactionalInsert(bean); | |
158 | - } | |
159 | - } | |
160 | - | |
161 | - @Transactional | |
162 | - private T transactionalInsert(final T bean) { | |
163 | - return nonTransactionalInsert(bean); | |
164 | - } | |
165 | - | |
166 | - private T nonTransactionalInsert(final T bean) { | |
167 | 124 | return getDelegate().insert(bean); |
168 | 125 | } |
169 | 126 | |
... | ... | @@ -185,24 +142,6 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { |
185 | 142 | */ |
186 | 143 | @Override |
187 | 144 | public T update(final T bean) { |
188 | - if (isRunningTransactionalOperations()) { | |
189 | - return transactionalUpdate(bean); | |
190 | - } else { | |
191 | - return nonTransactionalUpdate(bean); | |
192 | - } | |
193 | - } | |
194 | - | |
195 | - @Transactional | |
196 | - private T transactionalUpdate(final T bean) { | |
197 | - return nonTransactionalUpdate(bean); | |
198 | - } | |
199 | - | |
200 | - private T nonTransactionalUpdate(final T bean) { | |
201 | 145 | return getDelegate().update(bean); |
202 | 146 | } |
203 | - | |
204 | - private boolean isRunningTransactionalOperations() { | |
205 | - Transaction transaction = Beans.getReference(TransactionContext.class).getCurrentTransaction(); | |
206 | - return !(transaction instanceof DefaultTransaction); | |
207 | - } | |
208 | 147 | } | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/transaction/TransactionalInterceptor.java
... | ... | @@ -48,9 +48,8 @@ import javax.interceptor.InvocationContext; |
48 | 48 | import org.slf4j.Logger; |
49 | 49 | |
50 | 50 | import br.gov.frameworkdemoiselle.exception.ApplicationException; |
51 | -import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; | |
52 | -import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | |
53 | 51 | import br.gov.frameworkdemoiselle.util.Beans; |
52 | +import br.gov.frameworkdemoiselle.util.NameQualifier; | |
54 | 53 | import br.gov.frameworkdemoiselle.util.ResourceBundle; |
55 | 54 | |
56 | 55 | @Interceptor |
... | ... | @@ -63,9 +62,9 @@ public class TransactionalInterceptor implements Serializable { |
63 | 62 | |
64 | 63 | private TransactionInfo transactionInfo; |
65 | 64 | |
66 | - private static ResourceBundle bundle; | |
65 | + private static transient ResourceBundle bundle; | |
67 | 66 | |
68 | - private static Logger logger; | |
67 | + private static transient Logger logger; | |
69 | 68 | |
70 | 69 | private TransactionContext getTransactionContext() { |
71 | 70 | if (this.transactionContext == null) { |
... | ... | @@ -175,7 +174,7 @@ public class TransactionalInterceptor implements Serializable { |
175 | 174 | |
176 | 175 | private static ResourceBundle getBundle() { |
177 | 176 | if (bundle == null) { |
178 | - bundle = ResourceBundleProducer.create("demoiselle-core-bundle"); | |
177 | + bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle")); | |
179 | 178 | } |
180 | 179 | |
181 | 180 | return bundle; |
... | ... | @@ -183,7 +182,7 @@ public class TransactionalInterceptor implements Serializable { |
183 | 182 | |
184 | 183 | private static Logger getLogger() { |
185 | 184 | if (logger == null) { |
186 | - logger = LoggerProducer.create(TransactionalInterceptor.class); | |
185 | + logger = Beans.getReference(Logger.class, new NameQualifier(TransactionalInterceptor.class.getName())); | |
187 | 186 | } |
188 | 187 | |
189 | 188 | return logger; | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/util/Beans.java
... | ... | @@ -37,22 +37,25 @@ |
37 | 37 | package br.gov.frameworkdemoiselle.util; |
38 | 38 | |
39 | 39 | import java.lang.annotation.Annotation; |
40 | +import java.lang.reflect.Member; | |
40 | 41 | import java.lang.reflect.Type; |
41 | -import java.util.Locale; | |
42 | +import java.util.Arrays; | |
43 | +import java.util.HashSet; | |
42 | 44 | import java.util.NoSuchElementException; |
43 | 45 | import java.util.Set; |
44 | 46 | |
45 | 47 | import javax.enterprise.context.spi.CreationalContext; |
48 | +import javax.enterprise.inject.spi.Annotated; | |
46 | 49 | import javax.enterprise.inject.spi.Bean; |
47 | 50 | import javax.enterprise.inject.spi.BeanManager; |
48 | 51 | import javax.enterprise.inject.spi.InjectionPoint; |
49 | 52 | |
50 | 53 | import br.gov.frameworkdemoiselle.DemoiselleException; |
51 | -import br.gov.frameworkdemoiselle.internal.bootstrap.CustomInjectionPoint; | |
52 | -import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | |
53 | 54 | |
54 | 55 | public final class Beans { |
55 | 56 | |
57 | + private static transient ResourceBundle bundle; | |
58 | + | |
56 | 59 | private static BeanManager manager; |
57 | 60 | |
58 | 61 | private Beans() { |
... | ... | @@ -132,6 +135,98 @@ public final class Beans { |
132 | 135 | } |
133 | 136 | |
134 | 137 | private static ResourceBundle getBundle() { |
135 | - return ResourceBundleProducer.create("demoiselle-core-bundle", Locale.getDefault()); | |
138 | + if (bundle == null) { | |
139 | + bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle")); | |
140 | + } | |
141 | + | |
142 | + return bundle; | |
143 | + } | |
144 | + | |
145 | + static class CustomInjectionPoint implements InjectionPoint { | |
146 | + | |
147 | + private final Bean<?> bean; | |
148 | + | |
149 | + private final Type beanType; | |
150 | + | |
151 | + private final Set<Annotation> qualifiers; | |
152 | + | |
153 | + public CustomInjectionPoint(Bean<?> bean, Type beanType, Annotation... qualifiers) { | |
154 | + this.bean = bean; | |
155 | + this.beanType = beanType; | |
156 | + this.qualifiers = new HashSet<Annotation>(Arrays.asList(qualifiers)); | |
157 | + } | |
158 | + | |
159 | + @Override | |
160 | + public Type getType() { | |
161 | + return this.beanType; | |
162 | + } | |
163 | + | |
164 | + @Override | |
165 | + public Set<Annotation> getQualifiers() { | |
166 | + return this.qualifiers; | |
167 | + } | |
168 | + | |
169 | + @Override | |
170 | + public Bean<?> getBean() { | |
171 | + return this.bean; | |
172 | + } | |
173 | + | |
174 | + @Override | |
175 | + public Member getMember() { | |
176 | + return null; | |
177 | + } | |
178 | + | |
179 | + @Override | |
180 | + public boolean isDelegate() { | |
181 | + return false; | |
182 | + } | |
183 | + | |
184 | + @Override | |
185 | + public boolean isTransient() { | |
186 | + return false; | |
187 | + } | |
188 | + | |
189 | + @Override | |
190 | + public Annotated getAnnotated() { | |
191 | + return new Annotated() { | |
192 | + | |
193 | + @Override | |
194 | + public Type getBaseType() { | |
195 | + // TODO Auto-generated method stub | |
196 | + return null; | |
197 | + } | |
198 | + | |
199 | + @Override | |
200 | + public Set<Type> getTypeClosure() { | |
201 | + // TODO Auto-generated method stub | |
202 | + return null; | |
203 | + } | |
204 | + | |
205 | + @Override | |
206 | + @SuppressWarnings("unchecked") | |
207 | + public <T extends Annotation> T getAnnotation(Class<T> annotationType) { | |
208 | + T result = null; | |
209 | + | |
210 | + for (Annotation annotation : getAnnotations()) { | |
211 | + if (annotation.annotationType() == annotationType) { | |
212 | + result = (T) annotation; | |
213 | + break; | |
214 | + } | |
215 | + } | |
216 | + | |
217 | + return result; | |
218 | + } | |
219 | + | |
220 | + @Override | |
221 | + public Set<Annotation> getAnnotations() { | |
222 | + return qualifiers; | |
223 | + } | |
224 | + | |
225 | + @Override | |
226 | + public boolean isAnnotationPresent(Class<? extends Annotation> annotationType) { | |
227 | + return qualifiers.contains(annotationType); | |
228 | + } | |
229 | + }; | |
230 | + } | |
136 | 231 | } |
137 | 232 | } | ... | ... |
impl/core/src/test/java/configuration/field/beanvalidation/BeanValidationWithEmptyNotNullFieldConfig.java
... | ... | @@ -42,14 +42,14 @@ public abstract class BeanValidationWithEmptyNotNullFieldConfig { |
42 | 42 | |
43 | 43 | @NotNull |
44 | 44 | private Integer intAttributeNull; |
45 | - | |
45 | + | |
46 | 46 | @NotNull |
47 | 47 | private String stringAttributeNull; |
48 | - | |
48 | + | |
49 | 49 | public Integer getIntAttributeNull() { |
50 | 50 | return intAttributeNull; |
51 | 51 | } |
52 | - | |
52 | + | |
53 | 53 | public String getStringAttributeNull() { |
54 | 54 | return stringAttributeNull; |
55 | 55 | } | ... | ... |
impl/core/src/test/java/configuration/field/beanvalidation/BeanValidationWithFilledNotNullFieldConfig.java
... | ... | @@ -6,14 +6,14 @@ public class BeanValidationWithFilledNotNullFieldConfig { |
6 | 6 | |
7 | 7 | @NotNull |
8 | 8 | private String stringAttributeNotNull; |
9 | - | |
9 | + | |
10 | 10 | @NotNull |
11 | 11 | private Integer intAttibuteNotNull; |
12 | - | |
12 | + | |
13 | 13 | public String getStringAttributeNotNull() { |
14 | 14 | return stringAttributeNotNull; |
15 | 15 | } |
16 | - | |
16 | + | |
17 | 17 | public Integer getIntAttibuteNotNull() { |
18 | 18 | return intAttibuteNotNull; |
19 | 19 | } | ... | ... |
impl/core/src/test/java/configuration/field/beanvalidation/ConfigurationBeanValidationFieldTest.java
... | ... | @@ -80,7 +80,8 @@ public class ConfigurationBeanValidationFieldTest { |
80 | 80 | JavaArchive deployment = Tests.createDeployment(ConfigurationBeanValidationFieldTest.class); |
81 | 81 | deployment.addAsResource(Tests.createFileAsset(PATH + "/demoiselle.properties"), "demoiselle.properties"); |
82 | 82 | deployment.addAsResource(Tests.createFileAsset(PATH + "/demoiselle.xml"), "demoiselle.xml"); |
83 | - deployment.addAsResource(Tests.createFileAsset(PATH + "/two-constrain-validation.properties"), "two-constrain-validation.properties"); | |
83 | + deployment.addAsResource(Tests.createFileAsset(PATH + "/two-constrain-validation.properties"), | |
84 | + "two-constrain-validation.properties"); | |
84 | 85 | |
85 | 86 | return deployment; |
86 | 87 | } |
... | ... | @@ -136,7 +137,7 @@ public class ConfigurationBeanValidationFieldTest { |
136 | 137 | } |
137 | 138 | |
138 | 139 | @Test |
139 | - public void loadPropertiesWithTwoConstraintViolations(){ | |
140 | + public void loadPropertiesWithTwoConstraintViolations() { | |
140 | 141 | try { |
141 | 142 | propertyWithTwoConstrainViolations.getAttributeWithTwoConstrainValidations(); |
142 | 143 | fail(); | ... | ... |
impl/core/src/test/java/configuration/field/clazz/AbstractClassNotFoundFieldConfig.java
... | ... | @@ -41,7 +41,7 @@ public abstract class AbstractClassNotFoundFieldConfig { |
41 | 41 | private Class<MyClass> nonExistentTypedClass; |
42 | 42 | |
43 | 43 | private Class<?> nonExistentUntypedClass; |
44 | - | |
44 | + | |
45 | 45 | public Class<MyClass> getNonExistentTypedClass() { |
46 | 46 | return nonExistentTypedClass; |
47 | 47 | } | ... | ... |
impl/core/src/test/java/configuration/field/clazz/PropertiesNullClassFieldConfig.java
... | ... | @@ -40,9 +40,9 @@ import br.gov.frameworkdemoiselle.configuration.Configuration; |
40 | 40 | |
41 | 41 | @Configuration |
42 | 42 | public class PropertiesNullClassFieldConfig { |
43 | - | |
43 | + | |
44 | 44 | private Class<MyClass> nullClass; |
45 | - | |
45 | + | |
46 | 46 | public Class<MyClass> getNullClass() { |
47 | 47 | return nullClass; |
48 | 48 | } | ... | ... |
impl/core/src/test/java/configuration/field/map/AbstractMapFieldConfig.java
... | ... | @@ -45,7 +45,7 @@ public abstract class AbstractMapFieldConfig { |
45 | 45 | private Map<String, String> stringWithUndefinedKeyMap; |
46 | 46 | |
47 | 47 | private Map<String, String> emptyValueMap; |
48 | - | |
48 | + | |
49 | 49 | private Map<String, String> NullMapValue; |
50 | 50 | |
51 | 51 | public Map<String, String> getStringWithUndefinedKeyMap() { | ... | ... |
impl/core/src/test/java/configuration/field/map/ConfigurationMapFieldTest.java
... | ... | @@ -99,9 +99,9 @@ public class ConfigurationMapFieldTest { |
99 | 99 | assertEquals(expected, propertiesConfig.getEmptyValueMap()); |
100 | 100 | assertEquals(expected, xmlConfig.getEmptyValueMap()); |
101 | 101 | } |
102 | - | |
102 | + | |
103 | 103 | @Test |
104 | - public void loadNullMap(){ | |
104 | + public void loadNullMap() { | |
105 | 105 | assertNull(propertiesConfig.getNullMapValue()); |
106 | 106 | assertNull(xmlConfig.getNullMapValue()); |
107 | 107 | } | ... | ... |
impl/core/src/test/java/configuration/field/primitiveorwrapper/AbstractPrimitiveOrWrapperErrorFieldConfig.java
impl/core/src/test/java/configuration/field/primitiveorwrapper/ConfigurationPrimitiveOrWrapperFieldTest.java
... | ... | @@ -78,7 +78,7 @@ public class ConfigurationPrimitiveOrWrapperFieldTest { |
78 | 78 | |
79 | 79 | @Inject |
80 | 80 | private PropertiesNullWrappedField nullWrappedField; |
81 | - | |
81 | + | |
82 | 82 | @Deployment |
83 | 83 | public static JavaArchive createDeployment() { |
84 | 84 | JavaArchive deployment = Tests.createDeployment(ConfigurationPrimitiveOrWrapperFieldTest.class); |
... | ... | @@ -210,9 +210,9 @@ public class ConfigurationPrimitiveOrWrapperFieldTest { |
210 | 210 | assertEquals(ConversionException.class, cause.getCause().getClass()); |
211 | 211 | } |
212 | 212 | } |
213 | - | |
213 | + | |
214 | 214 | @Test |
215 | - public void loadNullWrappedField(){ | |
215 | + public void loadNullWrappedField() { | |
216 | 216 | assertNull(nullWrappedField.getNullWrappedField()); |
217 | 217 | } |
218 | 218 | } | ... | ... |
impl/core/src/test/java/configuration/field/primitiveorwrapper/PropertiesNullWrappedField.java
impl/core/src/test/java/configuration/field/string/AbstractNullStringFieldConfig.java
impl/core/src/test/java/configuration/field/string/ConfigurationStringFieldTest.java
... | ... | @@ -63,7 +63,7 @@ public class ConfigurationStringFieldTest { |
63 | 63 | |
64 | 64 | @Inject |
65 | 65 | private SystemStringFieldConfig systemConfig; |
66 | - | |
66 | + | |
67 | 67 | @Inject |
68 | 68 | private PropertiesNullStringFieldConfig propertiesNullConfig; |
69 | 69 | |
... | ... | @@ -113,9 +113,9 @@ public class ConfigurationStringFieldTest { |
113 | 113 | assertEquals(expected, propertiesConfig.getEmptyString()); |
114 | 114 | assertEquals(expected, xmlConfig.getEmptyString()); |
115 | 115 | } |
116 | - | |
116 | + | |
117 | 117 | @Test |
118 | - public void loadNullString(){ | |
118 | + public void loadNullString() { | |
119 | 119 | assertNull(propertiesNullConfig.getNullString()); |
120 | 120 | assertNull(xmlNullConfig.getNullString()); |
121 | 121 | assertNull(systemNullConfig.getNullString()); | ... | ... |
impl/core/src/test/java/exception/basic/ExceptionClassNotAnnotated.java
... | ... | @@ -41,7 +41,7 @@ import br.gov.frameworkdemoiselle.exception.ExceptionHandler; |
41 | 41 | public class ExceptionClassNotAnnotated { |
42 | 42 | |
43 | 43 | private boolean nullPointerExceptionHandler = false; |
44 | - | |
44 | + | |
45 | 45 | public boolean isNullPointerExceptionHandler() { |
46 | 46 | return nullPointerExceptionHandler; |
47 | 47 | } | ... | ... |
impl/core/src/test/java/exception/basic/ExceptionHandlerTest.java
... | ... | @@ -64,7 +64,7 @@ public class ExceptionHandlerTest { |
64 | 64 | |
65 | 65 | @Inject |
66 | 66 | private ExceptionNested nested; |
67 | - | |
67 | + | |
68 | 68 | @Inject |
69 | 69 | private ExceptionClassNotAnnotated classNotAnnotated; |
70 | 70 | |
... | ... | @@ -127,7 +127,7 @@ public class ExceptionHandlerTest { |
127 | 127 | assertEquals(false, nested.isExceptionHandler()); |
128 | 128 | } |
129 | 129 | } |
130 | - | |
130 | + | |
131 | 131 | @Test |
132 | 132 | public void exceptionClassNotAnnotatedController() { |
133 | 133 | try { | ... | ... |
impl/core/src/test/java/exception/basic/SimpleExceptionHandler.java
... | ... | @@ -45,7 +45,7 @@ public class SimpleExceptionHandler { |
45 | 45 | private boolean nullPointerExceptionHandler = false; |
46 | 46 | |
47 | 47 | private boolean arithmeticExceptionHandler = false; |
48 | - | |
48 | + | |
49 | 49 | public boolean isNullPointerExceptionHandler() { |
50 | 50 | return nullPointerExceptionHandler; |
51 | 51 | } |
... | ... | @@ -53,7 +53,7 @@ public class SimpleExceptionHandler { |
53 | 53 | public boolean isArithmeticExceptionHandler() { |
54 | 54 | return arithmeticExceptionHandler; |
55 | 55 | } |
56 | - | |
56 | + | |
57 | 57 | public void throwNullPointerException() { |
58 | 58 | throw new NullPointerException(); |
59 | 59 | } |
... | ... | @@ -61,11 +61,11 @@ public class SimpleExceptionHandler { |
61 | 61 | public void throwArithmeticException() { |
62 | 62 | throw new ArithmeticException(); |
63 | 63 | } |
64 | - | |
64 | + | |
65 | 65 | public void throwExceptionWithoutHandler() { |
66 | 66 | throw new IllegalArgumentException(); |
67 | - } | |
68 | - | |
67 | + } | |
68 | + | |
69 | 69 | @SuppressWarnings({ "null", "unused" }) |
70 | 70 | public void throwTwoException() { |
71 | 71 | String txt = null; |
... | ... | @@ -81,5 +81,5 @@ public class SimpleExceptionHandler { |
81 | 81 | @ExceptionHandler |
82 | 82 | public void handler(ArithmeticException cause) { |
83 | 83 | arithmeticExceptionHandler = true; |
84 | - } | |
84 | + } | |
85 | 85 | } | ... | ... |
impl/core/src/test/java/exception/custom/CustomExceptionHandler.java
... | ... | @@ -50,12 +50,12 @@ public class CustomExceptionHandler { |
50 | 50 | |
51 | 51 | public void setExceptionHandler(boolean exceptionHandler) { |
52 | 52 | this.exceptionHandler = exceptionHandler; |
53 | - } | |
54 | - | |
53 | + } | |
54 | + | |
55 | 55 | public void throwExceptionWithMessage() { |
56 | 56 | throw new CustomException(); |
57 | 57 | } |
58 | - | |
58 | + | |
59 | 59 | @ExceptionHandler |
60 | 60 | public void handler(CustomException exception) { |
61 | 61 | setExceptionHandler(true); | ... | ... |
impl/core/src/test/java/lifecycle/shutdown/priority/ShutdownWithPriority.java
... | ... | @@ -51,7 +51,7 @@ import br.gov.frameworkdemoiselle.lifecycle.Shutdown; |
51 | 51 | public class ShutdownWithPriority { |
52 | 52 | |
53 | 53 | private List<Integer> listShutdown = new ArrayList<Integer>(); |
54 | - | |
54 | + | |
55 | 55 | public List<Integer> getListShutdown() { |
56 | 56 | return listShutdown; |
57 | 57 | } |
... | ... | @@ -67,7 +67,7 @@ public class ShutdownWithPriority { |
67 | 67 | public void unloadWithPriority1() { |
68 | 68 | listShutdown.add(2); |
69 | 69 | } |
70 | - | |
70 | + | |
71 | 71 | @Shutdown |
72 | 72 | @Priority(MAX_PRIORITY) |
73 | 73 | public void unloadWithMaxPriority() { | ... | ... |
impl/core/src/test/java/lifecycle/shutdown/simple/ShutdownSimple.java
... | ... | @@ -47,11 +47,11 @@ import br.gov.frameworkdemoiselle.lifecycle.Shutdown; |
47 | 47 | public class ShutdownSimple { |
48 | 48 | |
49 | 49 | private List<Integer> listShutdown = new ArrayList<Integer>(); |
50 | - | |
50 | + | |
51 | 51 | public List<Integer> getListShutdown() { |
52 | 52 | return listShutdown; |
53 | 53 | } |
54 | - | |
54 | + | |
55 | 55 | @Shutdown |
56 | 56 | public void unloadWithoutPriorityFirst() { |
57 | 57 | listShutdown.add(3); | ... | ... |
impl/core/src/test/java/lifecycle/startup/priority/StartupWithPriorityTest.java
impl/core/src/test/java/lifecycle/startup/simple/StartupSimple.java
impl/core/src/test/java/lifecycle/startup/simple/StartupSimpleTest.java
... | ... | @@ -59,9 +59,9 @@ public class StartupSimpleTest { |
59 | 59 | |
60 | 60 | @Inject |
61 | 61 | private StartupSimple startupSimple; |
62 | - | |
62 | + | |
63 | 63 | List<Integer> expected = new ArrayList<Integer>(); |
64 | - | |
64 | + | |
65 | 65 | @Deployment |
66 | 66 | public static JavaArchive createDeployment() { |
67 | 67 | JavaArchive deployment = Tests.createDeployment(StartupSimpleTest.class); |
... | ... | @@ -73,7 +73,7 @@ public class StartupSimpleTest { |
73 | 73 | Beans.getBeanManager().fireEvent(new AfterStartupProccess() { |
74 | 74 | }); |
75 | 75 | } |
76 | - | |
76 | + | |
77 | 77 | @Test |
78 | 78 | public void startup() { |
79 | 79 | expected.add(1); |
... | ... | @@ -83,4 +83,3 @@ public class StartupSimpleTest { |
83 | 83 | Assert.assertEquals(expected, startupSimple.getListStartup()); |
84 | 84 | } |
85 | 85 | } |
86 | - | ... | ... |
impl/core/src/test/java/resourcebundle/file/defaultfile/ResourceBundleDefaultTest.java
... | ... | @@ -67,23 +67,23 @@ public class ResourceBundleDefaultTest { |
67 | 67 | |
68 | 68 | @Test |
69 | 69 | public void loadResourceDefault() { |
70 | - Locale.setDefault(new Locale("pt", "BR")); | |
70 | + Locale.setDefault(new Locale("pt", "BR")); | |
71 | 71 | bundleDefault = Beans.getReference(ResourceBundleDefault.class); |
72 | 72 | Assert.assertEquals("mensagem em Portugues", bundleDefault.getMessage()); |
73 | 73 | } |
74 | 74 | |
75 | 75 | @Test |
76 | 76 | public void loadResourceDefaultEnglish() { |
77 | - Locale.setDefault(Locale.US); | |
77 | + Locale.setDefault(Locale.US); | |
78 | 78 | bundleDefault = Beans.getReference(ResourceBundleDefault.class); |
79 | 79 | Assert.assertEquals("message in English", bundleDefault.getMessage()); |
80 | 80 | } |
81 | - | |
81 | + | |
82 | 82 | @Test |
83 | 83 | public void loadResourceWithLocaleNotExist() { |
84 | 84 | Locale.setDefault(Locale.ITALY); |
85 | 85 | bundleDefault = Beans.getReference(ResourceBundleDefault.class); |
86 | 86 | Assert.assertEquals("mensagem em Portugues", bundleDefault.getMessage()); |
87 | - } | |
87 | + } | |
88 | 88 | |
89 | 89 | } | ... | ... |
impl/core/src/test/java/resourcebundle/parameter/ResourceBundleWithParameterTest.java
... | ... | @@ -77,7 +77,7 @@ public class ResourceBundleWithParameterTest { |
77 | 77 | String value = bundleCustom.getBundle().getString("messageTwoParameter", "1", "2"); |
78 | 78 | Assert.assertEquals(expected, value); |
79 | 79 | } |
80 | - | |
80 | + | |
81 | 81 | @Test |
82 | 82 | public void loadKeyWithoutParameter() { |
83 | 83 | bundleCustom = Beans.getReference(ResourceBundleWithParameter.class); |
... | ... | @@ -85,15 +85,15 @@ public class ResourceBundleWithParameterTest { |
85 | 85 | String value = bundleCustom.getBundle().getString("messageWithoutParameter", "1", "2", "3"); |
86 | 86 | Assert.assertEquals(expected, value); |
87 | 87 | } |
88 | - | |
88 | + | |
89 | 89 | @Test |
90 | 90 | public void loadKeyWithStringParameter() { |
91 | 91 | bundleCustom = Beans.getReference(ResourceBundleWithParameter.class); |
92 | 92 | String expected = "Mensagem número 1"; |
93 | 93 | String value = bundleCustom.getBundle().getString("messageParameterString", "1"); |
94 | 94 | Assert.assertNotSame(expected, value); |
95 | - | |
96 | - expected = "Mensagem número {numero}"; | |
95 | + | |
96 | + expected = "Mensagem número {numero}"; | |
97 | 97 | Assert.assertEquals(expected, value); |
98 | 98 | } |
99 | 99 | ... | ... |
impl/core/src/test/java/security/athentication/custom/CustomAuthenticatorTest.java
... | ... | @@ -83,24 +83,24 @@ public class CustomAuthenticatorTest { |
83 | 83 | @Test |
84 | 84 | public void loginProcess() { |
85 | 85 | ContextManager.activate(ThreadLocalContext.class, RequestScoped.class); |
86 | - | |
86 | + | |
87 | 87 | context.login(); |
88 | 88 | assertTrue(context.isLoggedIn()); |
89 | 89 | assertNotNull(observer.getEvent()); |
90 | 90 | assertEquals("demoiselle", context.getCurrentUser().getName()); |
91 | - | |
91 | + | |
92 | 92 | ContextManager.deactivate(ThreadLocalContext.class, RequestScoped.class); |
93 | 93 | } |
94 | 94 | |
95 | 95 | @Test |
96 | 96 | public void logoutProcess() { |
97 | 97 | ContextManager.activate(ThreadLocalContext.class, RequestScoped.class); |
98 | - | |
98 | + | |
99 | 99 | context.login(); |
100 | 100 | context.logout(); |
101 | 101 | assertFalse(context.isLoggedIn()); |
102 | 102 | assertNull(context.getCurrentUser()); |
103 | - | |
103 | + | |
104 | 104 | ContextManager.deactivate(ThreadLocalContext.class, RequestScoped.class); |
105 | 105 | } |
106 | 106 | } | ... | ... |
impl/core/src/test/java/test/Tests.java
... | ... | @@ -47,7 +47,7 @@ public final class Tests { |
47 | 47 | private Tests() { |
48 | 48 | } |
49 | 49 | |
50 | - public static JavaArchive createDeployment(Class<?> baseClass) { | |
50 | + public static JavaArchive createDeployment(final Class<?> baseClass) { | |
51 | 51 | return createDeployment().addPackages(true, baseClass.getPackage()); |
52 | 52 | } |
53 | 53 | |
... | ... | @@ -62,7 +62,7 @@ public final class Tests { |
62 | 62 | "services/javax.enterprise.inject.spi.Extension"); |
63 | 63 | } |
64 | 64 | |
65 | - public static FileAsset createFileAsset(String pathname) { | |
65 | + public static FileAsset createFileAsset(final String pathname) { | |
66 | 66 | return new FileAsset(new File(pathname)); |
67 | 67 | } |
68 | 68 | } | ... | ... |
impl/core/src/test/java/transaction/rollback/DummyStrategy.java
... | ... | @@ -41,7 +41,7 @@ import br.gov.frameworkdemoiselle.transaction.Transaction; |
41 | 41 | public class DummyStrategy implements Transaction { |
42 | 42 | |
43 | 43 | private static final long serialVersionUID = 1L; |
44 | - | |
44 | + | |
45 | 45 | private boolean markedRollback = false; |
46 | 46 | |
47 | 47 | private boolean active = false; | ... | ... |
impl/core/src/test/java/transaction/rollback/TransactionManager.java
... | ... | @@ -97,35 +97,35 @@ public class TransactionManager { |
97 | 97 | return transactionPassedInSetRollbackOnlyMethod; |
98 | 98 | } |
99 | 99 | |
100 | - public static void setTransactionMarkedRollback(boolean markedRollback) { | |
100 | + public static void setTransactionMarkedRollback(final boolean markedRollback) { | |
101 | 101 | transactionMarkedRollback = markedRollback; |
102 | 102 | } |
103 | 103 | |
104 | - public static void setTransactionActive(boolean active) { | |
104 | + public static void setTransactionActive(final boolean active) { | |
105 | 105 | transactionActive = active; |
106 | 106 | } |
107 | 107 | |
108 | - public static void setTransactionPassedInIsActiveMethod(boolean passedInIsActiveMethod) { | |
108 | + public static void setTransactionPassedInIsActiveMethod(final boolean passedInIsActiveMethod) { | |
109 | 109 | transactionPassedInIsActiveMethod = passedInIsActiveMethod; |
110 | 110 | } |
111 | 111 | |
112 | - public static void setTransactionPassedInIsMarkedRollbackMethod(boolean passedInIsMarkedRollbackMethod) { | |
112 | + public static void setTransactionPassedInIsMarkedRollbackMethod(final boolean passedInIsMarkedRollbackMethod) { | |
113 | 113 | transactionPassedInIsMarkedRollbackMethod = passedInIsMarkedRollbackMethod; |
114 | 114 | } |
115 | 115 | |
116 | - public static void setTransactionPassedInBeginMethod(boolean passedInBeginMethod) { | |
116 | + public static void setTransactionPassedInBeginMethod(final boolean passedInBeginMethod) { | |
117 | 117 | transactionPassedInBeginMethod = passedInBeginMethod; |
118 | 118 | } |
119 | 119 | |
120 | - public static void setTransactionPassedInCommitMethod(boolean passedInCommitMethod) { | |
120 | + public static void setTransactionPassedInCommitMethod(final boolean passedInCommitMethod) { | |
121 | 121 | transactionPassedInCommitMethod = passedInCommitMethod; |
122 | 122 | } |
123 | 123 | |
124 | - public static void setTransactionPassedInRollbackMethod(boolean passedInRollbackMethod) { | |
124 | + public static void setTransactionPassedInRollbackMethod(final boolean passedInRollbackMethod) { | |
125 | 125 | transactionPassedInRollbackMethod = passedInRollbackMethod; |
126 | 126 | } |
127 | 127 | |
128 | - public static void setTransactionPassedInSetRollbackOnlyMethod(boolean passedInSetRollbackOnlyMethod) { | |
128 | + public static void setTransactionPassedInSetRollbackOnlyMethod(final boolean passedInSetRollbackOnlyMethod) { | |
129 | 129 | transactionPassedInSetRollbackOnlyMethod = passedInSetRollbackOnlyMethod; |
130 | 130 | } |
131 | 131 | } | ... | ... |
impl/core/src/test/java/transaction/rollback/TransactionManagerWithDefaultRollback.java
... | ... | @@ -41,8 +41,8 @@ import br.gov.frameworkdemoiselle.stereotype.Controller; |
41 | 41 | import br.gov.frameworkdemoiselle.transaction.Transactional; |
42 | 42 | |
43 | 43 | @Controller |
44 | -public class TransactionManagerWithDefaultRollback extends TransactionManager{ | |
45 | - | |
44 | +public class TransactionManagerWithDefaultRollback extends TransactionManager { | |
45 | + | |
46 | 46 | @Transactional |
47 | 47 | public void insert() { |
48 | 48 | throw new TransactionExceptionWithDefaultRollback(); | ... | ... |
impl/core/src/test/java/transaction/rollback/TransactionManagerWithRollback.java
... | ... | @@ -41,7 +41,7 @@ import br.gov.frameworkdemoiselle.stereotype.Controller; |
41 | 41 | import br.gov.frameworkdemoiselle.transaction.Transactional; |
42 | 42 | |
43 | 43 | @Controller |
44 | -public class TransactionManagerWithRollback extends TransactionManager{ | |
44 | +public class TransactionManagerWithRollback extends TransactionManager { | |
45 | 45 | |
46 | 46 | @Transactional |
47 | 47 | public void insert() { | ... | ... |
impl/core/src/test/java/transaction/rollback/TransactionRollbackTest.java
... | ... | @@ -58,16 +58,16 @@ import br.gov.frameworkdemoiselle.internal.context.ManagedContext; |
58 | 58 | |
59 | 59 | @RunWith(Arquillian.class) |
60 | 60 | public class TransactionRollbackTest { |
61 | - | |
61 | + | |
62 | 62 | @Inject |
63 | 63 | private TransactionManagerWithDefaultRollback managerWithDefaultRollback; |
64 | - | |
64 | + | |
65 | 65 | @Inject |
66 | 66 | private TransactionManagerWithRollback managerWithRollback; |
67 | - | |
67 | + | |
68 | 68 | @Inject |
69 | 69 | private TransactionManagerWithoutRollback managerWithoutRollback; |
70 | - | |
70 | + | |
71 | 71 | @Deployment |
72 | 72 | public static JavaArchive createDeployment() { |
73 | 73 | JavaArchive deployment = Tests.createDeployment(TransactionRollbackTest.class); |
... | ... | @@ -78,19 +78,19 @@ public class TransactionRollbackTest { |
78 | 78 | public void activeContext() { |
79 | 79 | ContextManager.activate(ManagedContext.class, RequestScoped.class); |
80 | 80 | } |
81 | - | |
81 | + | |
82 | 82 | @After |
83 | - public void deactiveContext(){ | |
83 | + public void deactiveContext() { | |
84 | 84 | ContextManager.deactivate(ManagedContext.class, RequestScoped.class); |
85 | 85 | } |
86 | - | |
86 | + | |
87 | 87 | @Test |
88 | - public void transactionWithDefaultRollback(){ | |
89 | - try{ | |
88 | + public void transactionWithDefaultRollback() { | |
89 | + try { | |
90 | 90 | managerWithDefaultRollback.clean(); |
91 | 91 | managerWithDefaultRollback.insert(); |
92 | 92 | fail(); |
93 | - }catch(TransactionExceptionWithDefaultRollback exception){ | |
93 | + } catch (TransactionExceptionWithDefaultRollback exception) { | |
94 | 94 | assertTrue(managerWithDefaultRollback.isTransactionPassedInIsActiveMethod()); |
95 | 95 | assertTrue(managerWithDefaultRollback.isTransactionPassedInBeginMethod()); |
96 | 96 | assertTrue(managerWithDefaultRollback.isTransactionMarkedRollback()); |
... | ... | @@ -101,14 +101,14 @@ public class TransactionRollbackTest { |
101 | 101 | assertFalse(managerWithDefaultRollback.isTransactionActive()); |
102 | 102 | } |
103 | 103 | } |
104 | - | |
104 | + | |
105 | 105 | @Test |
106 | - public void transactionWithRollback(){ | |
107 | - try{ | |
106 | + public void transactionWithRollback() { | |
107 | + try { | |
108 | 108 | managerWithRollback.clean(); |
109 | 109 | managerWithRollback.insert(); |
110 | 110 | fail(); |
111 | - }catch(TransactionExceptionWithRollback exception){ | |
111 | + } catch (TransactionExceptionWithRollback exception) { | |
112 | 112 | assertTrue(managerWithRollback.isTransactionPassedInIsActiveMethod()); |
113 | 113 | assertTrue(managerWithRollback.isTransactionPassedInBeginMethod()); |
114 | 114 | assertTrue(managerWithRollback.isTransactionMarkedRollback()); |
... | ... | @@ -119,14 +119,14 @@ public class TransactionRollbackTest { |
119 | 119 | assertFalse(managerWithRollback.isTransactionActive()); |
120 | 120 | } |
121 | 121 | } |
122 | - | |
123 | - @Test | |
124 | - public void transactionWithoutRollback(){ | |
125 | - try{ | |
122 | + | |
123 | + @Test | |
124 | + public void transactionWithoutRollback() { | |
125 | + try { | |
126 | 126 | managerWithoutRollback.clean(); |
127 | 127 | managerWithoutRollback.insert(); |
128 | 128 | fail(); |
129 | - }catch(TransactionExceptionWithoutRollback exception){ | |
129 | + } catch (TransactionExceptionWithoutRollback exception) { | |
130 | 130 | assertTrue(managerWithRollback.isTransactionPassedInIsActiveMethod()); |
131 | 131 | assertTrue(managerWithRollback.isTransactionPassedInBeginMethod()); |
132 | 132 | assertFalse(managerWithRollback.isTransactionMarkedRollback()); | ... | ... |
impl/core/src/test/java/util/ReflectionsTest.java
impl/core/src/test/java/util/StringsTest.java
... | ... | @@ -144,7 +144,7 @@ public class StringsTest { |
144 | 144 | assertTrue(result.contains("Test [name=myName, lastname=myLastname, nullField=null, this")); |
145 | 145 | } |
146 | 146 | |
147 | - private void testEqualsGetString(String in, String expected, Object... params) { | |
147 | + private void testEqualsGetString(final String in, final String expected, final Object... params) { | |
148 | 148 | String out = Strings.getString(in, params); |
149 | 149 | assertEquals(expected, out); |
150 | 150 | } | ... | ... |