Commit 50cc595e3b0bafe67f98ad82c21e73a3c35daaaa
Exists in
master
Merge remote-tracking branch 'origin/2.4.0' into 2.4.0
Conflicts: impl/core/src/main/java/br/gov/frameworkdemoiselle/annotation/OperationType.java
Showing
107 changed files
with
1255 additions
and
1349 deletions
Show diff stats
Too many changes.
To preserve performance only 100 of 107 files displayed.
documentation/reference/pom.xml
| @@ -45,7 +45,7 @@ | @@ -45,7 +45,7 @@ | ||
| 45 | <parent> | 45 | <parent> |
| 46 | <groupId>br.gov.frameworkdemoiselle</groupId> | 46 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 47 | <artifactId>demoiselle-documentation-parent</artifactId> | 47 | <artifactId>demoiselle-documentation-parent</artifactId> |
| 48 | - <version>8</version> | 48 | + <version>9-SNAPSHOT</version> |
| 49 | <relativePath>../../../internal/parent/documentation</relativePath> | 49 | <relativePath>../../../internal/parent/documentation</relativePath> |
| 50 | </parent> | 50 | </parent> |
| 51 | 51 |
documentation/reference/pt-BR/gerenciamento.xml
| @@ -24,6 +24,8 @@ | @@ -24,6 +24,8 @@ | ||
| 24 | uso o desenvolvedor pode se despreocupar com detalhes de implementação de cada tecnologia individual e facilmente integrar tais tecnologias.</para> | 24 | uso o desenvolvedor pode se despreocupar com detalhes de implementação de cada tecnologia individual e facilmente integrar tais tecnologias.</para> |
| 25 | </section> | 25 | </section> |
| 26 | 26 | ||
| 27 | + | ||
| 28 | + | ||
| 27 | <section> | 29 | <section> |
| 28 | <title>Introdução ao mecanismo</title> | 30 | <title>Introdução ao mecanismo</title> |
| 29 | 31 | ||
| @@ -136,6 +138,8 @@ | @@ -136,6 +138,8 @@ | ||
| 136 | 138 | ||
| 137 | </section> | 139 | </section> |
| 138 | 140 | ||
| 141 | + | ||
| 142 | + | ||
| 139 | <section> | 143 | <section> |
| 140 | <title>Expondo aspectos de sua aplicação para monitoração</title> | 144 | <title>Expondo aspectos de sua aplicação para monitoração</title> |
| 141 | 145 | ||
| @@ -169,6 +173,8 @@ | @@ -169,6 +173,8 @@ | ||
| 169 | a quantidade de logins efetuados no momento da consulta.</para> | 173 | a quantidade de logins efetuados no momento da consulta.</para> |
| 170 | </section> | 174 | </section> |
| 171 | 175 | ||
| 176 | + | ||
| 177 | + | ||
| 172 | <section> | 178 | <section> |
| 173 | <title>Conectando um cliente de monitoração</title> | 179 | <title>Conectando um cliente de monitoração</title> |
| 174 | 180 | ||
| @@ -197,7 +203,7 @@ | @@ -197,7 +203,7 @@ | ||
| 197 | individualmente, as classes monitoradas serão então expostas para todas as extensões escolhidas.</para> | 203 | individualmente, as classes monitoradas serão então expostas para todas as extensões escolhidas.</para> |
| 198 | </tip> | 204 | </tip> |
| 199 | 205 | ||
| 200 | - <para>A imagem abaixo mostra como uma classe monitorada na aplicação <emphasis>Bookmark</emphasis> é exibida no <emphasis>JConsole</emphasis>.</para> | 206 | + <para>A figura <xref linkend="exemplo_jconsole"/> mostra como uma classe monitorada na aplicação <emphasis>Bookmark</emphasis> é exibida no <emphasis>JConsole</emphasis>.</para> |
| 201 | 207 | ||
| 202 | <programlisting role="JAVA"><![CDATA[ | 208 | <programlisting role="JAVA"><![CDATA[ |
| 203 | @ManagementController | 209 | @ManagementController |
| @@ -213,15 +219,14 @@ | @@ -213,15 +219,14 @@ | ||
| 213 | } | 219 | } |
| 214 | ]]></programlisting> | 220 | ]]></programlisting> |
| 215 | 221 | ||
| 216 | - <figure> | ||
| 217 | - <title>JConsole acessando a aplicação <emphasis>Bookmark</emphasis></title> | 222 | + <figure id="exemplo_jconsole"><title>JConsole acessando a aplicação <emphasis>Bookmark</emphasis></title> |
| 218 | <mediaobject> | 223 | <mediaobject> |
| 219 | <imageobject> | 224 | <imageobject> |
| 220 | - <imagedata fileref="jmx-console-example.jpg" align="center"/> | 225 | + <imagedata fileref="images/jmx-jconsole-example.png"/> |
| 221 | </imageobject> | 226 | </imageobject> |
| 227 | + <textobject><phrase>JConsole acessando a aplicação <emphasis>Bookmark</emphasis></phrase></textobject> | ||
| 222 | </mediaobject> | 228 | </mediaobject> |
| 223 | </figure> | 229 | </figure> |
| 224 | - | ||
| 225 | </section> | 230 | </section> |
| 226 | 231 | ||
| 227 | </chapter> | 232 | </chapter> |
| 228 | \ No newline at end of file | 233 | \ No newline at end of file |
290 KB
documentation/reference/pt-BR/jmx-jconsole-example.jpg
95.5 KB
documentation/reference/pt-BR/master.xml
| @@ -5,6 +5,7 @@ | @@ -5,6 +5,7 @@ | ||
| 5 | 5 | ||
| 6 | <xi:include href="bookinfo.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> | 6 | <xi:include href="bookinfo.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> |
| 7 | 7 | ||
| 8 | + <!-- | ||
| 8 | <preface> | 9 | <preface> |
| 9 | <title>Sobre o Guia de Referência</title> | 10 | <title>Sobre o Guia de Referência</title> |
| 10 | <para> | 11 | <para> |
| @@ -38,8 +39,9 @@ | @@ -38,8 +39,9 @@ | ||
| 38 | <xi:include href="templates.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> | 39 | <xi:include href="templates.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> |
| 39 | <xi:include href="security.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> | 40 | <xi:include href="security.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> |
| 40 | <xi:include href="paginacao.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> | 41 | <xi:include href="paginacao.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> |
| 42 | + --> | ||
| 41 | <xi:include href="gerenciamento.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> | 43 | <xi:include href="gerenciamento.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> |
| 42 | - <xi:include href="properties.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> | 44 | + <!-- <xi:include href="properties.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> --> |
| 43 | 45 | ||
| 44 | <!-- parte 1 --> | 46 | <!-- parte 1 --> |
| 45 | <!-- TODO: dividir melhor os capítulos em seções --> | 47 | <!-- TODO: dividir melhor os capítulos em seções --> |
impl/core/src/main/java/br/gov/frameworkdemoiselle/annotation/Ignore.java
| @@ -42,7 +42,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; | @@ -42,7 +42,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
| 42 | import java.lang.annotation.Retention; | 42 | import java.lang.annotation.Retention; |
| 43 | import java.lang.annotation.Target; | 43 | import java.lang.annotation.Target; |
| 44 | 44 | ||
| 45 | -@Target(FIELD) | 45 | +@Target(FIELD) |
| 46 | @Retention(RUNTIME) | 46 | @Retention(RUNTIME) |
| 47 | public @interface Ignore { | 47 | public @interface Ignore { |
| 48 | } | 48 | } |
impl/core/src/main/java/br/gov/frameworkdemoiselle/annotation/ManagedOperation.java
| @@ -47,24 +47,28 @@ import javax.enterprise.util.Nonbinding; | @@ -47,24 +47,28 @@ import javax.enterprise.util.Nonbinding; | ||
| 47 | import br.gov.frameworkdemoiselle.DemoiselleException; | 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 | * @author SERPRO | 59 | * @author SERPRO |
| 54 | - * | ||
| 55 | */ | 60 | */ |
| 56 | @Documented | 61 | @Documented |
| 57 | -@Target({ElementType.METHOD}) | 62 | +@Target({ ElementType.METHOD }) |
| 58 | @Retention(RetentionPolicy.RUNTIME) | 63 | @Retention(RetentionPolicy.RUNTIME) |
| 59 | public @interface ManagedOperation { | 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 | @Nonbinding | 69 | @Nonbinding |
| 66 | String description() default ""; | 70 | String description() default ""; |
| 67 | - | 71 | + |
| 68 | /** | 72 | /** |
| 69 | * Type of operation. Defaults to {@link OperationType#UNKNOWN}. | 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,57 +45,65 @@ import java.lang.annotation.Target; | ||
| 45 | import javax.enterprise.util.Nonbinding; | 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 | * @author SERPRO | 63 | * @author SERPRO |
| 57 | - * | ||
| 58 | */ | 64 | */ |
| 59 | @Documented | 65 | @Documented |
| 60 | -@Target({ElementType.FIELD}) | 66 | +@Target({ ElementType.FIELD }) |
| 61 | @Retention(RetentionPolicy.RUNTIME) | 67 | @Retention(RetentionPolicy.RUNTIME) |
| 62 | public @interface ManagedProperty { | 68 | public @interface ManagedProperty { |
| 63 | - | 69 | + |
| 64 | /** | 70 | /** |
| 65 | * @return The description of this property exposed to management clients. | 71 | * @return The description of this property exposed to management clients. |
| 66 | */ | 72 | */ |
| 67 | @Nonbinding | 73 | @Nonbinding |
| 68 | String description() default ""; | 74 | String description() default ""; |
| 69 | - | 75 | + |
| 70 | @Nonbinding | 76 | @Nonbinding |
| 71 | ManagedPropertyAccess accessLevel() default ManagedPropertyAccess.DEFAULT; | 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 | * @author serpro | 88 | * @author serpro |
| 80 | - * | ||
| 81 | */ | 89 | */ |
| 82 | - enum ManagedPropertyAccess{ | ||
| 83 | - | 90 | + enum ManagedPropertyAccess { |
| 91 | + | ||
| 84 | /** | 92 | /** |
| 85 | * Restricts a property to be only readable even if a setter method exists. | 93 | * Restricts a property to be only readable even if a setter method exists. |
| 86 | */ | 94 | */ |
| 87 | READ_ONLY | 95 | READ_ONLY |
| 88 | - | 96 | + |
| 89 | /** | 97 | /** |
| 90 | * Restricts a property to be only writeable even if a getter method exists. | 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,29 +45,31 @@ import java.lang.annotation.Target; | ||
| 45 | import javax.enterprise.util.Nonbinding; | 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 | * @author SERPRO | 55 | * @author SERPRO |
| 52 | - * | ||
| 53 | */ | 56 | */ |
| 54 | @Documented | 57 | @Documented |
| 55 | -@Target({ElementType.PARAMETER}) | 58 | +@Target({ ElementType.PARAMETER }) |
| 56 | @Retention(RetentionPolicy.RUNTIME) | 59 | @Retention(RetentionPolicy.RUNTIME) |
| 57 | public @interface OperationParameter { | 60 | public @interface OperationParameter { |
| 58 | - | 61 | + |
| 59 | /** | 62 | /** |
| 60 | * Name that will be used to publish this operation's parameter to clients. | 63 | * Name that will be used to publish this operation's parameter to clients. |
| 61 | */ | 64 | */ |
| 62 | @Nonbinding | 65 | @Nonbinding |
| 63 | String name(); | 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 | @Nonbinding | 72 | @Nonbinding |
| 70 | String description() default ""; | 73 | String description() default ""; |
| 71 | - | ||
| 72 | 74 | ||
| 73 | } | 75 | } |
impl/core/src/main/java/br/gov/frameworkdemoiselle/annotation/OperationType.java
| @@ -37,43 +37,42 @@ | @@ -37,43 +37,42 @@ | ||
| 37 | package br.gov.frameworkdemoiselle.annotation; | 37 | package br.gov.frameworkdemoiselle.annotation; |
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | - | ||
| 41 | /** | 40 | /** |
| 42 | - * <p>Define the operation type for an operation inside a ManagementController class.</p> | ||
| 43 | - * | ||
| 44 | - * <p>This is an optional annotation and it's significanse will change based on the management extension | ||
| 45 | - * used. Most extensions will just publish this information to the client so it can better show to the user the inner | ||
| 46 | - * workings of the annotated operation.</p> | ||
| 47 | - * | 41 | + * <p> |
| 42 | + * Define the operation type for an operation inside a ManagementController class. | ||
| 43 | + * </p> | ||
| 44 | + * <p> | ||
| 45 | + * This is an optional annotation and it's significanse will change based on the management extension used. Most | ||
| 46 | + * extensions will just publish this information to the client so it can better show to the user the inner workings of | ||
| 47 | + * the annotated operation. | ||
| 48 | + * </p> | ||
| 48 | * | 49 | * |
| 49 | * @author SERPRO | 50 | * @author SERPRO |
| 50 | - * | ||
| 51 | */ | 51 | */ |
| 52 | public enum OperationType { | 52 | public enum OperationType { |
| 53 | - | 53 | + |
| 54 | /** | 54 | /** |
| 55 | - * ManagedOperation is write-only, it causes the application | ||
| 56 | - * to change some of it's behaviour but doesn't return any kind of information | 55 | + * ManagedOperation is write-only, it causes the application to change some of it's behaviour but doesn't return any |
| 56 | + * kind of information | ||
| 57 | */ | 57 | */ |
| 58 | - ACTION | ||
| 59 | - , | 58 | + ACTION, |
| 59 | + | ||
| 60 | /** | 60 | /** |
| 61 | * ManagedOperation is read-only, it will operate over data provided by the application and return some information, | 61 | * ManagedOperation is read-only, it will operate over data provided by the application and return some information, |
| 62 | * but will not change the application in any way. | 62 | * but will not change the application in any way. |
| 63 | */ | 63 | */ |
| 64 | - INFO | ||
| 65 | - , | 64 | + INFO, |
| 65 | + | ||
| 66 | /** | 66 | /** |
| 67 | - * ManagedOperation is read-write, it will both change the way the application work and return some information regarding | ||
| 68 | - * the result of the operation. | 67 | + * ManagedOperation is read-write, it will both change the way the application work and return some information |
| 68 | + * regarding the result of the operation. | ||
| 69 | */ | 69 | */ |
| 70 | - ACTION_INFO | ||
| 71 | - , | 70 | + ACTION_INFO, |
| 71 | + | ||
| 72 | /** | 72 | /** |
| 73 | - * The effect of calling this operation is unknown. This is the default type and if this type is assigned to an operation, | ||
| 74 | - * the user must rely on the {@link ManagedOperation#description()} attribute to learn about how the operation works. | 73 | + * The effect of calling this operation is unknown. This is the default type and if this type is assigned to an |
| 74 | + * operation, the user must rely on the {@link ManagedOperation#description()} attribute to learn about how the | ||
| 75 | + * operation works. | ||
| 75 | */ | 76 | */ |
| 76 | UNKNOWN | 77 | UNKNOWN |
| 77 | - | ||
| 78 | - | ||
| 79 | } | 78 | } |
impl/core/src/main/java/br/gov/frameworkdemoiselle/annotation/Priority.java
| @@ -60,6 +60,14 @@ public @interface Priority { | @@ -60,6 +60,14 @@ public @interface Priority { | ||
| 60 | */ | 60 | */ |
| 61 | static int MIN_PRIORITY = Integer.MAX_VALUE; | 61 | static int MIN_PRIORITY = Integer.MAX_VALUE; |
| 62 | 62 | ||
| 63 | + static int L1_PRIORITY = MIN_PRIORITY; | ||
| 64 | + | ||
| 65 | + static int L2_PRIORITY = L1_PRIORITY - 100; | ||
| 66 | + | ||
| 67 | + static int L3_PRIORITY = L2_PRIORITY - 100; | ||
| 68 | + | ||
| 69 | + static int L4_PRIORITY = L3_PRIORITY - 100; | ||
| 70 | + | ||
| 63 | /** | 71 | /** |
| 64 | * An integer value defines the priority order. | 72 | * An integer value defines the priority order. |
| 65 | */ | 73 | */ |
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,9 +52,9 @@ import javax.interceptor.InvocationContext; | ||
| 52 | import org.slf4j.Logger; | 52 | import org.slf4j.Logger; |
| 53 | 53 | ||
| 54 | import br.gov.frameworkdemoiselle.DemoiselleException; | 54 | import br.gov.frameworkdemoiselle.DemoiselleException; |
| 55 | -import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; | ||
| 56 | -import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | ||
| 57 | import br.gov.frameworkdemoiselle.stereotype.Controller; | 55 | import br.gov.frameworkdemoiselle.stereotype.Controller; |
| 56 | +import br.gov.frameworkdemoiselle.util.Beans; | ||
| 57 | +import br.gov.frameworkdemoiselle.util.NameQualifier; | ||
| 58 | import br.gov.frameworkdemoiselle.util.ResourceBundle; | 58 | import br.gov.frameworkdemoiselle.util.ResourceBundle; |
| 59 | 59 | ||
| 60 | @Interceptor | 60 | @Interceptor |
| @@ -63,9 +63,9 @@ public class ExceptionHandlerInterceptor implements Serializable { | @@ -63,9 +63,9 @@ public class ExceptionHandlerInterceptor implements Serializable { | ||
| 63 | 63 | ||
| 64 | private static final long serialVersionUID = 1L; | 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 | private final Map<Class<?>, Map<Class<?>, Method>> cache = new HashMap<Class<?>, Map<Class<?>, Method>>(); | 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,7 +199,7 @@ public class ExceptionHandlerInterceptor implements Serializable { | ||
| 199 | 199 | ||
| 200 | private static ResourceBundle getBundle() { | 200 | private static ResourceBundle getBundle() { |
| 201 | if (bundle == null) { | 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 | return bundle; | 205 | return bundle; |
| @@ -207,7 +207,7 @@ public class ExceptionHandlerInterceptor implements Serializable { | @@ -207,7 +207,7 @@ public class ExceptionHandlerInterceptor implements Serializable { | ||
| 207 | 207 | ||
| 208 | private static Logger getLogger() { | 208 | private static Logger getLogger() { |
| 209 | if (logger == null) { | 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 | return logger; | 213 | return logger; |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/AbstractLifecycleBootstrap.java
| @@ -98,23 +98,22 @@ public abstract class AbstractLifecycleBootstrap<A extends Annotation> implement | @@ -98,23 +98,22 @@ public abstract class AbstractLifecycleBootstrap<A extends Annotation> implement | ||
| 98 | return this.annotationClass; | 98 | return this.annotationClass; |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | + @SuppressWarnings("unchecked") | ||
| 101 | public <T> void processAnnotatedType(@Observes final ProcessAnnotatedType<T> event) { | 102 | public <T> void processAnnotatedType(@Observes final ProcessAnnotatedType<T> event) { |
| 102 | final AnnotatedType<T> annotatedType = event.getAnnotatedType(); | 103 | final AnnotatedType<T> annotatedType = event.getAnnotatedType(); |
| 103 | 104 | ||
| 104 | for (AnnotatedMethod<?> am : annotatedType.getMethods()) { | 105 | for (AnnotatedMethod<?> am : annotatedType.getMethods()) { |
| 105 | if (am.isAnnotationPresent(getAnnotationClass())) { | 106 | if (am.isAnnotationPresent(getAnnotationClass())) { |
| 106 | - @SuppressWarnings("unchecked") | ||
| 107 | - AnnotatedMethod<T> annotatedMethod = (AnnotatedMethod<T>) am; | ||
| 108 | - processors.add(newProcessorInstance(annotatedMethod)); | 107 | + processors.add(newProcessorInstance((AnnotatedMethod<T>) am)); |
| 109 | } | 108 | } |
| 110 | } | 109 | } |
| 111 | } | 110 | } |
| 112 | 111 | ||
| 113 | public void loadTempContexts(@Observes final AfterBeanDiscovery event) { | 112 | public void loadTempContexts(@Observes final AfterBeanDiscovery event) { |
| 114 | - //Caso este bootstrap rode antes do CoreBootstrap. Não há problemas em chamar este método várias vezes, ele | ||
| 115 | - //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. | ||
| 116 | ContextManager.initialize(event); | 115 | ContextManager.initialize(event); |
| 117 | - | 116 | + |
| 118 | // Não registrar o contexto de aplicação pq ele já é registrado pela implementação do CDI | 117 | // Não registrar o contexto de aplicação pq ele já é registrado pela implementação do CDI |
| 119 | ContextManager.add(new ThreadLocalContext(ViewScoped.class), event); | 118 | ContextManager.add(new ThreadLocalContext(ViewScoped.class), event); |
| 120 | ContextManager.add(new ThreadLocalContext(SessionScoped.class), event); | 119 | ContextManager.add(new ThreadLocalContext(SessionScoped.class), event); |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/AuthenticatorBootstrap.java
| @@ -1,56 +0,0 @@ | @@ -1,56 +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 org.slf4j.Logger; | ||
| 40 | - | ||
| 41 | -import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; | ||
| 42 | -import br.gov.frameworkdemoiselle.security.Authenticator; | ||
| 43 | - | ||
| 44 | -public class AuthenticatorBootstrap extends AbstractStrategyBootstrap<Authenticator> { | ||
| 45 | - | ||
| 46 | - private Logger logger; | ||
| 47 | - | ||
| 48 | - @Override | ||
| 49 | - protected Logger getLogger() { | ||
| 50 | - if (logger == null) { | ||
| 51 | - logger = LoggerProducer.create(AuthenticatorBootstrap.class); | ||
| 52 | - } | ||
| 53 | - | ||
| 54 | - return logger; | ||
| 55 | - } | ||
| 56 | -} |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/AuthorizerBootstrap.java
| @@ -1,56 +0,0 @@ | @@ -1,56 +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 org.slf4j.Logger; | ||
| 40 | - | ||
| 41 | -import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; | ||
| 42 | -import br.gov.frameworkdemoiselle.security.Authorizer; | ||
| 43 | - | ||
| 44 | -public class AuthorizerBootstrap extends AbstractStrategyBootstrap<Authorizer> { | ||
| 45 | - | ||
| 46 | - private Logger logger; | ||
| 47 | - | ||
| 48 | - @Override | ||
| 49 | - protected Logger getLogger() { | ||
| 50 | - if (logger == null) { | ||
| 51 | - logger = LoggerProducer.create(AuthorizerBootstrap.class); | ||
| 52 | - } | ||
| 53 | - | ||
| 54 | - return logger; | ||
| 55 | - } | ||
| 56 | -} |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ConfigurationBootstrap.java
| @@ -96,7 +96,7 @@ public class ConfigurationBootstrap extends AbstractStrategyBootstrap<Configurat | @@ -96,7 +96,7 @@ public class ConfigurationBootstrap extends AbstractStrategyBootstrap<Configurat | ||
| 96 | String superClassName = type.getCanonicalName(); | 96 | String superClassName = type.getCanonicalName(); |
| 97 | String chieldClassName = superClassName + "_$$_DemoiselleProxy"; | 97 | String chieldClassName = superClassName + "_$$_DemoiselleProxy"; |
| 98 | 98 | ||
| 99 | - Map<String, Class<Object>> cacheProxy = Collections.synchronizedMap(new HashMap<String, Class<Object>>());; | 99 | + Map<String, Class<Object>> cacheProxy = Collections.synchronizedMap(new HashMap<String, Class<Object>>()); |
| 100 | 100 | ||
| 101 | Class<Object> clazzProxy = null; | 101 | Class<Object> clazzProxy = null; |
| 102 | 102 | ||
| @@ -139,7 +139,7 @@ public class ConfigurationBootstrap extends AbstractStrategyBootstrap<Configurat | @@ -139,7 +139,7 @@ public class ConfigurationBootstrap extends AbstractStrategyBootstrap<Configurat | ||
| 139 | @Override | 139 | @Override |
| 140 | protected Logger getLogger() { | 140 | protected Logger getLogger() { |
| 141 | if (logger == null) { | 141 | if (logger == null) { |
| 142 | - logger = LoggerProducer.create(TransactionBootstrap.class); | 142 | + logger = LoggerProducer.create(ConfigurationBootstrap.class); |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | return logger; | 145 | return logger; |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/CustomInjectionPoint.java
| @@ -1,136 +0,0 @@ | @@ -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,8 +32,8 @@ public class ManagementBootstrap implements Extension { | ||
| 32 | 32 | ||
| 33 | protected static List<AnnotatedType<?>> types = Collections.synchronizedList(new ArrayList<AnnotatedType<?>>()); | 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 | public <T> void detectAnnotation(@Observes final ProcessAnnotatedType<T> event, final BeanManager beanManager) { | 38 | public <T> void detectAnnotation(@Observes final ProcessAnnotatedType<T> event, final BeanManager beanManager) { |
| 39 | if (event.getAnnotatedType().isAnnotationPresent(ManagementController.class)) { | 39 | if (event.getAnnotatedType().isAnnotationPresent(ManagementController.class)) { |
| @@ -47,27 +47,28 @@ public class ManagementBootstrap implements Extension { | @@ -47,27 +47,28 @@ public class ManagementBootstrap implements Extension { | ||
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | @SuppressWarnings("unchecked") | 49 | @SuppressWarnings("unchecked") |
| 50 | - public void registerAvailableManagedTypes(@Observes final AfterDeploymentValidation event,BeanManager beanManager) { | 50 | + public void registerAvailableManagedTypes(@Observes final AfterDeploymentValidation event, BeanManager beanManager) { |
| 51 | ResourceBundle bundle = ResourceBundleProducer.create("demoiselle-core-bundle", Locale.getDefault()); | 51 | ResourceBundle bundle = ResourceBundleProducer.create("demoiselle-core-bundle", Locale.getDefault()); |
| 52 | 52 | ||
| 53 | Management monitoringManager = Beans.getReference(Management.class); | 53 | Management monitoringManager = Beans.getReference(Management.class); |
| 54 | for (AnnotatedType<?> type : types) { | 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 | ManagedType managedType = new ManagedType(type.getJavaClass()); | 60 | ManagedType managedType = new ManagedType(type.getJavaClass()); |
| 60 | monitoringManager.addManagedType(managedType); | 61 | monitoringManager.addManagedType(managedType); |
| 61 | } | 62 | } |
| 62 | - | 63 | + |
| 63 | Set<Bean<?>> extensionBeans = beanManager.getBeans(ManagementExtension.class); | 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 | Class<?> extensionConcreteClass = bean.getBeanClass(); | 67 | Class<?> extensionConcreteClass = bean.getBeanClass(); |
| 67 | managementExtensionCache.add((Class<? extends ManagementExtension>) extensionConcreteClass); | 68 | managementExtensionCache.add((Class<? extends ManagementExtension>) extensionConcreteClass); |
| 68 | } | 69 | } |
| 69 | } | 70 | } |
| 70 | - | 71 | + |
| 71 | monitoringManager.initialize(managementExtensionCache); | 72 | monitoringManager.initialize(managementExtensionCache); |
| 72 | } | 73 | } |
| 73 | 74 | ||
| @@ -75,7 +76,7 @@ public class ManagementBootstrap implements Extension { | @@ -75,7 +76,7 @@ public class ManagementBootstrap implements Extension { | ||
| 75 | 76 | ||
| 76 | Management manager = Beans.getReference(Management.class); | 77 | Management manager = Beans.getReference(Management.class); |
| 77 | manager.shutdown(managementExtensionCache); | 78 | manager.shutdown(managementExtensionCache); |
| 78 | - | 79 | + |
| 79 | managementExtensionCache.clear(); | 80 | managementExtensionCache.clear(); |
| 80 | types.clear(); | 81 | types.clear(); |
| 81 | } | 82 | } |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/TransactionBootstrap.java
| @@ -1,56 +0,0 @@ | @@ -1,56 +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 org.slf4j.Logger; | ||
| 40 | - | ||
| 41 | -import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; | ||
| 42 | -import br.gov.frameworkdemoiselle.transaction.Transaction; | ||
| 43 | - | ||
| 44 | -public class TransactionBootstrap extends AbstractStrategyBootstrap<Transaction> { | ||
| 45 | - | ||
| 46 | - private Logger logger; | ||
| 47 | - | ||
| 48 | - @Override | ||
| 49 | - protected Logger getLogger() { | ||
| 50 | - if (logger == null) { | ||
| 51 | - logger = LoggerProducer.create(TransactionBootstrap.class); | ||
| 52 | - } | ||
| 53 | - | ||
| 54 | - return logger; | ||
| 55 | - } | ||
| 56 | -} |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/AbstractCustomContext.java
| @@ -75,7 +75,7 @@ public abstract class AbstractCustomContext implements CustomContext { | @@ -75,7 +75,7 @@ public abstract class AbstractCustomContext implements CustomContext { | ||
| 75 | 75 | ||
| 76 | Class<?> type = getType(contextual); | 76 | Class<?> type = getType(contextual); |
| 77 | if (getStore().contains(type)) { | 77 | if (getStore().contains(type)) { |
| 78 | - instance = (T) getStore().get(type); | 78 | + instance = getStore().get(type); |
| 79 | 79 | ||
| 80 | } else if (creationalContext != null) { | 80 | } else if (creationalContext != null) { |
| 81 | instance = contextual.create(creationalContext); | 81 | instance = contextual.create(creationalContext); |
| @@ -96,8 +96,8 @@ public abstract class AbstractCustomContext implements CustomContext { | @@ -96,8 +96,8 @@ public abstract class AbstractCustomContext implements CustomContext { | ||
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | public void setActive(boolean active) { | 98 | public void setActive(boolean active) { |
| 99 | - if (!active && this.active){ | ||
| 100 | - //Limpando contexto | 99 | + if (!active && this.active) { |
| 100 | + // Limpando contexto | ||
| 101 | getStore().clear(); | 101 | getStore().clear(); |
| 102 | } | 102 | } |
| 103 | this.active = active; | 103 | this.active = active; |
| @@ -120,13 +120,13 @@ public abstract class AbstractCustomContext implements CustomContext { | @@ -120,13 +120,13 @@ public abstract class AbstractCustomContext implements CustomContext { | ||
| 120 | private Store() { | 120 | private Store() { |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | - | ||
| 124 | private boolean contains(final Class<?> type) { | 123 | private boolean contains(final Class<?> type) { |
| 125 | return this.getMap().containsKey(type); | 124 | return this.getMap().containsKey(type); |
| 126 | } | 125 | } |
| 127 | 126 | ||
| 128 | - private Object get(final Class<?> type) { | ||
| 129 | - return this.getMap().get(type); | 127 | + @SuppressWarnings("unchecked") |
| 128 | + private <T> T get(final Class<?> type) { | ||
| 129 | + return (T) this.getMap().get(type); | ||
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | private void put(final Class<?> type, final Object instance) { | 132 | private void put(final Class<?> type, final Object instance) { |
| @@ -136,7 +136,7 @@ public abstract class AbstractCustomContext implements CustomContext { | @@ -136,7 +136,7 @@ public abstract class AbstractCustomContext implements CustomContext { | ||
| 136 | public void clear() { | 136 | public void clear() { |
| 137 | cache.clear(); | 137 | cache.clear(); |
| 138 | } | 138 | } |
| 139 | - | 139 | + |
| 140 | private Map<Class<?>, Object> getMap() { | 140 | private Map<Class<?>, Object> getMap() { |
| 141 | ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); | 141 | ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); |
| 142 | 142 |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/ContextManager.java
| @@ -51,8 +51,9 @@ public class ContextManager { | @@ -51,8 +51,9 @@ public class ContextManager { | ||
| 51 | private static ResourceBundle bundle; | 51 | private static ResourceBundle bundle; |
| 52 | 52 | ||
| 53 | private static Logger logger; | 53 | private static Logger logger; |
| 54 | - | ||
| 55 | - private ContextManager(){} | 54 | + |
| 55 | + private ContextManager() { | ||
| 56 | + } | ||
| 56 | 57 | ||
| 57 | /** | 58 | /** |
| 58 | * <p> | 59 | * <p> |
| @@ -105,9 +106,9 @@ public class ContextManager { | @@ -105,9 +106,9 @@ public class ContextManager { | ||
| 105 | } | 106 | } |
| 106 | 107 | ||
| 107 | ContextManager.getLogger().trace( | 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 | context.setActive(false); | 112 | context.setActive(false); |
| 112 | event.addContext(context); | 113 | event.addContext(context); |
| 113 | contexts.add(new CustomContextCounter(context)); | 114 | contexts.add(new CustomContextCounter(context)); |
| @@ -194,8 +195,10 @@ public class ContextManager { | @@ -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 | public static synchronized void shutdown() { | 203 | public static synchronized void shutdown() { |
| 201 | for (CustomContextCounter context : contexts) { | 204 | for (CustomContextCounter context : contexts) { |
| @@ -252,7 +255,7 @@ class CustomContextCounter { | @@ -252,7 +255,7 @@ class CustomContextCounter { | ||
| 252 | public CustomContext getInternalContext() { | 255 | public CustomContext getInternalContext() { |
| 253 | return this.context; | 256 | return this.context; |
| 254 | } | 257 | } |
| 255 | - | 258 | + |
| 256 | public void setInternalContext(CustomContext context) { | 259 | public void setInternalContext(CustomContext context) { |
| 257 | this.context = context; | 260 | this.context = context; |
| 258 | } | 261 | } |
| @@ -261,19 +264,14 @@ class CustomContextCounter { | @@ -261,19 +264,14 @@ class CustomContextCounter { | ||
| 261 | try { | 264 | try { |
| 262 | BeanManager beanManager = Beans.getReference(BeanManager.class); | 265 | BeanManager beanManager = Beans.getReference(BeanManager.class); |
| 263 | Context c = beanManager.getContext(context.getScope()); | 266 | Context c = beanManager.getContext(context.getScope()); |
| 264 | - | ||
| 265 | - | 267 | + |
| 266 | if (c == context) { | 268 | if (c == context) { |
| 267 | activationCounter++; | 269 | activationCounter++; |
| 268 | - } | ||
| 269 | - else{ | 270 | + } else { |
| 270 | ContextManager.getLogger().trace( | 271 | ContextManager.getLogger().trace( |
| 271 | ContextManager.getBundle().getString("custom-context-already-activated", | 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 | } catch (ContextNotActiveException ce) { | 276 | } catch (ContextNotActiveException ce) { |
| 279 | context.setActive(true); | 277 | context.setActive(true); |
| @@ -299,10 +297,10 @@ class CustomContextCounter { | @@ -299,10 +297,10 @@ class CustomContextCounter { | ||
| 299 | } catch (ContextNotActiveException ce) { | 297 | } catch (ContextNotActiveException ce) { |
| 300 | } | 298 | } |
| 301 | } | 299 | } |
| 302 | - | 300 | + |
| 303 | public synchronized void shutdown() { | 301 | public synchronized void shutdown() { |
| 304 | context.setActive(false); | 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,14 +5,13 @@ import javax.enterprise.context.RequestScoped; | ||
| 5 | import br.gov.frameworkdemoiselle.stereotype.ManagementController; | 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 | * @author serpro | 11 | * @author serpro |
| 12 | - * | ||
| 13 | */ | 12 | */ |
| 14 | public class ManagedContext extends ThreadLocalContext { | 13 | public class ManagedContext extends ThreadLocalContext { |
| 15 | - | 14 | + |
| 16 | /** | 15 | /** |
| 17 | * Constructs a new context. | 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,10 +51,9 @@ package br.gov.frameworkdemoiselle.internal.context; | ||
| 51 | import java.lang.annotation.Annotation; | 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 | * @author serpro | 56 | * @author serpro |
| 57 | - * | ||
| 58 | */ | 57 | */ |
| 59 | public class ThreadLocalContext extends AbstractCustomContext { | 58 | public class ThreadLocalContext extends AbstractCustomContext { |
| 60 | 59 |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConfigurationArrayValueExtractor.java
| @@ -36,7 +36,7 @@ | @@ -36,7 +36,7 @@ | ||
| 36 | */ | 36 | */ |
| 37 | package br.gov.frameworkdemoiselle.internal.implementation; | 37 | package br.gov.frameworkdemoiselle.internal.implementation; |
| 38 | 38 | ||
| 39 | -import static br.gov.frameworkdemoiselle.internal.implementation.StrategySelector.EXTENSIONS_L1_PRIORITY; | 39 | +import static br.gov.frameworkdemoiselle.annotation.Priority.L2_PRIORITY; |
| 40 | 40 | ||
| 41 | import java.lang.reflect.Field; | 41 | import java.lang.reflect.Field; |
| 42 | 42 | ||
| @@ -46,7 +46,7 @@ import org.apache.commons.configuration.DataConfiguration; | @@ -46,7 +46,7 @@ import org.apache.commons.configuration.DataConfiguration; | ||
| 46 | import br.gov.frameworkdemoiselle.annotation.Priority; | 46 | import br.gov.frameworkdemoiselle.annotation.Priority; |
| 47 | import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; | 47 | import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; |
| 48 | 48 | ||
| 49 | -@Priority(EXTENSIONS_L1_PRIORITY) | 49 | +@Priority(L2_PRIORITY) |
| 50 | public class ConfigurationArrayValueExtractor implements ConfigurationValueExtractor { | 50 | public class ConfigurationArrayValueExtractor implements ConfigurationValueExtractor { |
| 51 | 51 | ||
| 52 | @Override | 52 | @Override |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConfigurationClassValueExtractor.java
| @@ -36,7 +36,7 @@ | @@ -36,7 +36,7 @@ | ||
| 36 | */ | 36 | */ |
| 37 | package br.gov.frameworkdemoiselle.internal.implementation; | 37 | package br.gov.frameworkdemoiselle.internal.implementation; |
| 38 | 38 | ||
| 39 | -import static br.gov.frameworkdemoiselle.internal.implementation.StrategySelector.EXTENSIONS_L1_PRIORITY; | 39 | +import static br.gov.frameworkdemoiselle.annotation.Priority.L2_PRIORITY; |
| 40 | 40 | ||
| 41 | import java.lang.reflect.Field; | 41 | import java.lang.reflect.Field; |
| 42 | 42 | ||
| @@ -46,7 +46,7 @@ import br.gov.frameworkdemoiselle.annotation.Priority; | @@ -46,7 +46,7 @@ import br.gov.frameworkdemoiselle.annotation.Priority; | ||
| 46 | import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; | 46 | import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; |
| 47 | import br.gov.frameworkdemoiselle.util.Reflections; | 47 | import br.gov.frameworkdemoiselle.util.Reflections; |
| 48 | 48 | ||
| 49 | -@Priority(EXTENSIONS_L1_PRIORITY) | 49 | +@Priority(L2_PRIORITY) |
| 50 | public class ConfigurationClassValueExtractor implements ConfigurationValueExtractor { | 50 | public class ConfigurationClassValueExtractor implements ConfigurationValueExtractor { |
| 51 | 51 | ||
| 52 | @Override | 52 | @Override |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConfigurationMapValueExtractor.java
| @@ -36,7 +36,7 @@ | @@ -36,7 +36,7 @@ | ||
| 36 | */ | 36 | */ |
| 37 | package br.gov.frameworkdemoiselle.internal.implementation; | 37 | package br.gov.frameworkdemoiselle.internal.implementation; |
| 38 | 38 | ||
| 39 | -import static br.gov.frameworkdemoiselle.internal.implementation.StrategySelector.EXTENSIONS_L1_PRIORITY; | 39 | +import static br.gov.frameworkdemoiselle.annotation.Priority.L2_PRIORITY; |
| 40 | 40 | ||
| 41 | import java.lang.reflect.Field; | 41 | import java.lang.reflect.Field; |
| 42 | import java.util.HashMap; | 42 | import java.util.HashMap; |
| @@ -50,7 +50,7 @@ import org.apache.commons.configuration.Configuration; | @@ -50,7 +50,7 @@ import org.apache.commons.configuration.Configuration; | ||
| 50 | import br.gov.frameworkdemoiselle.annotation.Priority; | 50 | import br.gov.frameworkdemoiselle.annotation.Priority; |
| 51 | import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; | 51 | import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; |
| 52 | 52 | ||
| 53 | -@Priority(EXTENSIONS_L1_PRIORITY) | 53 | +@Priority(L2_PRIORITY) |
| 54 | public class ConfigurationMapValueExtractor implements ConfigurationValueExtractor { | 54 | public class ConfigurationMapValueExtractor implements ConfigurationValueExtractor { |
| 55 | 55 | ||
| 56 | @Override | 56 | @Override |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConfigurationPrimitiveOrWrapperValueExtractor.java
| @@ -36,7 +36,7 @@ | @@ -36,7 +36,7 @@ | ||
| 36 | */ | 36 | */ |
| 37 | package br.gov.frameworkdemoiselle.internal.implementation; | 37 | package br.gov.frameworkdemoiselle.internal.implementation; |
| 38 | 38 | ||
| 39 | -import static br.gov.frameworkdemoiselle.internal.implementation.StrategySelector.EXTENSIONS_L1_PRIORITY; | 39 | +import static br.gov.frameworkdemoiselle.annotation.Priority.L2_PRIORITY; |
| 40 | 40 | ||
| 41 | import java.lang.reflect.Field; | 41 | import java.lang.reflect.Field; |
| 42 | import java.util.HashSet; | 42 | import java.util.HashSet; |
| @@ -50,7 +50,7 @@ import org.apache.commons.lang.ClassUtils; | @@ -50,7 +50,7 @@ import org.apache.commons.lang.ClassUtils; | ||
| 50 | import br.gov.frameworkdemoiselle.annotation.Priority; | 50 | import br.gov.frameworkdemoiselle.annotation.Priority; |
| 51 | import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; | 51 | import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; |
| 52 | 52 | ||
| 53 | -@Priority(EXTENSIONS_L1_PRIORITY) | 53 | +@Priority(L2_PRIORITY) |
| 54 | public class ConfigurationPrimitiveOrWrapperValueExtractor implements ConfigurationValueExtractor { | 54 | public class ConfigurationPrimitiveOrWrapperValueExtractor implements ConfigurationValueExtractor { |
| 55 | 55 | ||
| 56 | private static final Set<Object> wrappers = new HashSet<Object>(); | 56 | private static final Set<Object> wrappers = new HashSet<Object>(); |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConfigurationStringValueExtractor.java
| @@ -36,7 +36,7 @@ | @@ -36,7 +36,7 @@ | ||
| 36 | */ | 36 | */ |
| 37 | package br.gov.frameworkdemoiselle.internal.implementation; | 37 | package br.gov.frameworkdemoiselle.internal.implementation; |
| 38 | 38 | ||
| 39 | -import static br.gov.frameworkdemoiselle.internal.implementation.StrategySelector.EXTENSIONS_L1_PRIORITY; | 39 | +import static br.gov.frameworkdemoiselle.annotation.Priority.L2_PRIORITY; |
| 40 | 40 | ||
| 41 | import java.lang.reflect.Field; | 41 | import java.lang.reflect.Field; |
| 42 | 42 | ||
| @@ -45,7 +45,7 @@ import org.apache.commons.configuration.Configuration; | @@ -45,7 +45,7 @@ import org.apache.commons.configuration.Configuration; | ||
| 45 | import br.gov.frameworkdemoiselle.annotation.Priority; | 45 | import br.gov.frameworkdemoiselle.annotation.Priority; |
| 46 | import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; | 46 | import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; |
| 47 | 47 | ||
| 48 | -@Priority(EXTENSIONS_L1_PRIORITY) | 48 | +@Priority(L2_PRIORITY) |
| 49 | public class ConfigurationStringValueExtractor implements ConfigurationValueExtractor { | 49 | public class ConfigurationStringValueExtractor implements ConfigurationValueExtractor { |
| 50 | 50 | ||
| 51 | @Override | 51 | @Override |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthenticator.java
| @@ -36,14 +36,16 @@ | @@ -36,14 +36,16 @@ | ||
| 36 | */ | 36 | */ |
| 37 | package br.gov.frameworkdemoiselle.internal.implementation; | 37 | package br.gov.frameworkdemoiselle.internal.implementation; |
| 38 | 38 | ||
| 39 | -import static br.gov.frameworkdemoiselle.internal.implementation.StrategySelector.CORE_PRIORITY; | 39 | +import static br.gov.frameworkdemoiselle.annotation.Priority.L1_PRIORITY; |
| 40 | + | ||
| 41 | +import java.security.Principal; | ||
| 42 | + | ||
| 40 | import br.gov.frameworkdemoiselle.DemoiselleException; | 43 | import br.gov.frameworkdemoiselle.DemoiselleException; |
| 41 | import br.gov.frameworkdemoiselle.annotation.Priority; | 44 | import br.gov.frameworkdemoiselle.annotation.Priority; |
| 42 | import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | 45 | import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; |
| 43 | import br.gov.frameworkdemoiselle.security.AuthenticationException; | 46 | import br.gov.frameworkdemoiselle.security.AuthenticationException; |
| 44 | import br.gov.frameworkdemoiselle.security.Authenticator; | 47 | import br.gov.frameworkdemoiselle.security.Authenticator; |
| 45 | import br.gov.frameworkdemoiselle.security.SecurityContext; | 48 | import br.gov.frameworkdemoiselle.security.SecurityContext; |
| 46 | -import br.gov.frameworkdemoiselle.security.User; | ||
| 47 | import br.gov.frameworkdemoiselle.util.ResourceBundle; | 49 | import br.gov.frameworkdemoiselle.util.ResourceBundle; |
| 48 | 50 | ||
| 49 | /** | 51 | /** |
| @@ -52,8 +54,7 @@ import br.gov.frameworkdemoiselle.util.ResourceBundle; | @@ -52,8 +54,7 @@ import br.gov.frameworkdemoiselle.util.ResourceBundle; | ||
| 52 | * @author SERPRO | 54 | * @author SERPRO |
| 53 | * @see Authenticator | 55 | * @see Authenticator |
| 54 | */ | 56 | */ |
| 55 | -@SuppressWarnings("deprecation") | ||
| 56 | -@Priority(CORE_PRIORITY) | 57 | +@Priority(L1_PRIORITY) |
| 57 | public class DefaultAuthenticator implements Authenticator { | 58 | public class DefaultAuthenticator implements Authenticator { |
| 58 | 59 | ||
| 59 | private static final long serialVersionUID = 1L; | 60 | private static final long serialVersionUID = 1L; |
| @@ -80,7 +81,7 @@ public class DefaultAuthenticator implements Authenticator { | @@ -80,7 +81,7 @@ public class DefaultAuthenticator implements Authenticator { | ||
| 80 | * @see br.gov.frameworkdemoiselle.security.Authenticator#getUser() | 81 | * @see br.gov.frameworkdemoiselle.security.Authenticator#getUser() |
| 81 | */ | 82 | */ |
| 82 | @Override | 83 | @Override |
| 83 | - public User getUser() { | 84 | + public Principal getUser() { |
| 84 | throw getException(); | 85 | throw getException(); |
| 85 | } | 86 | } |
| 86 | 87 |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthorizer.java
| @@ -36,7 +36,7 @@ | @@ -36,7 +36,7 @@ | ||
| 36 | */ | 36 | */ |
| 37 | package br.gov.frameworkdemoiselle.internal.implementation; | 37 | package br.gov.frameworkdemoiselle.internal.implementation; |
| 38 | 38 | ||
| 39 | -import static br.gov.frameworkdemoiselle.internal.implementation.StrategySelector.CORE_PRIORITY; | 39 | +import static br.gov.frameworkdemoiselle.annotation.Priority.L1_PRIORITY; |
| 40 | import br.gov.frameworkdemoiselle.DemoiselleException; | 40 | import br.gov.frameworkdemoiselle.DemoiselleException; |
| 41 | import br.gov.frameworkdemoiselle.annotation.Priority; | 41 | import br.gov.frameworkdemoiselle.annotation.Priority; |
| 42 | import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | 42 | import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; |
| @@ -50,7 +50,7 @@ import br.gov.frameworkdemoiselle.util.ResourceBundle; | @@ -50,7 +50,7 @@ import br.gov.frameworkdemoiselle.util.ResourceBundle; | ||
| 50 | * @author SERPRO | 50 | * @author SERPRO |
| 51 | * @see Authorizer | 51 | * @see Authorizer |
| 52 | */ | 52 | */ |
| 53 | -@Priority(CORE_PRIORITY) | 53 | +@Priority(L1_PRIORITY) |
| 54 | public class DefaultAuthorizer implements Authorizer { | 54 | public class DefaultAuthorizer implements Authorizer { |
| 55 | 55 | ||
| 56 | private static final long serialVersionUID = 1L; | 56 | private static final long serialVersionUID = 1L; |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultTransaction.java
| @@ -36,7 +36,7 @@ | @@ -36,7 +36,7 @@ | ||
| 36 | */ | 36 | */ |
| 37 | package br.gov.frameworkdemoiselle.internal.implementation; | 37 | package br.gov.frameworkdemoiselle.internal.implementation; |
| 38 | 38 | ||
| 39 | -import static br.gov.frameworkdemoiselle.internal.implementation.StrategySelector.CORE_PRIORITY; | 39 | +import static br.gov.frameworkdemoiselle.annotation.Priority.L1_PRIORITY; |
| 40 | import br.gov.frameworkdemoiselle.DemoiselleException; | 40 | import br.gov.frameworkdemoiselle.DemoiselleException; |
| 41 | import br.gov.frameworkdemoiselle.annotation.Priority; | 41 | import br.gov.frameworkdemoiselle.annotation.Priority; |
| 42 | import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | 42 | import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; |
| @@ -50,7 +50,7 @@ import br.gov.frameworkdemoiselle.util.ResourceBundle; | @@ -50,7 +50,7 @@ import br.gov.frameworkdemoiselle.util.ResourceBundle; | ||
| 50 | * @author SERPRO | 50 | * @author SERPRO |
| 51 | * @see Transaction | 51 | * @see Transaction |
| 52 | */ | 52 | */ |
| 53 | -@Priority(CORE_PRIORITY) | 53 | +@Priority(L1_PRIORITY) |
| 54 | public class DefaultTransaction implements Transaction { | 54 | public class DefaultTransaction implements Transaction { |
| 55 | 55 | ||
| 56 | private static final long serialVersionUID = 1L; | 56 | private static final long serialVersionUID = 1L; |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/LoggerMessageAppender.java
0 → 100644
| @@ -0,0 +1,74 @@ | @@ -0,0 +1,74 @@ | ||
| 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.implementation; | ||
| 38 | + | ||
| 39 | +import static br.gov.frameworkdemoiselle.annotation.Priority.L1_PRIORITY; | ||
| 40 | + | ||
| 41 | +import javax.inject.Inject; | ||
| 42 | + | ||
| 43 | +import org.slf4j.Logger; | ||
| 44 | + | ||
| 45 | +import br.gov.frameworkdemoiselle.annotation.Priority; | ||
| 46 | +import br.gov.frameworkdemoiselle.message.Message; | ||
| 47 | +import br.gov.frameworkdemoiselle.message.MessageAppender; | ||
| 48 | + | ||
| 49 | +@Priority(L1_PRIORITY) | ||
| 50 | +public class LoggerMessageAppender implements MessageAppender { | ||
| 51 | + | ||
| 52 | + private static final long serialVersionUID = 1L; | ||
| 53 | + | ||
| 54 | + @Inject | ||
| 55 | + private Logger logger; | ||
| 56 | + | ||
| 57 | + @Override | ||
| 58 | + public void append(Message message) { | ||
| 59 | + String text = message.getText(); | ||
| 60 | + | ||
| 61 | + switch (message.getSeverity()) { | ||
| 62 | + case INFO: | ||
| 63 | + logger.info(text); | ||
| 64 | + break; | ||
| 65 | + | ||
| 66 | + case WARN: | ||
| 67 | + logger.warn(text); | ||
| 68 | + break; | ||
| 69 | + | ||
| 70 | + default: | ||
| 71 | + logger.error(text); | ||
| 72 | + } | ||
| 73 | + } | ||
| 74 | +} |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/MessageContextImpl.java
| @@ -48,8 +48,10 @@ import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; | @@ -48,8 +48,10 @@ import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; | ||
| 48 | import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | 48 | import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; |
| 49 | import br.gov.frameworkdemoiselle.message.DefaultMessage; | 49 | import br.gov.frameworkdemoiselle.message.DefaultMessage; |
| 50 | import br.gov.frameworkdemoiselle.message.Message; | 50 | import br.gov.frameworkdemoiselle.message.Message; |
| 51 | +import br.gov.frameworkdemoiselle.message.MessageAppender; | ||
| 51 | import br.gov.frameworkdemoiselle.message.MessageContext; | 52 | import br.gov.frameworkdemoiselle.message.MessageContext; |
| 52 | import br.gov.frameworkdemoiselle.message.SeverityType; | 53 | import br.gov.frameworkdemoiselle.message.SeverityType; |
| 54 | +import br.gov.frameworkdemoiselle.util.Beans; | ||
| 53 | import br.gov.frameworkdemoiselle.util.ResourceBundle; | 55 | import br.gov.frameworkdemoiselle.util.ResourceBundle; |
| 54 | 56 | ||
| 55 | /** | 57 | /** |
| @@ -79,7 +81,13 @@ public class MessageContextImpl implements Serializable, MessageContext { | @@ -79,7 +81,13 @@ public class MessageContextImpl implements Serializable, MessageContext { | ||
| 79 | } | 81 | } |
| 80 | 82 | ||
| 81 | getLogger().debug(getBundle().getString("adding-message-to-context", message.toString())); | 83 | getLogger().debug(getBundle().getString("adding-message-to-context", message.toString())); |
| 82 | - messages.add(aux); | 84 | + getAppender().append(aux); |
| 85 | + } | ||
| 86 | + | ||
| 87 | + private MessageAppender getAppender() { | ||
| 88 | + Class<? extends MessageAppender> appenderClass = StrategySelector.selectClass(MessageAppender.class); | ||
| 89 | + | ||
| 90 | + return Beans.getReference(appenderClass); | ||
| 83 | } | 91 | } |
| 84 | 92 | ||
| 85 | @Override | 93 | @Override |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/SecurityContextImpl.java
| @@ -42,8 +42,6 @@ import java.security.Principal; | @@ -42,8 +42,6 @@ import java.security.Principal; | ||
| 42 | import javax.inject.Named; | 42 | import javax.inject.Named; |
| 43 | 43 | ||
| 44 | import br.gov.frameworkdemoiselle.DemoiselleException; | 44 | import br.gov.frameworkdemoiselle.DemoiselleException; |
| 45 | -import br.gov.frameworkdemoiselle.internal.bootstrap.AuthenticatorBootstrap; | ||
| 46 | -import br.gov.frameworkdemoiselle.internal.bootstrap.AuthorizerBootstrap; | ||
| 47 | import br.gov.frameworkdemoiselle.internal.configuration.SecurityConfig; | 45 | import br.gov.frameworkdemoiselle.internal.configuration.SecurityConfig; |
| 48 | import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | 46 | import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; |
| 49 | import br.gov.frameworkdemoiselle.security.AfterLoginSuccessful; | 47 | import br.gov.frameworkdemoiselle.security.AfterLoginSuccessful; |
| @@ -74,11 +72,10 @@ public class SecurityContextImpl implements SecurityContext { | @@ -74,11 +72,10 @@ public class SecurityContextImpl implements SecurityContext { | ||
| 74 | 72 | ||
| 75 | private Authenticator getAuthenticator() { | 73 | private Authenticator getAuthenticator() { |
| 76 | if (this.authenticator == null) { | 74 | if (this.authenticator == null) { |
| 77 | - AuthenticatorBootstrap bootstrap = Beans.getReference(AuthenticatorBootstrap.class); | ||
| 78 | Class<? extends Authenticator> clazz = getConfig().getAuthenticatorClass(); | 75 | Class<? extends Authenticator> clazz = getConfig().getAuthenticatorClass(); |
| 79 | 76 | ||
| 80 | if (clazz == null) { | 77 | if (clazz == null) { |
| 81 | - clazz = StrategySelector.selectClass(Authenticator.class, bootstrap.getCache()); | 78 | + clazz = StrategySelector.selectClass(Authenticator.class); |
| 82 | } | 79 | } |
| 83 | 80 | ||
| 84 | this.authenticator = Beans.getReference(clazz); | 81 | this.authenticator = Beans.getReference(clazz); |
| @@ -89,11 +86,10 @@ public class SecurityContextImpl implements SecurityContext { | @@ -89,11 +86,10 @@ public class SecurityContextImpl implements SecurityContext { | ||
| 89 | 86 | ||
| 90 | private Authorizer getAuthorizer() { | 87 | private Authorizer getAuthorizer() { |
| 91 | if (this.authorizer == null) { | 88 | if (this.authorizer == null) { |
| 92 | - AuthorizerBootstrap bootstrap = Beans.getReference(AuthorizerBootstrap.class); | ||
| 93 | Class<? extends Authorizer> clazz = getConfig().getAuthorizerClass(); | 89 | Class<? extends Authorizer> clazz = getConfig().getAuthorizerClass(); |
| 94 | 90 | ||
| 95 | if (clazz == null) { | 91 | if (clazz == null) { |
| 96 | - clazz = StrategySelector.selectClass(Authorizer.class, bootstrap.getCache()); | 92 | + clazz = StrategySelector.selectClass(Authorizer.class); |
| 97 | } | 93 | } |
| 98 | 94 | ||
| 99 | this.authorizer = Beans.getReference(clazz); | 95 | this.authorizer = Beans.getReference(clazz); |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/StrategySelector.java
| @@ -36,32 +36,26 @@ | @@ -36,32 +36,26 @@ | ||
| 36 | */ | 36 | */ |
| 37 | package br.gov.frameworkdemoiselle.internal.implementation; | 37 | package br.gov.frameworkdemoiselle.internal.implementation; |
| 38 | 38 | ||
| 39 | -import static br.gov.frameworkdemoiselle.annotation.Priority.MIN_PRIORITY; | ||
| 40 | - | ||
| 41 | import java.io.Serializable; | 39 | import java.io.Serializable; |
| 42 | import java.util.ArrayList; | 40 | import java.util.ArrayList; |
| 43 | import java.util.Collection; | 41 | import java.util.Collection; |
| 44 | import java.util.HashMap; | 42 | import java.util.HashMap; |
| 43 | +import java.util.HashSet; | ||
| 45 | import java.util.List; | 44 | import java.util.List; |
| 46 | import java.util.Map; | 45 | import java.util.Map; |
| 46 | +import java.util.Set; | ||
| 47 | 47 | ||
| 48 | import javax.enterprise.inject.AmbiguousResolutionException; | 48 | import javax.enterprise.inject.AmbiguousResolutionException; |
| 49 | +import javax.enterprise.inject.spi.Bean; | ||
| 49 | 50 | ||
| 50 | import br.gov.frameworkdemoiselle.DemoiselleException; | 51 | import br.gov.frameworkdemoiselle.DemoiselleException; |
| 51 | import br.gov.frameworkdemoiselle.annotation.Priority; | 52 | import br.gov.frameworkdemoiselle.annotation.Priority; |
| 52 | import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | 53 | import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; |
| 54 | +import br.gov.frameworkdemoiselle.util.Beans; | ||
| 53 | import br.gov.frameworkdemoiselle.util.ResourceBundle; | 55 | import br.gov.frameworkdemoiselle.util.ResourceBundle; |
| 54 | 56 | ||
| 55 | public final class StrategySelector implements Serializable { | 57 | public final class StrategySelector implements Serializable { |
| 56 | 58 | ||
| 57 | - public static final int CORE_PRIORITY = MIN_PRIORITY; | ||
| 58 | - | ||
| 59 | - public static final int EXTENSIONS_L1_PRIORITY = CORE_PRIORITY - 100; | ||
| 60 | - | ||
| 61 | - public static final int EXTENSIONS_L2_PRIORITY = EXTENSIONS_L1_PRIORITY - 100; | ||
| 62 | - | ||
| 63 | - public static final int COMPONENTS_PRIORITY = EXTENSIONS_L2_PRIORITY - 100; | ||
| 64 | - | ||
| 65 | private static final long serialVersionUID = 1L; | 59 | private static final long serialVersionUID = 1L; |
| 66 | 60 | ||
| 67 | private static ResourceBundle bundle; | 61 | private static ResourceBundle bundle; |
| @@ -92,7 +86,7 @@ public final class StrategySelector implements Serializable { | @@ -92,7 +86,7 @@ public final class StrategySelector implements Serializable { | ||
| 92 | return map.get(elected); | 86 | return map.get(elected); |
| 93 | } | 87 | } |
| 94 | 88 | ||
| 95 | - public static <T> Class<? extends T> selectClass(Class<T> type, Collection<Class<? extends T>> options) { | 89 | + private static <T> Class<? extends T> selectClass(Class<T> type, Collection<Class<? extends T>> options) { |
| 96 | Class<? extends T> selected = null; | 90 | Class<? extends T> selected = null; |
| 97 | 91 | ||
| 98 | for (Class<? extends T> option : options) { | 92 | for (Class<? extends T> option : options) { |
| @@ -102,13 +96,28 @@ public final class StrategySelector implements Serializable { | @@ -102,13 +96,28 @@ public final class StrategySelector implements Serializable { | ||
| 102 | } | 96 | } |
| 103 | 97 | ||
| 104 | if (selected != null) { | 98 | if (selected != null) { |
| 105 | - checkForAmbiguity(type, selected, options); | 99 | + performAmbiguityCheck(type, selected, options); |
| 106 | } | 100 | } |
| 107 | 101 | ||
| 108 | return selected; | 102 | return selected; |
| 109 | } | 103 | } |
| 110 | 104 | ||
| 111 | - private static <T> void checkForAmbiguity(Class<T> type, Class<? extends T> selected, | 105 | + public static <T> Class<? extends T> selectClass(Class<T> type) { |
| 106 | + return selectClass(type, getOptions(type)); | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + @SuppressWarnings("unchecked") | ||
| 110 | + private static <T> Collection<Class<? extends T>> getOptions(Class<T> type) { | ||
| 111 | + Set<Class<? extends T>> result = new HashSet<Class<? extends T>>(); | ||
| 112 | + | ||
| 113 | + for (Bean<?> bean : Beans.getBeanManager().getBeans(type)) { | ||
| 114 | + result.add((Class<? extends T>) bean.getBeanClass()); | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + return result; | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + private static <T> void performAmbiguityCheck(Class<T> type, Class<? extends T> selected, | ||
| 112 | Collection<Class<? extends T>> options) { | 121 | Collection<Class<? extends T>> options) { |
| 113 | int selectedPriority = getPriority(selected); | 122 | int selectedPriority = getPriority(selected); |
| 114 | 123 |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/TransactionContextImpl.java
| @@ -38,7 +38,6 @@ package br.gov.frameworkdemoiselle.internal.implementation; | @@ -38,7 +38,6 @@ package br.gov.frameworkdemoiselle.internal.implementation; | ||
| 38 | 38 | ||
| 39 | import javax.inject.Named; | 39 | import javax.inject.Named; |
| 40 | 40 | ||
| 41 | -import br.gov.frameworkdemoiselle.internal.bootstrap.TransactionBootstrap; | ||
| 42 | import br.gov.frameworkdemoiselle.internal.configuration.TransactionConfig; | 41 | import br.gov.frameworkdemoiselle.internal.configuration.TransactionConfig; |
| 43 | import br.gov.frameworkdemoiselle.transaction.Transaction; | 42 | import br.gov.frameworkdemoiselle.transaction.Transaction; |
| 44 | import br.gov.frameworkdemoiselle.transaction.TransactionContext; | 43 | import br.gov.frameworkdemoiselle.transaction.TransactionContext; |
| @@ -56,13 +55,13 @@ public class TransactionContextImpl implements TransactionContext { | @@ -56,13 +55,13 @@ public class TransactionContextImpl implements TransactionContext { | ||
| 56 | 55 | ||
| 57 | private Transaction transaction; | 56 | private Transaction transaction; |
| 58 | 57 | ||
| 59 | - private Transaction getTransaction() { | 58 | + @Override |
| 59 | + public Transaction getCurrentTransaction() { | ||
| 60 | if (this.transaction == null) { | 60 | if (this.transaction == null) { |
| 61 | - TransactionBootstrap bootstrap = Beans.getReference(TransactionBootstrap.class); | ||
| 62 | Class<? extends Transaction> clazz = getConfig().getTransactionClass(); | 61 | Class<? extends Transaction> clazz = getConfig().getTransactionClass(); |
| 63 | 62 | ||
| 64 | if (clazz == null) { | 63 | if (clazz == null) { |
| 65 | - clazz = StrategySelector.selectClass(Transaction.class, bootstrap.getCache()); | 64 | + clazz = StrategySelector.selectClass(Transaction.class); |
| 66 | } | 65 | } |
| 67 | 66 | ||
| 68 | this.transaction = Beans.getReference(clazz); | 67 | this.transaction = Beans.getReference(clazz); |
| @@ -71,11 +70,6 @@ public class TransactionContextImpl implements TransactionContext { | @@ -71,11 +70,6 @@ public class TransactionContextImpl implements TransactionContext { | ||
| 71 | return this.transaction; | 70 | return this.transaction; |
| 72 | } | 71 | } |
| 73 | 72 | ||
| 74 | - @Override | ||
| 75 | - public Transaction getCurrentTransaction() { | ||
| 76 | - return getTransaction(); | ||
| 77 | - } | ||
| 78 | - | ||
| 79 | private TransactionConfig getConfig() { | 73 | private TransactionConfig getConfig() { |
| 80 | return Beans.getReference(TransactionConfig.class); | 74 | return Beans.getReference(TransactionConfig.class); |
| 81 | } | 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,7 +57,7 @@ public class ExceptionHandlerInterceptor extends br.gov.frameworkdemoiselle.exce | ||
| 57 | 57 | ||
| 58 | @Inject | 58 | @Inject |
| 59 | private Logger logger; | 59 | private Logger logger; |
| 60 | - | 60 | + |
| 61 | @Override | 61 | @Override |
| 62 | @AroundInvoke | 62 | @AroundInvoke |
| 63 | public Object manage(InvocationContext ic) throws Exception { | 63 | public Object manage(InvocationContext ic) throws Exception { |
| @@ -65,4 +65,3 @@ public class ExceptionHandlerInterceptor extends br.gov.frameworkdemoiselle.exce | @@ -65,4 +65,3 @@ public class ExceptionHandlerInterceptor extends br.gov.frameworkdemoiselle.exce | ||
| 65 | return super.manage(ic); | 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,12 +61,12 @@ public class Slf4jLoggerProxy implements Logger, Serializable { | ||
| 61 | private transient Logger delegate; | 61 | private transient Logger delegate; |
| 62 | 62 | ||
| 63 | private final Class<?> type; | 63 | private final Class<?> type; |
| 64 | - | 64 | + |
| 65 | private Logger getDelegate() { | 65 | private Logger getDelegate() { |
| 66 | - if(delegate == null) { | 66 | + if (delegate == null) { |
| 67 | delegate = LoggerFactory.getLogger(type); | 67 | delegate = LoggerFactory.getLogger(type); |
| 68 | } | 68 | } |
| 69 | - | 69 | + |
| 70 | return delegate; | 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,34 +42,36 @@ import br.gov.frameworkdemoiselle.internal.management.ManagedType; | ||
| 42 | import br.gov.frameworkdemoiselle.stereotype.ManagementController; | 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 | * @author serpro | 57 | * @author serpro |
| 56 | - * | ||
| 57 | */ | 58 | */ |
| 58 | public interface ManagementExtension { | 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 | void initialize(List<ManagedType> managedTypes); | 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 | void shutdown(List<ManagedType> managedTypes); | 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,17 +48,20 @@ import java.lang.annotation.Target; | ||
| 48 | * Take a look at the following usage sample: | 48 | * Take a look at the following usage sample: |
| 49 | * <p> | 49 | * <p> |
| 50 | * <blockquote> | 50 | * <blockquote> |
| 51 | + * | ||
| 51 | * <pre> | 52 | * <pre> |
| 52 | * public class Finalizer { | 53 | * public class Finalizer { |
| 53 | * | 54 | * |
| 54 | - * @Shutdown | 55 | + * @Shutdown |
| 55 | * @Priority(5) | 56 | * @Priority(5) |
| 56 | * public void finalize() { | 57 | * public void finalize() { |
| 57 | * ... | 58 | * ... |
| 58 | * } | 59 | * } |
| 59 | * } | 60 | * } |
| 60 | * | 61 | * |
| 62 | + * | ||
| 61 | * </pre> | 63 | * </pre> |
| 64 | + * | ||
| 62 | * </blockquote> | 65 | * </blockquote> |
| 63 | * <p> | 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,17 +48,20 @@ import java.lang.annotation.Target; | ||
| 48 | * Take a look at the following usage sample: | 48 | * Take a look at the following usage sample: |
| 49 | * <p> | 49 | * <p> |
| 50 | * <blockquote> | 50 | * <blockquote> |
| 51 | + * | ||
| 51 | * <pre> | 52 | * <pre> |
| 52 | * public class Finalizer { | 53 | * public class Finalizer { |
| 53 | * | 54 | * |
| 54 | - * @Startup | 55 | + * @Startup |
| 55 | * @Priority(1) | 56 | * @Priority(1) |
| 56 | * public void init() { | 57 | * public void init() { |
| 57 | * ... | 58 | * ... |
| 58 | * } | 59 | * } |
| 59 | * } | 60 | * } |
| 60 | * | 61 | * |
| 62 | + * | ||
| 61 | * </pre> | 63 | * </pre> |
| 64 | + * | ||
| 62 | * </blockquote> | 65 | * </blockquote> |
| 63 | * <p> | 66 | * <p> |
| 64 | * | 67 | * |
impl/core/src/main/java/br/gov/frameworkdemoiselle/message/DefaultMessage.java
| @@ -36,8 +36,6 @@ | @@ -36,8 +36,6 @@ | ||
| 36 | */ | 36 | */ |
| 37 | package br.gov.frameworkdemoiselle.message; | 37 | package br.gov.frameworkdemoiselle.message; |
| 38 | 38 | ||
| 39 | -import javax.enterprise.inject.Alternative; | ||
| 40 | - | ||
| 41 | import br.gov.frameworkdemoiselle.util.Beans; | 39 | import br.gov.frameworkdemoiselle.util.Beans; |
| 42 | import br.gov.frameworkdemoiselle.util.ResourceBundle; | 40 | import br.gov.frameworkdemoiselle.util.ResourceBundle; |
| 43 | import br.gov.frameworkdemoiselle.util.Strings; | 41 | import br.gov.frameworkdemoiselle.util.Strings; |
| @@ -45,7 +43,6 @@ import br.gov.frameworkdemoiselle.util.Strings; | @@ -45,7 +43,6 @@ import br.gov.frameworkdemoiselle.util.Strings; | ||
| 45 | /** | 43 | /** |
| 46 | * @author SERPRO | 44 | * @author SERPRO |
| 47 | */ | 45 | */ |
| 48 | -@Alternative | ||
| 49 | public class DefaultMessage implements Message { | 46 | public class DefaultMessage implements Message { |
| 50 | 47 | ||
| 51 | private final String originalText; | 48 | private final String originalText; |
| @@ -65,28 +62,27 @@ public class DefaultMessage implements Message { | @@ -65,28 +62,27 @@ public class DefaultMessage implements Message { | ||
| 65 | this.severity = (severity == null ? DEFAULT_SEVERITY : severity); | 62 | this.severity = (severity == null ? DEFAULT_SEVERITY : severity); |
| 66 | this.params = params; | 63 | this.params = params; |
| 67 | this.bundle = Beans.getReference(ResourceBundle.class); | 64 | this.bundle = Beans.getReference(ResourceBundle.class); |
| 65 | + | ||
| 66 | + initParsedText(); | ||
| 68 | } | 67 | } |
| 69 | 68 | ||
| 70 | public DefaultMessage(String text, Object... params) { | 69 | public DefaultMessage(String text, Object... params) { |
| 71 | this(text, null, (Object[]) params); | 70 | this(text, null, (Object[]) params); |
| 72 | } | 71 | } |
| 73 | 72 | ||
| 74 | - public String getText() { | ||
| 75 | - initParsedText(); | ||
| 76 | - return parsedText; | ||
| 77 | - } | ||
| 78 | - | ||
| 79 | private void initParsedText() { | 73 | private void initParsedText() { |
| 80 | - if (parsedText == null) { | ||
| 81 | - if (Strings.isResourceBundleKeyFormat(originalText)) { | ||
| 82 | - parsedText = bundle.getString(Strings.removeBraces(originalText)); | ||
| 83 | - | ||
| 84 | - } else if (originalText != null) { | ||
| 85 | - parsedText = new String(originalText); | ||
| 86 | - } | 74 | + if (Strings.isResourceBundleKeyFormat(originalText)) { |
| 75 | + parsedText = bundle.getString(Strings.removeBraces(originalText)); | ||
| 87 | 76 | ||
| 88 | - parsedText = Strings.getString(parsedText, params); | 77 | + } else if (originalText != null) { |
| 78 | + parsedText = new String(originalText); | ||
| 89 | } | 79 | } |
| 80 | + | ||
| 81 | + parsedText = Strings.getString(parsedText, params); | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + public String getText() { | ||
| 85 | + return parsedText; | ||
| 90 | } | 86 | } |
| 91 | 87 | ||
| 92 | public SeverityType getSeverity() { | 88 | public SeverityType getSeverity() { |
| @@ -95,7 +91,40 @@ public class DefaultMessage implements Message { | @@ -95,7 +91,40 @@ public class DefaultMessage implements Message { | ||
| 95 | 91 | ||
| 96 | @Override | 92 | @Override |
| 97 | public String toString() { | 93 | public String toString() { |
| 98 | - initParsedText(); | ||
| 99 | return Strings.toString(this); | 94 | return Strings.toString(this); |
| 100 | } | 95 | } |
| 96 | + | ||
| 97 | + @Override | ||
| 98 | + public int hashCode() { | ||
| 99 | + final int prime = 31; | ||
| 100 | + int result = 1; | ||
| 101 | + result = prime * result + ((parsedText == null) ? 0 : parsedText.hashCode()); | ||
| 102 | + result = prime * result + ((severity == null) ? 0 : severity.hashCode()); | ||
| 103 | + return result; | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + @Override | ||
| 107 | + public boolean equals(Object obj) { | ||
| 108 | + if (this == obj) { | ||
| 109 | + return true; | ||
| 110 | + } | ||
| 111 | + if (obj == null) { | ||
| 112 | + return false; | ||
| 113 | + } | ||
| 114 | + if (getClass() != obj.getClass()) { | ||
| 115 | + return false; | ||
| 116 | + } | ||
| 117 | + DefaultMessage other = (DefaultMessage) obj; | ||
| 118 | + if (parsedText == null) { | ||
| 119 | + if (other.parsedText != null) { | ||
| 120 | + return false; | ||
| 121 | + } | ||
| 122 | + } else if (!parsedText.equals(other.parsedText)) { | ||
| 123 | + return false; | ||
| 124 | + } | ||
| 125 | + if (severity != other.severity) { | ||
| 126 | + return false; | ||
| 127 | + } | ||
| 128 | + return true; | ||
| 129 | + } | ||
| 101 | } | 130 | } |
impl/core/src/main/java/br/gov/frameworkdemoiselle/message/MessageAppender.java
0 → 100644
| @@ -0,0 +1,47 @@ | @@ -0,0 +1,47 @@ | ||
| 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.message; | ||
| 38 | + | ||
| 39 | +import java.io.Serializable; | ||
| 40 | + | ||
| 41 | +/** | ||
| 42 | + * @author SERPRO | ||
| 43 | + */ | ||
| 44 | +public interface MessageAppender extends Serializable { | ||
| 45 | + | ||
| 46 | + void append(Message message); | ||
| 47 | +} |
impl/core/src/main/java/br/gov/frameworkdemoiselle/message/MessageContext.java
| @@ -65,11 +65,13 @@ public interface MessageContext { | @@ -65,11 +65,13 @@ public interface MessageContext { | ||
| 65 | /** | 65 | /** |
| 66 | * Returns all messages in the context. | 66 | * Returns all messages in the context. |
| 67 | */ | 67 | */ |
| 68 | + @Deprecated | ||
| 68 | List<Message> getMessages(); | 69 | List<Message> getMessages(); |
| 69 | 70 | ||
| 70 | /** | 71 | /** |
| 71 | * Clears the list of messages in the context. | 72 | * Clears the list of messages in the context. |
| 72 | */ | 73 | */ |
| 74 | + @Deprecated | ||
| 73 | void clear(); | 75 | void clear(); |
| 74 | 76 | ||
| 75 | } | 77 | } |
impl/core/src/main/java/br/gov/frameworkdemoiselle/pagination/Pagination.java
| @@ -88,5 +88,5 @@ public interface Pagination { | @@ -88,5 +88,5 @@ public interface Pagination { | ||
| 88 | * Sets the position for the first record and hence calculates current page according to page size. | 88 | * Sets the position for the first record and hence calculates current page according to page size. |
| 89 | */ | 89 | */ |
| 90 | void setFirstResult(int firstResult); | 90 | void setFirstResult(int firstResult); |
| 91 | - | 91 | + |
| 92 | } | 92 | } |
impl/core/src/main/java/br/gov/frameworkdemoiselle/pagination/PaginationContext.java
| @@ -51,7 +51,8 @@ public interface PaginationContext { | @@ -51,7 +51,8 @@ public interface PaginationContext { | ||
| 51 | /** | 51 | /** |
| 52 | * Retrieves the pagination according to the class type specified. | 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 | * @return Pagination | 56 | * @return Pagination |
| 56 | */ | 57 | */ |
| 57 | Pagination getPagination(Class<?> clazz); | 58 | Pagination getPagination(Class<?> clazz); |
| @@ -60,8 +61,10 @@ public interface PaginationContext { | @@ -60,8 +61,10 @@ public interface PaginationContext { | ||
| 60 | * Retrieves the pagination according to the class type specified. If not existing, creates the pagination whenever | 61 | * Retrieves the pagination according to the class type specified. If not existing, creates the pagination whenever |
| 61 | * {@code create} parameter is true. | 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 | * @return Pagination | 68 | * @return Pagination |
| 66 | */ | 69 | */ |
| 67 | Pagination getPagination(Class<?> clazz, boolean create); | 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,7 +49,8 @@ public interface Authenticator extends Serializable { | ||
| 49 | /** | 49 | /** |
| 50 | * Executes the necessary steps to authenticate an user. | 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 | void authenticate() throws AuthenticationException; | 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,9 +46,8 @@ import javax.interceptor.InvocationContext; | ||
| 46 | import org.slf4j.Logger; | 46 | import org.slf4j.Logger; |
| 47 | 47 | ||
| 48 | import br.gov.frameworkdemoiselle.annotation.Name; | 48 | import br.gov.frameworkdemoiselle.annotation.Name; |
| 49 | -import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; | ||
| 50 | -import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | ||
| 51 | import br.gov.frameworkdemoiselle.util.Beans; | 49 | import br.gov.frameworkdemoiselle.util.Beans; |
| 50 | +import br.gov.frameworkdemoiselle.util.NameQualifier; | ||
| 52 | import br.gov.frameworkdemoiselle.util.ResourceBundle; | 51 | import br.gov.frameworkdemoiselle.util.ResourceBundle; |
| 53 | import br.gov.frameworkdemoiselle.util.Strings; | 52 | import br.gov.frameworkdemoiselle.util.Strings; |
| 54 | 53 | ||
| @@ -63,9 +62,9 @@ public class RequiredPermissionInterceptor implements Serializable { | @@ -63,9 +62,9 @@ public class RequiredPermissionInterceptor implements Serializable { | ||
| 63 | 62 | ||
| 64 | private static final long serialVersionUID = 1L; | 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 | * Gets the values for both resource and operation properties of {@code @RequiredPermission}. Delegates to | 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,7 +167,7 @@ public class RequiredPermissionInterceptor implements Serializable { | ||
| 168 | 167 | ||
| 169 | private static ResourceBundle getBundle() { | 168 | private static ResourceBundle getBundle() { |
| 170 | if (bundle == null) { | 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 | return bundle; | 173 | return bundle; |
| @@ -176,7 +175,7 @@ public class RequiredPermissionInterceptor implements Serializable { | @@ -176,7 +175,7 @@ public class RequiredPermissionInterceptor implements Serializable { | ||
| 176 | 175 | ||
| 177 | private static Logger getLogger() { | 176 | private static Logger getLogger() { |
| 178 | if (logger == null) { | 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 | return logger; | 181 | return logger; |
impl/core/src/main/java/br/gov/frameworkdemoiselle/security/RequiredRoleInterceptor.java
| @@ -47,9 +47,8 @@ import javax.interceptor.InvocationContext; | @@ -47,9 +47,8 @@ import javax.interceptor.InvocationContext; | ||
| 47 | 47 | ||
| 48 | import org.slf4j.Logger; | 48 | import org.slf4j.Logger; |
| 49 | 49 | ||
| 50 | -import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; | ||
| 51 | -import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | ||
| 52 | import br.gov.frameworkdemoiselle.util.Beans; | 50 | import br.gov.frameworkdemoiselle.util.Beans; |
| 51 | +import br.gov.frameworkdemoiselle.util.NameQualifier; | ||
| 53 | import br.gov.frameworkdemoiselle.util.ResourceBundle; | 52 | import br.gov.frameworkdemoiselle.util.ResourceBundle; |
| 54 | 53 | ||
| 55 | /** | 54 | /** |
| @@ -63,9 +62,9 @@ public class RequiredRoleInterceptor implements Serializable { | @@ -63,9 +62,9 @@ public class RequiredRoleInterceptor implements Serializable { | ||
| 63 | 62 | ||
| 64 | private static final long serialVersionUID = 1L; | 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 | * Gets the value property of {@code @RequiredRole}. Delegates to {@code SecurityContext} check role. If the user | 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,7 +101,6 @@ public class RequiredRoleInterceptor implements Serializable { | ||
| 102 | .error(getBundle().getString("does-not-have-role", getSecurityContext().getCurrentUser().getName(), | 101 | .error(getBundle().getString("does-not-have-role", getSecurityContext().getCurrentUser().getName(), |
| 103 | roles)); | 102 | roles)); |
| 104 | 103 | ||
| 105 | - // AuthorizationException a = new AuthorizationException(null); | ||
| 106 | throw new AuthorizationException(getBundle().getString("does-not-have-role-ui", roles)); | 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,7 +137,7 @@ public class RequiredRoleInterceptor implements Serializable { | ||
| 139 | 137 | ||
| 140 | private static ResourceBundle getBundle() { | 138 | private static ResourceBundle getBundle() { |
| 141 | if (bundle == null) { | 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 | return bundle; | 143 | return bundle; |
| @@ -147,7 +145,7 @@ public class RequiredRoleInterceptor implements Serializable { | @@ -147,7 +145,7 @@ public class RequiredRoleInterceptor implements Serializable { | ||
| 147 | 145 | ||
| 148 | private static Logger getLogger() { | 146 | private static Logger getLogger() { |
| 149 | if (logger == null) { | 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 | return logger; | 151 | return logger; |
impl/core/src/main/java/br/gov/frameworkdemoiselle/security/User.java
| @@ -41,7 +41,7 @@ import java.security.Principal; | @@ -41,7 +41,7 @@ import java.security.Principal; | ||
| 41 | 41 | ||
| 42 | /** | 42 | /** |
| 43 | * @author SERPRO | 43 | * @author SERPRO |
| 44 | - * @deprecated | 44 | + * @deprecated |
| 45 | */ | 45 | */ |
| 46 | public interface User extends Principal, Serializable { | 46 | public interface User extends Principal, Serializable { |
| 47 | 47 |
impl/core/src/main/java/br/gov/frameworkdemoiselle/stereotype/ManagementController.java
| @@ -49,17 +49,23 @@ import javax.enterprise.inject.Stereotype; | @@ -49,17 +49,23 @@ import javax.enterprise.inject.Stereotype; | ||
| 49 | import javax.enterprise.util.Nonbinding; | 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 | * <p> | 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 | * to external clients using any technology available. One example is the Demoiselle JMX extension, that will expose | 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 | * @author SERPRO | 70 | * @author SERPRO |
| 65 | */ | 71 | */ |
| @@ -71,7 +77,7 @@ import javax.enterprise.util.Nonbinding; | @@ -71,7 +77,7 @@ import javax.enterprise.util.Nonbinding; | ||
| 71 | @Retention(RUNTIME) | 77 | @Retention(RUNTIME) |
| 72 | @Target({ TYPE }) | 78 | @Target({ TYPE }) |
| 73 | public @interface ManagementController { | 79 | public @interface ManagementController { |
| 74 | - | 80 | + |
| 75 | /** | 81 | /** |
| 76 | * @return Human readable description of this managed class. | 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,16 +43,18 @@ import java.util.List; | ||
| 43 | * Interface containing basic methods for creating, updating and deleting entities (the CRUD design pattern). | 43 | * Interface containing basic methods for creating, updating and deleting entities (the CRUD design pattern). |
| 44 | * | 44 | * |
| 45 | * @author serpro | 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 | public interface Crud<T, I> extends Serializable { | 51 | public interface Crud<T, I> extends Serializable { |
| 51 | 52 | ||
| 52 | /** | 53 | /** |
| 53 | * Find an entity by it's identification attribute and make it transient. | 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 | void delete(I id); | 59 | void delete(I id); |
| 58 | 60 | ||
| @@ -66,24 +68,27 @@ public interface Crud<T, I> extends Serializable { | @@ -66,24 +68,27 @@ public interface Crud<T, I> extends Serializable { | ||
| 66 | /** | 68 | /** |
| 67 | * Insert an entity and return the inserted instance of the entity | 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 | * @return The inserted instance of the entity | 73 | * @return The inserted instance of the entity |
| 71 | */ | 74 | */ |
| 72 | T insert(T bean); | 75 | T insert(T bean); |
| 73 | 76 | ||
| 74 | /** | 77 | /** |
| 75 | * Find an entity's instance by it's identification attribute and return it | 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 | T load(I id); | 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 | * @return The updated entity's instance | 92 | * @return The updated entity's instance |
| 88 | */ | 93 | */ |
| 89 | T update(T bean); | 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,20 +39,15 @@ package br.gov.frameworkdemoiselle.template; | ||
| 39 | import java.util.List; | 39 | import java.util.List; |
| 40 | import java.util.ListIterator; | 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 | import br.gov.frameworkdemoiselle.util.Beans; | 42 | import br.gov.frameworkdemoiselle.util.Beans; |
| 47 | import br.gov.frameworkdemoiselle.util.Reflections; | 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 | * @author serpro | 49 | * @author serpro |
| 54 | - * | ||
| 55 | - * @param <T> | 50 | + * @param <T> |
| 56 | * bean object type | 51 | * bean object type |
| 57 | * @param <I> | 52 | * @param <I> |
| 58 | * bean id type | 53 | * bean id type |
| @@ -75,19 +70,6 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { | @@ -75,19 +70,6 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { | ||
| 75 | */ | 70 | */ |
| 76 | @Override | 71 | @Override |
| 77 | public void delete(final I id) { | 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 | getDelegate().delete(id); | 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,20 +80,8 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { | ||
| 98 | * List of entities identifiers | 80 | * List of entities identifiers |
| 99 | */ | 81 | */ |
| 100 | public void delete(final List<I> ids) { | 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 | ListIterator<I> iter = ids.listIterator(); | 83 | ListIterator<I> iter = ids.listIterator(); |
| 84 | + | ||
| 115 | while (iter.hasNext()) { | 85 | while (iter.hasNext()) { |
| 116 | this.delete(iter.next()); | 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,19 +121,6 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { | ||
| 151 | */ | 121 | */ |
| 152 | @Override | 122 | @Override |
| 153 | public T insert(final T bean) { | 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 | return getDelegate().insert(bean); | 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,24 +142,6 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { | ||
| 185 | */ | 142 | */ |
| 186 | @Override | 143 | @Override |
| 187 | public T update(final T bean) { | 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 | return getDelegate().update(bean); | 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,9 +48,8 @@ import javax.interceptor.InvocationContext; | ||
| 48 | import org.slf4j.Logger; | 48 | import org.slf4j.Logger; |
| 49 | 49 | ||
| 50 | import br.gov.frameworkdemoiselle.exception.ApplicationException; | 50 | import br.gov.frameworkdemoiselle.exception.ApplicationException; |
| 51 | -import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; | ||
| 52 | -import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | ||
| 53 | import br.gov.frameworkdemoiselle.util.Beans; | 51 | import br.gov.frameworkdemoiselle.util.Beans; |
| 52 | +import br.gov.frameworkdemoiselle.util.NameQualifier; | ||
| 54 | import br.gov.frameworkdemoiselle.util.ResourceBundle; | 53 | import br.gov.frameworkdemoiselle.util.ResourceBundle; |
| 55 | 54 | ||
| 56 | @Interceptor | 55 | @Interceptor |
| @@ -63,9 +62,9 @@ public class TransactionalInterceptor implements Serializable { | @@ -63,9 +62,9 @@ public class TransactionalInterceptor implements Serializable { | ||
| 63 | 62 | ||
| 64 | private TransactionInfo transactionInfo; | 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 | private TransactionContext getTransactionContext() { | 69 | private TransactionContext getTransactionContext() { |
| 71 | if (this.transactionContext == null) { | 70 | if (this.transactionContext == null) { |
| @@ -175,7 +174,7 @@ public class TransactionalInterceptor implements Serializable { | @@ -175,7 +174,7 @@ public class TransactionalInterceptor implements Serializable { | ||
| 175 | 174 | ||
| 176 | private static ResourceBundle getBundle() { | 175 | private static ResourceBundle getBundle() { |
| 177 | if (bundle == null) { | 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 | return bundle; | 180 | return bundle; |
| @@ -183,7 +182,7 @@ public class TransactionalInterceptor implements Serializable { | @@ -183,7 +182,7 @@ public class TransactionalInterceptor implements Serializable { | ||
| 183 | 182 | ||
| 184 | private static Logger getLogger() { | 183 | private static Logger getLogger() { |
| 185 | if (logger == null) { | 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 | return logger; | 188 | return logger; |
impl/core/src/main/java/br/gov/frameworkdemoiselle/util/Beans.java
| @@ -37,22 +37,25 @@ | @@ -37,22 +37,25 @@ | ||
| 37 | package br.gov.frameworkdemoiselle.util; | 37 | package br.gov.frameworkdemoiselle.util; |
| 38 | 38 | ||
| 39 | import java.lang.annotation.Annotation; | 39 | import java.lang.annotation.Annotation; |
| 40 | +import java.lang.reflect.Member; | ||
| 40 | import java.lang.reflect.Type; | 41 | import java.lang.reflect.Type; |
| 41 | -import java.util.Locale; | 42 | +import java.util.Arrays; |
| 43 | +import java.util.HashSet; | ||
| 42 | import java.util.NoSuchElementException; | 44 | import java.util.NoSuchElementException; |
| 43 | import java.util.Set; | 45 | import java.util.Set; |
| 44 | 46 | ||
| 45 | import javax.enterprise.context.spi.CreationalContext; | 47 | import javax.enterprise.context.spi.CreationalContext; |
| 48 | +import javax.enterprise.inject.spi.Annotated; | ||
| 46 | import javax.enterprise.inject.spi.Bean; | 49 | import javax.enterprise.inject.spi.Bean; |
| 47 | import javax.enterprise.inject.spi.BeanManager; | 50 | import javax.enterprise.inject.spi.BeanManager; |
| 48 | import javax.enterprise.inject.spi.InjectionPoint; | 51 | import javax.enterprise.inject.spi.InjectionPoint; |
| 49 | 52 | ||
| 50 | import br.gov.frameworkdemoiselle.DemoiselleException; | 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 | public final class Beans { | 55 | public final class Beans { |
| 55 | 56 | ||
| 57 | + private static transient ResourceBundle bundle; | ||
| 58 | + | ||
| 56 | private static BeanManager manager; | 59 | private static BeanManager manager; |
| 57 | 60 | ||
| 58 | private Beans() { | 61 | private Beans() { |
| @@ -132,6 +135,98 @@ public final class Beans { | @@ -132,6 +135,98 @@ public final class Beans { | ||
| 132 | } | 135 | } |
| 133 | 136 | ||
| 134 | private static ResourceBundle getBundle() { | 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/main/java/br/gov/frameworkdemoiselle/util/Reflections.java
| @@ -166,7 +166,7 @@ public final class Reflections { | @@ -166,7 +166,7 @@ public final class Reflections { | ||
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | public static ClassLoader getClassLoaderForResource(final String resource) { | 168 | public static ClassLoader getClassLoaderForResource(final String resource) { |
| 169 | - final String stripped = resource.startsWith("/") ? resource.substring(1) : resource; | 169 | + final String stripped = resource.charAt(0) == '/' ? resource.substring(1) : resource; |
| 170 | 170 | ||
| 171 | URL url = null; | 171 | URL url = null; |
| 172 | ClassLoader result = Thread.currentThread().getContextClassLoader(); | 172 | ClassLoader result = Thread.currentThread().getContextClassLoader(); |
impl/core/src/main/java/br/gov/frameworkdemoiselle/util/Strings.java
| @@ -114,14 +114,14 @@ public final class Strings { | @@ -114,14 +114,14 @@ public final class Strings { | ||
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | result.append(field.getName()); | 116 | result.append(field.getName()); |
| 117 | - result.append("="); | 117 | + result.append('='); |
| 118 | fieldValue = Reflections.getFieldValue(field, object); | 118 | fieldValue = Reflections.getFieldValue(field, object); |
| 119 | result.append(fieldValue != null && fieldValue.getClass().isArray() ? Arrays | 119 | result.append(fieldValue != null && fieldValue.getClass().isArray() ? Arrays |
| 120 | .toString((Object[]) fieldValue) : fieldValue); | 120 | .toString((Object[]) fieldValue) : fieldValue); |
| 121 | } | 121 | } |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | - result.append("]"); | 124 | + result.append(']'); |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | return result.toString(); | 127 | return result.toString(); |
impl/core/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
| 1 | br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap | 1 | br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap |
| 2 | br.gov.frameworkdemoiselle.internal.bootstrap.ConfigurationBootstrap | 2 | br.gov.frameworkdemoiselle.internal.bootstrap.ConfigurationBootstrap |
| 3 | -br.gov.frameworkdemoiselle.internal.bootstrap.TransactionBootstrap | ||
| 4 | -br.gov.frameworkdemoiselle.internal.bootstrap.AuthenticatorBootstrap | ||
| 5 | -br.gov.frameworkdemoiselle.internal.bootstrap.AuthorizerBootstrap | ||
| 6 | br.gov.frameworkdemoiselle.internal.bootstrap.ManagementBootstrap | 3 | br.gov.frameworkdemoiselle.internal.bootstrap.ManagementBootstrap |
| 7 | br.gov.frameworkdemoiselle.internal.bootstrap.StartupBootstrap | 4 | br.gov.frameworkdemoiselle.internal.bootstrap.StartupBootstrap |
| 8 | br.gov.frameworkdemoiselle.internal.bootstrap.ShutdownBootstrap | 5 | br.gov.frameworkdemoiselle.internal.bootstrap.ShutdownBootstrap |
impl/core/src/test/java/configuration/field/beanvalidation/BeanValidationWithEmptyNotNullFieldConfig.java
| @@ -42,14 +42,14 @@ public abstract class BeanValidationWithEmptyNotNullFieldConfig { | @@ -42,14 +42,14 @@ public abstract class BeanValidationWithEmptyNotNullFieldConfig { | ||
| 42 | 42 | ||
| 43 | @NotNull | 43 | @NotNull |
| 44 | private Integer intAttributeNull; | 44 | private Integer intAttributeNull; |
| 45 | - | 45 | + |
| 46 | @NotNull | 46 | @NotNull |
| 47 | private String stringAttributeNull; | 47 | private String stringAttributeNull; |
| 48 | - | 48 | + |
| 49 | public Integer getIntAttributeNull() { | 49 | public Integer getIntAttributeNull() { |
| 50 | return intAttributeNull; | 50 | return intAttributeNull; |
| 51 | } | 51 | } |
| 52 | - | 52 | + |
| 53 | public String getStringAttributeNull() { | 53 | public String getStringAttributeNull() { |
| 54 | return stringAttributeNull; | 54 | return stringAttributeNull; |
| 55 | } | 55 | } |
impl/core/src/test/java/configuration/field/beanvalidation/BeanValidationWithFilledNotNullFieldConfig.java
| @@ -6,14 +6,14 @@ public class BeanValidationWithFilledNotNullFieldConfig { | @@ -6,14 +6,14 @@ public class BeanValidationWithFilledNotNullFieldConfig { | ||
| 6 | 6 | ||
| 7 | @NotNull | 7 | @NotNull |
| 8 | private String stringAttributeNotNull; | 8 | private String stringAttributeNotNull; |
| 9 | - | 9 | + |
| 10 | @NotNull | 10 | @NotNull |
| 11 | private Integer intAttibuteNotNull; | 11 | private Integer intAttibuteNotNull; |
| 12 | - | 12 | + |
| 13 | public String getStringAttributeNotNull() { | 13 | public String getStringAttributeNotNull() { |
| 14 | return stringAttributeNotNull; | 14 | return stringAttributeNotNull; |
| 15 | } | 15 | } |
| 16 | - | 16 | + |
| 17 | public Integer getIntAttibuteNotNull() { | 17 | public Integer getIntAttibuteNotNull() { |
| 18 | return intAttibuteNotNull; | 18 | return intAttibuteNotNull; |
| 19 | } | 19 | } |
impl/core/src/test/java/configuration/field/beanvalidation/ConfigurationBeanValidationFieldTest.java
| @@ -80,7 +80,8 @@ public class ConfigurationBeanValidationFieldTest { | @@ -80,7 +80,8 @@ public class ConfigurationBeanValidationFieldTest { | ||
| 80 | JavaArchive deployment = Tests.createDeployment(ConfigurationBeanValidationFieldTest.class); | 80 | JavaArchive deployment = Tests.createDeployment(ConfigurationBeanValidationFieldTest.class); |
| 81 | deployment.addAsResource(Tests.createFileAsset(PATH + "/demoiselle.properties"), "demoiselle.properties"); | 81 | deployment.addAsResource(Tests.createFileAsset(PATH + "/demoiselle.properties"), "demoiselle.properties"); |
| 82 | deployment.addAsResource(Tests.createFileAsset(PATH + "/demoiselle.xml"), "demoiselle.xml"); | 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 | return deployment; | 86 | return deployment; |
| 86 | } | 87 | } |
| @@ -136,7 +137,7 @@ public class ConfigurationBeanValidationFieldTest { | @@ -136,7 +137,7 @@ public class ConfigurationBeanValidationFieldTest { | ||
| 136 | } | 137 | } |
| 137 | 138 | ||
| 138 | @Test | 139 | @Test |
| 139 | - public void loadPropertiesWithTwoConstraintViolations(){ | 140 | + public void loadPropertiesWithTwoConstraintViolations() { |
| 140 | try { | 141 | try { |
| 141 | propertyWithTwoConstrainViolations.getAttributeWithTwoConstrainValidations(); | 142 | propertyWithTwoConstrainViolations.getAttributeWithTwoConstrainValidations(); |
| 142 | fail(); | 143 | fail(); |
impl/core/src/test/java/configuration/field/clazz/AbstractClassNotFoundFieldConfig.java
| @@ -41,7 +41,7 @@ public abstract class AbstractClassNotFoundFieldConfig { | @@ -41,7 +41,7 @@ public abstract class AbstractClassNotFoundFieldConfig { | ||
| 41 | private Class<MyClass> nonExistentTypedClass; | 41 | private Class<MyClass> nonExistentTypedClass; |
| 42 | 42 | ||
| 43 | private Class<?> nonExistentUntypedClass; | 43 | private Class<?> nonExistentUntypedClass; |
| 44 | - | 44 | + |
| 45 | public Class<MyClass> getNonExistentTypedClass() { | 45 | public Class<MyClass> getNonExistentTypedClass() { |
| 46 | return nonExistentTypedClass; | 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,9 +40,9 @@ import br.gov.frameworkdemoiselle.configuration.Configuration; | ||
| 40 | 40 | ||
| 41 | @Configuration | 41 | @Configuration |
| 42 | public class PropertiesNullClassFieldConfig { | 42 | public class PropertiesNullClassFieldConfig { |
| 43 | - | 43 | + |
| 44 | private Class<MyClass> nullClass; | 44 | private Class<MyClass> nullClass; |
| 45 | - | 45 | + |
| 46 | public Class<MyClass> getNullClass() { | 46 | public Class<MyClass> getNullClass() { |
| 47 | return nullClass; | 47 | return nullClass; |
| 48 | } | 48 | } |
impl/core/src/test/java/configuration/field/map/AbstractMapFieldConfig.java
| @@ -45,7 +45,7 @@ public abstract class AbstractMapFieldConfig { | @@ -45,7 +45,7 @@ public abstract class AbstractMapFieldConfig { | ||
| 45 | private Map<String, String> stringWithUndefinedKeyMap; | 45 | private Map<String, String> stringWithUndefinedKeyMap; |
| 46 | 46 | ||
| 47 | private Map<String, String> emptyValueMap; | 47 | private Map<String, String> emptyValueMap; |
| 48 | - | 48 | + |
| 49 | private Map<String, String> NullMapValue; | 49 | private Map<String, String> NullMapValue; |
| 50 | 50 | ||
| 51 | public Map<String, String> getStringWithUndefinedKeyMap() { | 51 | public Map<String, String> getStringWithUndefinedKeyMap() { |
impl/core/src/test/java/configuration/field/map/ConfigurationMapFieldTest.java
| @@ -99,9 +99,9 @@ public class ConfigurationMapFieldTest { | @@ -99,9 +99,9 @@ public class ConfigurationMapFieldTest { | ||
| 99 | assertEquals(expected, propertiesConfig.getEmptyValueMap()); | 99 | assertEquals(expected, propertiesConfig.getEmptyValueMap()); |
| 100 | assertEquals(expected, xmlConfig.getEmptyValueMap()); | 100 | assertEquals(expected, xmlConfig.getEmptyValueMap()); |
| 101 | } | 101 | } |
| 102 | - | 102 | + |
| 103 | @Test | 103 | @Test |
| 104 | - public void loadNullMap(){ | 104 | + public void loadNullMap() { |
| 105 | assertNull(propertiesConfig.getNullMapValue()); | 105 | assertNull(propertiesConfig.getNullMapValue()); |
| 106 | assertNull(xmlConfig.getNullMapValue()); | 106 | assertNull(xmlConfig.getNullMapValue()); |
| 107 | } | 107 | } |
impl/core/src/test/java/configuration/field/primitiveorwrapper/AbstractPrimitiveOrWrapperErrorFieldConfig.java
| @@ -45,7 +45,7 @@ public abstract class AbstractPrimitiveOrWrapperErrorFieldConfig { | @@ -45,7 +45,7 @@ public abstract class AbstractPrimitiveOrWrapperErrorFieldConfig { | ||
| 45 | private Integer emptyWrappedField; | 45 | private Integer emptyWrappedField; |
| 46 | 46 | ||
| 47 | private Integer conversionErrorWrappedField; | 47 | private Integer conversionErrorWrappedField; |
| 48 | - | 48 | + |
| 49 | public int getEmptyPrimitiveField() { | 49 | public int getEmptyPrimitiveField() { |
| 50 | return emptyPrimitiveField; | 50 | return emptyPrimitiveField; |
| 51 | } | 51 | } |
impl/core/src/test/java/configuration/field/primitiveorwrapper/ConfigurationPrimitiveOrWrapperFieldTest.java
| @@ -78,7 +78,7 @@ public class ConfigurationPrimitiveOrWrapperFieldTest { | @@ -78,7 +78,7 @@ public class ConfigurationPrimitiveOrWrapperFieldTest { | ||
| 78 | 78 | ||
| 79 | @Inject | 79 | @Inject |
| 80 | private PropertiesNullWrappedField nullWrappedField; | 80 | private PropertiesNullWrappedField nullWrappedField; |
| 81 | - | 81 | + |
| 82 | @Deployment | 82 | @Deployment |
| 83 | public static JavaArchive createDeployment() { | 83 | public static JavaArchive createDeployment() { |
| 84 | JavaArchive deployment = Tests.createDeployment(ConfigurationPrimitiveOrWrapperFieldTest.class); | 84 | JavaArchive deployment = Tests.createDeployment(ConfigurationPrimitiveOrWrapperFieldTest.class); |
| @@ -210,9 +210,9 @@ public class ConfigurationPrimitiveOrWrapperFieldTest { | @@ -210,9 +210,9 @@ public class ConfigurationPrimitiveOrWrapperFieldTest { | ||
| 210 | assertEquals(ConversionException.class, cause.getCause().getClass()); | 210 | assertEquals(ConversionException.class, cause.getCause().getClass()); |
| 211 | } | 211 | } |
| 212 | } | 212 | } |
| 213 | - | 213 | + |
| 214 | @Test | 214 | @Test |
| 215 | - public void loadNullWrappedField(){ | 215 | + public void loadNullWrappedField() { |
| 216 | assertNull(nullWrappedField.getNullWrappedField()); | 216 | assertNull(nullWrappedField.getNullWrappedField()); |
| 217 | } | 217 | } |
| 218 | } | 218 | } |
impl/core/src/test/java/configuration/field/primitiveorwrapper/PropertiesNullWrappedField.java
| @@ -6,7 +6,7 @@ import br.gov.frameworkdemoiselle.configuration.Configuration; | @@ -6,7 +6,7 @@ import br.gov.frameworkdemoiselle.configuration.Configuration; | ||
| 6 | public class PropertiesNullWrappedField { | 6 | public class PropertiesNullWrappedField { |
| 7 | 7 | ||
| 8 | private Integer nullWrappedField; | 8 | private Integer nullWrappedField; |
| 9 | - | 9 | + |
| 10 | public Integer getNullWrappedField() { | 10 | public Integer getNullWrappedField() { |
| 11 | return nullWrappedField; | 11 | return nullWrappedField; |
| 12 | } | 12 | } |
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,7 +63,7 @@ public class ConfigurationStringFieldTest { | ||
| 63 | 63 | ||
| 64 | @Inject | 64 | @Inject |
| 65 | private SystemStringFieldConfig systemConfig; | 65 | private SystemStringFieldConfig systemConfig; |
| 66 | - | 66 | + |
| 67 | @Inject | 67 | @Inject |
| 68 | private PropertiesNullStringFieldConfig propertiesNullConfig; | 68 | private PropertiesNullStringFieldConfig propertiesNullConfig; |
| 69 | 69 | ||
| @@ -113,9 +113,9 @@ public class ConfigurationStringFieldTest { | @@ -113,9 +113,9 @@ public class ConfigurationStringFieldTest { | ||
| 113 | assertEquals(expected, propertiesConfig.getEmptyString()); | 113 | assertEquals(expected, propertiesConfig.getEmptyString()); |
| 114 | assertEquals(expected, xmlConfig.getEmptyString()); | 114 | assertEquals(expected, xmlConfig.getEmptyString()); |
| 115 | } | 115 | } |
| 116 | - | 116 | + |
| 117 | @Test | 117 | @Test |
| 118 | - public void loadNullString(){ | 118 | + public void loadNullString() { |
| 119 | assertNull(propertiesNullConfig.getNullString()); | 119 | assertNull(propertiesNullConfig.getNullString()); |
| 120 | assertNull(xmlNullConfig.getNullString()); | 120 | assertNull(xmlNullConfig.getNullString()); |
| 121 | assertNull(systemNullConfig.getNullString()); | 121 | assertNull(systemNullConfig.getNullString()); |
impl/core/src/test/java/exception/basic/ExceptionClassNotAnnotated.java
| @@ -41,7 +41,7 @@ import br.gov.frameworkdemoiselle.exception.ExceptionHandler; | @@ -41,7 +41,7 @@ import br.gov.frameworkdemoiselle.exception.ExceptionHandler; | ||
| 41 | public class ExceptionClassNotAnnotated { | 41 | public class ExceptionClassNotAnnotated { |
| 42 | 42 | ||
| 43 | private boolean nullPointerExceptionHandler = false; | 43 | private boolean nullPointerExceptionHandler = false; |
| 44 | - | 44 | + |
| 45 | public boolean isNullPointerExceptionHandler() { | 45 | public boolean isNullPointerExceptionHandler() { |
| 46 | return nullPointerExceptionHandler; | 46 | return nullPointerExceptionHandler; |
| 47 | } | 47 | } |
impl/core/src/test/java/exception/basic/ExceptionHandlerTest.java
| @@ -64,7 +64,7 @@ public class ExceptionHandlerTest { | @@ -64,7 +64,7 @@ public class ExceptionHandlerTest { | ||
| 64 | 64 | ||
| 65 | @Inject | 65 | @Inject |
| 66 | private ExceptionNested nested; | 66 | private ExceptionNested nested; |
| 67 | - | 67 | + |
| 68 | @Inject | 68 | @Inject |
| 69 | private ExceptionClassNotAnnotated classNotAnnotated; | 69 | private ExceptionClassNotAnnotated classNotAnnotated; |
| 70 | 70 | ||
| @@ -127,7 +127,7 @@ public class ExceptionHandlerTest { | @@ -127,7 +127,7 @@ public class ExceptionHandlerTest { | ||
| 127 | assertEquals(false, nested.isExceptionHandler()); | 127 | assertEquals(false, nested.isExceptionHandler()); |
| 128 | } | 128 | } |
| 129 | } | 129 | } |
| 130 | - | 130 | + |
| 131 | @Test | 131 | @Test |
| 132 | public void exceptionClassNotAnnotatedController() { | 132 | public void exceptionClassNotAnnotatedController() { |
| 133 | try { | 133 | try { |
impl/core/src/test/java/exception/basic/SimpleExceptionHandler.java
| @@ -45,7 +45,7 @@ public class SimpleExceptionHandler { | @@ -45,7 +45,7 @@ public class SimpleExceptionHandler { | ||
| 45 | private boolean nullPointerExceptionHandler = false; | 45 | private boolean nullPointerExceptionHandler = false; |
| 46 | 46 | ||
| 47 | private boolean arithmeticExceptionHandler = false; | 47 | private boolean arithmeticExceptionHandler = false; |
| 48 | - | 48 | + |
| 49 | public boolean isNullPointerExceptionHandler() { | 49 | public boolean isNullPointerExceptionHandler() { |
| 50 | return nullPointerExceptionHandler; | 50 | return nullPointerExceptionHandler; |
| 51 | } | 51 | } |
| @@ -53,7 +53,7 @@ public class SimpleExceptionHandler { | @@ -53,7 +53,7 @@ public class SimpleExceptionHandler { | ||
| 53 | public boolean isArithmeticExceptionHandler() { | 53 | public boolean isArithmeticExceptionHandler() { |
| 54 | return arithmeticExceptionHandler; | 54 | return arithmeticExceptionHandler; |
| 55 | } | 55 | } |
| 56 | - | 56 | + |
| 57 | public void throwNullPointerException() { | 57 | public void throwNullPointerException() { |
| 58 | throw new NullPointerException(); | 58 | throw new NullPointerException(); |
| 59 | } | 59 | } |
| @@ -61,11 +61,11 @@ public class SimpleExceptionHandler { | @@ -61,11 +61,11 @@ public class SimpleExceptionHandler { | ||
| 61 | public void throwArithmeticException() { | 61 | public void throwArithmeticException() { |
| 62 | throw new ArithmeticException(); | 62 | throw new ArithmeticException(); |
| 63 | } | 63 | } |
| 64 | - | 64 | + |
| 65 | public void throwExceptionWithoutHandler() { | 65 | public void throwExceptionWithoutHandler() { |
| 66 | throw new IllegalArgumentException(); | 66 | throw new IllegalArgumentException(); |
| 67 | - } | ||
| 68 | - | 67 | + } |
| 68 | + | ||
| 69 | @SuppressWarnings({ "null", "unused" }) | 69 | @SuppressWarnings({ "null", "unused" }) |
| 70 | public void throwTwoException() { | 70 | public void throwTwoException() { |
| 71 | String txt = null; | 71 | String txt = null; |
| @@ -81,5 +81,5 @@ public class SimpleExceptionHandler { | @@ -81,5 +81,5 @@ public class SimpleExceptionHandler { | ||
| 81 | @ExceptionHandler | 81 | @ExceptionHandler |
| 82 | public void handler(ArithmeticException cause) { | 82 | public void handler(ArithmeticException cause) { |
| 83 | arithmeticExceptionHandler = true; | 83 | arithmeticExceptionHandler = true; |
| 84 | - } | 84 | + } |
| 85 | } | 85 | } |
impl/core/src/test/java/exception/custom/CustomExceptionHandler.java
| @@ -50,12 +50,12 @@ public class CustomExceptionHandler { | @@ -50,12 +50,12 @@ public class CustomExceptionHandler { | ||
| 50 | 50 | ||
| 51 | public void setExceptionHandler(boolean exceptionHandler) { | 51 | public void setExceptionHandler(boolean exceptionHandler) { |
| 52 | this.exceptionHandler = exceptionHandler; | 52 | this.exceptionHandler = exceptionHandler; |
| 53 | - } | ||
| 54 | - | 53 | + } |
| 54 | + | ||
| 55 | public void throwExceptionWithMessage() { | 55 | public void throwExceptionWithMessage() { |
| 56 | throw new CustomException(); | 56 | throw new CustomException(); |
| 57 | } | 57 | } |
| 58 | - | 58 | + |
| 59 | @ExceptionHandler | 59 | @ExceptionHandler |
| 60 | public void handler(CustomException exception) { | 60 | public void handler(CustomException exception) { |
| 61 | setExceptionHandler(true); | 61 | setExceptionHandler(true); |
impl/core/src/test/java/lifecycle/shutdown/priority/ShutdownWithPriority.java
| @@ -51,7 +51,7 @@ import br.gov.frameworkdemoiselle.lifecycle.Shutdown; | @@ -51,7 +51,7 @@ import br.gov.frameworkdemoiselle.lifecycle.Shutdown; | ||
| 51 | public class ShutdownWithPriority { | 51 | public class ShutdownWithPriority { |
| 52 | 52 | ||
| 53 | private List<Integer> listShutdown = new ArrayList<Integer>(); | 53 | private List<Integer> listShutdown = new ArrayList<Integer>(); |
| 54 | - | 54 | + |
| 55 | public List<Integer> getListShutdown() { | 55 | public List<Integer> getListShutdown() { |
| 56 | return listShutdown; | 56 | return listShutdown; |
| 57 | } | 57 | } |
| @@ -67,7 +67,7 @@ public class ShutdownWithPriority { | @@ -67,7 +67,7 @@ public class ShutdownWithPriority { | ||
| 67 | public void unloadWithPriority1() { | 67 | public void unloadWithPriority1() { |
| 68 | listShutdown.add(2); | 68 | listShutdown.add(2); |
| 69 | } | 69 | } |
| 70 | - | 70 | + |
| 71 | @Shutdown | 71 | @Shutdown |
| 72 | @Priority(MAX_PRIORITY) | 72 | @Priority(MAX_PRIORITY) |
| 73 | public void unloadWithMaxPriority() { | 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,11 +47,11 @@ import br.gov.frameworkdemoiselle.lifecycle.Shutdown; | ||
| 47 | public class ShutdownSimple { | 47 | public class ShutdownSimple { |
| 48 | 48 | ||
| 49 | private List<Integer> listShutdown = new ArrayList<Integer>(); | 49 | private List<Integer> listShutdown = new ArrayList<Integer>(); |
| 50 | - | 50 | + |
| 51 | public List<Integer> getListShutdown() { | 51 | public List<Integer> getListShutdown() { |
| 52 | return listShutdown; | 52 | return listShutdown; |
| 53 | } | 53 | } |
| 54 | - | 54 | + |
| 55 | @Shutdown | 55 | @Shutdown |
| 56 | public void unloadWithoutPriorityFirst() { | 56 | public void unloadWithoutPriorityFirst() { |
| 57 | listShutdown.add(3); | 57 | listShutdown.add(3); |
impl/core/src/test/java/lifecycle/startup/priority/StartupWithPriorityTest.java
| @@ -73,7 +73,7 @@ public class StartupWithPriorityTest { | @@ -73,7 +73,7 @@ public class StartupWithPriorityTest { | ||
| 73 | Beans.getBeanManager().fireEvent(new AfterStartupProccess() { | 73 | Beans.getBeanManager().fireEvent(new AfterStartupProccess() { |
| 74 | }); | 74 | }); |
| 75 | } | 75 | } |
| 76 | - | 76 | + |
| 77 | @Test | 77 | @Test |
| 78 | public void startupWithPriority() { | 78 | public void startupWithPriority() { |
| 79 | expected.add(1); | 79 | expected.add(1); |
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,9 +59,9 @@ public class StartupSimpleTest { | ||
| 59 | 59 | ||
| 60 | @Inject | 60 | @Inject |
| 61 | private StartupSimple startupSimple; | 61 | private StartupSimple startupSimple; |
| 62 | - | 62 | + |
| 63 | List<Integer> expected = new ArrayList<Integer>(); | 63 | List<Integer> expected = new ArrayList<Integer>(); |
| 64 | - | 64 | + |
| 65 | @Deployment | 65 | @Deployment |
| 66 | public static JavaArchive createDeployment() { | 66 | public static JavaArchive createDeployment() { |
| 67 | JavaArchive deployment = Tests.createDeployment(StartupSimpleTest.class); | 67 | JavaArchive deployment = Tests.createDeployment(StartupSimpleTest.class); |
| @@ -73,7 +73,7 @@ public class StartupSimpleTest { | @@ -73,7 +73,7 @@ public class StartupSimpleTest { | ||
| 73 | Beans.getBeanManager().fireEvent(new AfterStartupProccess() { | 73 | Beans.getBeanManager().fireEvent(new AfterStartupProccess() { |
| 74 | }); | 74 | }); |
| 75 | } | 75 | } |
| 76 | - | 76 | + |
| 77 | @Test | 77 | @Test |
| 78 | public void startup() { | 78 | public void startup() { |
| 79 | expected.add(1); | 79 | expected.add(1); |
| @@ -83,4 +83,3 @@ public class StartupSimpleTest { | @@ -83,4 +83,3 @@ public class StartupSimpleTest { | ||
| 83 | Assert.assertEquals(expected, startupSimple.getListStartup()); | 83 | Assert.assertEquals(expected, startupSimple.getListStartup()); |
| 84 | } | 84 | } |
| 85 | } | 85 | } |
| 86 | - |
impl/core/src/test/java/message/DummyMessageAppender.java
0 → 100644
| @@ -0,0 +1,62 @@ | @@ -0,0 +1,62 @@ | ||
| 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 message; | ||
| 38 | + | ||
| 39 | +import java.util.ArrayList; | ||
| 40 | +import java.util.List; | ||
| 41 | + | ||
| 42 | +import javax.enterprise.context.RequestScoped; | ||
| 43 | + | ||
| 44 | +import br.gov.frameworkdemoiselle.message.Message; | ||
| 45 | +import br.gov.frameworkdemoiselle.message.MessageAppender; | ||
| 46 | + | ||
| 47 | +@RequestScoped | ||
| 48 | +public class DummyMessageAppender implements MessageAppender { | ||
| 49 | + | ||
| 50 | + private static final long serialVersionUID = 1L; | ||
| 51 | + | ||
| 52 | + private List<Message> messages = new ArrayList<Message>(); | ||
| 53 | + | ||
| 54 | + @Override | ||
| 55 | + public void append(Message message) { | ||
| 56 | + messages.add(message); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + public List<Message> getMessages() { | ||
| 60 | + return messages; | ||
| 61 | + } | ||
| 62 | +} |
impl/core/src/test/java/message/MessageContextTest.java
| 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 | + */ | ||
| 1 | package message; | 37 | package message; |
| 2 | 38 | ||
| 3 | import static junit.framework.Assert.assertEquals; | 39 | import static junit.framework.Assert.assertEquals; |
| @@ -14,7 +50,6 @@ import org.jboss.shrinkwrap.api.spec.JavaArchive; | @@ -14,7 +50,6 @@ import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
| 14 | import org.junit.Test; | 50 | import org.junit.Test; |
| 15 | import org.junit.runner.RunWith; | 51 | import org.junit.runner.RunWith; |
| 16 | 52 | ||
| 17 | -import resourcebundle.parameter.ResourceBundleWithParameter; | ||
| 18 | import test.Tests; | 53 | import test.Tests; |
| 19 | import br.gov.frameworkdemoiselle.internal.context.ContextManager; | 54 | import br.gov.frameworkdemoiselle.internal.context.ContextManager; |
| 20 | import br.gov.frameworkdemoiselle.internal.context.ManagedContext; | 55 | import br.gov.frameworkdemoiselle.internal.context.ManagedContext; |
| @@ -34,7 +69,7 @@ public class MessageContextTest { | @@ -34,7 +69,7 @@ public class MessageContextTest { | ||
| 34 | private MessageWithResourceBundle bundleCustom; | 69 | private MessageWithResourceBundle bundleCustom; |
| 35 | 70 | ||
| 36 | private static final String PATH = "src/test/resources/message/"; | 71 | private static final String PATH = "src/test/resources/message/"; |
| 37 | - | 72 | + |
| 38 | @Deployment | 73 | @Deployment |
| 39 | public static JavaArchive createDeployment() { | 74 | public static JavaArchive createDeployment() { |
| 40 | JavaArchive deployment = Tests.createDeployment(MessageContextTest.class); | 75 | JavaArchive deployment = Tests.createDeployment(MessageContextTest.class); |
| @@ -47,8 +82,10 @@ public class MessageContextTest { | @@ -47,8 +82,10 @@ public class MessageContextTest { | ||
| 47 | public void testAddMessageWithoutParams() { | 82 | public void testAddMessageWithoutParams() { |
| 48 | ContextManager.activate(ManagedContext.class, RequestScoped.class); | 83 | ContextManager.activate(ManagedContext.class, RequestScoped.class); |
| 49 | Message message = new DefaultMessage("Menssage without param"); | 84 | Message message = new DefaultMessage("Menssage without param"); |
| 85 | + DummyMessageAppender appender = Beans.getReference(DummyMessageAppender.class); | ||
| 86 | + | ||
| 50 | messageContext.add(message); | 87 | messageContext.add(message); |
| 51 | - assertEquals(messageContext.getMessages().size(), 1); | 88 | + assertEquals(appender.getMessages().size(), 1); |
| 52 | ContextManager.deactivate(ManagedContext.class, RequestScoped.class); | 89 | ContextManager.deactivate(ManagedContext.class, RequestScoped.class); |
| 53 | } | 90 | } |
| 54 | 91 | ||
| @@ -56,8 +93,10 @@ public class MessageContextTest { | @@ -56,8 +93,10 @@ public class MessageContextTest { | ||
| 56 | public void testAddMessageWithoutParamsIfSeverityIsInfo() { | 93 | public void testAddMessageWithoutParamsIfSeverityIsInfo() { |
| 57 | ContextManager.activate(ManagedContext.class, RequestScoped.class); | 94 | ContextManager.activate(ManagedContext.class, RequestScoped.class); |
| 58 | Message message = new DefaultMessage("Menssage without param"); | 95 | Message message = new DefaultMessage("Menssage without param"); |
| 96 | + DummyMessageAppender appender = Beans.getReference(DummyMessageAppender.class); | ||
| 97 | + | ||
| 59 | messageContext.add(message); | 98 | messageContext.add(message); |
| 60 | - assertEquals(messageContext.getMessages().get(0).getSeverity(), SeverityType.INFO); | 99 | + assertEquals(appender.getMessages().get(0).getSeverity(), SeverityType.INFO); |
| 61 | ContextManager.deactivate(ManagedContext.class, RequestScoped.class); | 100 | ContextManager.deactivate(ManagedContext.class, RequestScoped.class); |
| 62 | } | 101 | } |
| 63 | 102 | ||
| @@ -65,8 +104,10 @@ public class MessageContextTest { | @@ -65,8 +104,10 @@ public class MessageContextTest { | ||
| 65 | public void testAddMessageWitSeverityInfo() { | 104 | public void testAddMessageWitSeverityInfo() { |
| 66 | ContextManager.activate(ManagedContext.class, RequestScoped.class); | 105 | ContextManager.activate(ManagedContext.class, RequestScoped.class); |
| 67 | Message message = new DefaultMessage("Menssage without param", SeverityType.INFO); | 106 | Message message = new DefaultMessage("Menssage without param", SeverityType.INFO); |
| 107 | + DummyMessageAppender appender = Beans.getReference(DummyMessageAppender.class); | ||
| 108 | + | ||
| 68 | messageContext.add(message); | 109 | messageContext.add(message); |
| 69 | - assertEquals(messageContext.getMessages().get(0).getSeverity(), SeverityType.INFO); | 110 | + assertEquals(appender.getMessages().get(0).getSeverity(), SeverityType.INFO); |
| 70 | ContextManager.deactivate(ManagedContext.class, RequestScoped.class); | 111 | ContextManager.deactivate(ManagedContext.class, RequestScoped.class); |
| 71 | } | 112 | } |
| 72 | 113 | ||
| @@ -74,28 +115,21 @@ public class MessageContextTest { | @@ -74,28 +115,21 @@ public class MessageContextTest { | ||
| 74 | public void testAddMessageWitSeverityWarn() { | 115 | public void testAddMessageWitSeverityWarn() { |
| 75 | ContextManager.activate(ManagedContext.class, RequestScoped.class); | 116 | ContextManager.activate(ManagedContext.class, RequestScoped.class); |
| 76 | Message message = new DefaultMessage("Menssage without param", SeverityType.WARN); | 117 | Message message = new DefaultMessage("Menssage without param", SeverityType.WARN); |
| 118 | + DummyMessageAppender appender = Beans.getReference(DummyMessageAppender.class); | ||
| 119 | + | ||
| 77 | messageContext.add(message); | 120 | messageContext.add(message); |
| 78 | - assertEquals(messageContext.getMessages().get(0).getSeverity(), SeverityType.WARN); | 121 | + assertEquals(appender.getMessages().get(0).getSeverity(), SeverityType.WARN); |
| 79 | ContextManager.deactivate(ManagedContext.class, RequestScoped.class); | 122 | ContextManager.deactivate(ManagedContext.class, RequestScoped.class); |
| 80 | } | 123 | } |
| 81 | - | 124 | + |
| 82 | @Test | 125 | @Test |
| 83 | public void testAddMessageWitSeverityErro() { | 126 | public void testAddMessageWitSeverityErro() { |
| 84 | ContextManager.activate(ManagedContext.class, RequestScoped.class); | 127 | ContextManager.activate(ManagedContext.class, RequestScoped.class); |
| 85 | Message message = new DefaultMessage("Menssage without param", SeverityType.ERROR); | 128 | Message message = new DefaultMessage("Menssage without param", SeverityType.ERROR); |
| 129 | + DummyMessageAppender appender = Beans.getReference(DummyMessageAppender.class); | ||
| 130 | + | ||
| 86 | messageContext.add(message); | 131 | messageContext.add(message); |
| 87 | - assertEquals(messageContext.getMessages().get(0).getSeverity(), SeverityType.ERROR); | ||
| 88 | - ContextManager.deactivate(ManagedContext.class, RequestScoped.class); | ||
| 89 | - } | ||
| 90 | - | ||
| 91 | - @Test | ||
| 92 | - public void testCleanMessageContext() { | ||
| 93 | - ContextManager.activate(ManagedContext.class, RequestScoped.class); | ||
| 94 | - Message message = new DefaultMessage("Menssage without param"); | ||
| 95 | - messageContext.add(message); | ||
| 96 | - assertEquals(messageContext.getMessages().size(), 1); | ||
| 97 | - messageContext.clear(); | ||
| 98 | - assertEquals(messageContext.getMessages().size(), 0); | 132 | + assertEquals(appender.getMessages().get(0).getSeverity(), SeverityType.ERROR); |
| 99 | ContextManager.deactivate(ManagedContext.class, RequestScoped.class); | 133 | ContextManager.deactivate(ManagedContext.class, RequestScoped.class); |
| 100 | } | 134 | } |
| 101 | 135 | ||
| @@ -103,11 +137,13 @@ public class MessageContextTest { | @@ -103,11 +137,13 @@ public class MessageContextTest { | ||
| 103 | public void testRecoverMessageWithParams() { | 137 | public void testRecoverMessageWithParams() { |
| 104 | ContextManager.activate(ManagedContext.class, RequestScoped.class); | 138 | ContextManager.activate(ManagedContext.class, RequestScoped.class); |
| 105 | Message message = new DefaultMessage("Message with {0} param"); | 139 | Message message = new DefaultMessage("Message with {0} param"); |
| 140 | + DummyMessageAppender appender = Beans.getReference(DummyMessageAppender.class); | ||
| 141 | + | ||
| 106 | messageContext.add(message, 1); | 142 | messageContext.add(message, 1); |
| 107 | - assertTrue(messageContext.getMessages().get(0).getText().equals("Message with 1 param")); | 143 | + assertTrue(appender.getMessages().get(0).getText().equals("Message with 1 param")); |
| 108 | ContextManager.deactivate(ManagedContext.class, RequestScoped.class); | 144 | ContextManager.deactivate(ManagedContext.class, RequestScoped.class); |
| 109 | } | 145 | } |
| 110 | - | 146 | + |
| 111 | @Test | 147 | @Test |
| 112 | public void testMessageWithResourceBundle() { | 148 | public void testMessageWithResourceBundle() { |
| 113 | bundleCustom = Beans.getReference(MessageWithResourceBundle.class); | 149 | bundleCustom = Beans.getReference(MessageWithResourceBundle.class); |
| @@ -115,9 +151,9 @@ public class MessageContextTest { | @@ -115,9 +151,9 @@ public class MessageContextTest { | ||
| 115 | String value = bundleCustom.getBundle().getString("MESSAGE_WITHOUT_PARAMETER"); | 151 | String value = bundleCustom.getBundle().getString("MESSAGE_WITHOUT_PARAMETER"); |
| 116 | Assert.assertEquals(expected, value); | 152 | Assert.assertEquals(expected, value); |
| 117 | } | 153 | } |
| 118 | - | 154 | + |
| 119 | @Test | 155 | @Test |
| 120 | - public void testMessageParsedText(){ | 156 | + public void testMessageParsedText() { |
| 121 | ContextManager.activate(ManagedContext.class, RequestScoped.class); | 157 | ContextManager.activate(ManagedContext.class, RequestScoped.class); |
| 122 | Message MESSAGE_PARSED = new DefaultMessage("{MESSAGE_PARSED}"); | 158 | Message MESSAGE_PARSED = new DefaultMessage("{MESSAGE_PARSED}"); |
| 123 | String expected = "Message parsed"; | 159 | String expected = "Message parsed"; |
| @@ -125,9 +161,9 @@ public class MessageContextTest { | @@ -125,9 +161,9 @@ public class MessageContextTest { | ||
| 125 | Assert.assertEquals(expected, value); | 161 | Assert.assertEquals(expected, value); |
| 126 | ContextManager.deactivate(ManagedContext.class, RequestScoped.class); | 162 | ContextManager.deactivate(ManagedContext.class, RequestScoped.class); |
| 127 | } | 163 | } |
| 128 | - | 164 | + |
| 129 | @Test | 165 | @Test |
| 130 | - public void testMessageIsNull(){ | 166 | + public void testMessageIsNull() { |
| 131 | ContextManager.activate(ManagedContext.class, RequestScoped.class); | 167 | ContextManager.activate(ManagedContext.class, RequestScoped.class); |
| 132 | Message NULL_MESSAGE = new DefaultMessage(null); | 168 | Message NULL_MESSAGE = new DefaultMessage(null); |
| 133 | String expected = null; | 169 | String expected = null; |
| @@ -135,5 +171,4 @@ public class MessageContextTest { | @@ -135,5 +171,4 @@ public class MessageContextTest { | ||
| 135 | Assert.assertEquals(expected, value); | 171 | Assert.assertEquals(expected, value); |
| 136 | ContextManager.deactivate(ManagedContext.class, RequestScoped.class); | 172 | ContextManager.deactivate(ManagedContext.class, RequestScoped.class); |
| 137 | } | 173 | } |
| 138 | - | ||
| 139 | } | 174 | } |
impl/core/src/test/java/message/MessageWithResourceBundle.java
| 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 | + */ | ||
| 1 | package message; | 37 | package message; |
| 2 | 38 | ||
| 3 | import javax.inject.Inject; | 39 | import javax.inject.Inject; |
| 4 | 40 | ||
| 5 | import br.gov.frameworkdemoiselle.util.ResourceBundle; | 41 | import br.gov.frameworkdemoiselle.util.ResourceBundle; |
| 6 | 42 | ||
| 7 | -public class MessageWithResourceBundle{ | 43 | +public class MessageWithResourceBundle { |
| 8 | 44 | ||
| 9 | @Inject | 45 | @Inject |
| 10 | private ResourceBundle bundle; | 46 | private ResourceBundle bundle; |
impl/core/src/test/java/resourcebundle/file/defaultfile/ResourceBundleDefaultTest.java
| @@ -67,23 +67,23 @@ public class ResourceBundleDefaultTest { | @@ -67,23 +67,23 @@ public class ResourceBundleDefaultTest { | ||
| 67 | 67 | ||
| 68 | @Test | 68 | @Test |
| 69 | public void loadResourceDefault() { | 69 | public void loadResourceDefault() { |
| 70 | - Locale.setDefault(new Locale("pt", "BR")); | 70 | + Locale.setDefault(new Locale("pt", "BR")); |
| 71 | bundleDefault = Beans.getReference(ResourceBundleDefault.class); | 71 | bundleDefault = Beans.getReference(ResourceBundleDefault.class); |
| 72 | Assert.assertEquals("mensagem em Portugues", bundleDefault.getMessage()); | 72 | Assert.assertEquals("mensagem em Portugues", bundleDefault.getMessage()); |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | @Test | 75 | @Test |
| 76 | public void loadResourceDefaultEnglish() { | 76 | public void loadResourceDefaultEnglish() { |
| 77 | - Locale.setDefault(Locale.US); | 77 | + Locale.setDefault(Locale.US); |
| 78 | bundleDefault = Beans.getReference(ResourceBundleDefault.class); | 78 | bundleDefault = Beans.getReference(ResourceBundleDefault.class); |
| 79 | Assert.assertEquals("message in English", bundleDefault.getMessage()); | 79 | Assert.assertEquals("message in English", bundleDefault.getMessage()); |
| 80 | } | 80 | } |
| 81 | - | 81 | + |
| 82 | @Test | 82 | @Test |
| 83 | public void loadResourceWithLocaleNotExist() { | 83 | public void loadResourceWithLocaleNotExist() { |
| 84 | Locale.setDefault(Locale.ITALY); | 84 | Locale.setDefault(Locale.ITALY); |
| 85 | bundleDefault = Beans.getReference(ResourceBundleDefault.class); | 85 | bundleDefault = Beans.getReference(ResourceBundleDefault.class); |
| 86 | Assert.assertEquals("mensagem em Portugues", bundleDefault.getMessage()); | 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,7 +77,7 @@ public class ResourceBundleWithParameterTest { | ||
| 77 | String value = bundleCustom.getBundle().getString("messageTwoParameter", "1", "2"); | 77 | String value = bundleCustom.getBundle().getString("messageTwoParameter", "1", "2"); |
| 78 | Assert.assertEquals(expected, value); | 78 | Assert.assertEquals(expected, value); |
| 79 | } | 79 | } |
| 80 | - | 80 | + |
| 81 | @Test | 81 | @Test |
| 82 | public void loadKeyWithoutParameter() { | 82 | public void loadKeyWithoutParameter() { |
| 83 | bundleCustom = Beans.getReference(ResourceBundleWithParameter.class); | 83 | bundleCustom = Beans.getReference(ResourceBundleWithParameter.class); |
| @@ -85,15 +85,15 @@ public class ResourceBundleWithParameterTest { | @@ -85,15 +85,15 @@ public class ResourceBundleWithParameterTest { | ||
| 85 | String value = bundleCustom.getBundle().getString("messageWithoutParameter", "1", "2", "3"); | 85 | String value = bundleCustom.getBundle().getString("messageWithoutParameter", "1", "2", "3"); |
| 86 | Assert.assertEquals(expected, value); | 86 | Assert.assertEquals(expected, value); |
| 87 | } | 87 | } |
| 88 | - | 88 | + |
| 89 | @Test | 89 | @Test |
| 90 | public void loadKeyWithStringParameter() { | 90 | public void loadKeyWithStringParameter() { |
| 91 | bundleCustom = Beans.getReference(ResourceBundleWithParameter.class); | 91 | bundleCustom = Beans.getReference(ResourceBundleWithParameter.class); |
| 92 | String expected = "Mensagem número 1"; | 92 | String expected = "Mensagem número 1"; |
| 93 | String value = bundleCustom.getBundle().getString("messageParameterString", "1"); | 93 | String value = bundleCustom.getBundle().getString("messageParameterString", "1"); |
| 94 | Assert.assertNotSame(expected, value); | 94 | Assert.assertNotSame(expected, value); |
| 95 | - | ||
| 96 | - expected = "Mensagem número {numero}"; | 95 | + |
| 96 | + expected = "Mensagem número {numero}"; | ||
| 97 | Assert.assertEquals(expected, value); | 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,24 +83,24 @@ public class CustomAuthenticatorTest { | ||
| 83 | @Test | 83 | @Test |
| 84 | public void loginProcess() { | 84 | public void loginProcess() { |
| 85 | ContextManager.activate(ThreadLocalContext.class, RequestScoped.class); | 85 | ContextManager.activate(ThreadLocalContext.class, RequestScoped.class); |
| 86 | - | 86 | + |
| 87 | context.login(); | 87 | context.login(); |
| 88 | assertTrue(context.isLoggedIn()); | 88 | assertTrue(context.isLoggedIn()); |
| 89 | assertNotNull(observer.getEvent()); | 89 | assertNotNull(observer.getEvent()); |
| 90 | assertEquals("demoiselle", context.getCurrentUser().getName()); | 90 | assertEquals("demoiselle", context.getCurrentUser().getName()); |
| 91 | - | 91 | + |
| 92 | ContextManager.deactivate(ThreadLocalContext.class, RequestScoped.class); | 92 | ContextManager.deactivate(ThreadLocalContext.class, RequestScoped.class); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | @Test | 95 | @Test |
| 96 | public void logoutProcess() { | 96 | public void logoutProcess() { |
| 97 | ContextManager.activate(ThreadLocalContext.class, RequestScoped.class); | 97 | ContextManager.activate(ThreadLocalContext.class, RequestScoped.class); |
| 98 | - | 98 | + |
| 99 | context.login(); | 99 | context.login(); |
| 100 | context.logout(); | 100 | context.logout(); |
| 101 | assertFalse(context.isLoggedIn()); | 101 | assertFalse(context.isLoggedIn()); |
| 102 | assertNull(context.getCurrentUser()); | 102 | assertNull(context.getCurrentUser()); |
| 103 | - | 103 | + |
| 104 | ContextManager.deactivate(ThreadLocalContext.class, RequestScoped.class); | 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,7 +47,7 @@ public final class Tests { | ||
| 47 | private Tests() { | 47 | private Tests() { |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | - public static JavaArchive createDeployment(Class<?> baseClass) { | 50 | + public static JavaArchive createDeployment(final Class<?> baseClass) { |
| 51 | return createDeployment().addPackages(true, baseClass.getPackage()); | 51 | return createDeployment().addPackages(true, baseClass.getPackage()); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| @@ -62,7 +62,7 @@ public final class Tests { | @@ -62,7 +62,7 @@ public final class Tests { | ||
| 62 | "services/javax.enterprise.inject.spi.Extension"); | 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 | return new FileAsset(new File(pathname)); | 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,7 +41,7 @@ import br.gov.frameworkdemoiselle.transaction.Transaction; | ||
| 41 | public class DummyStrategy implements Transaction { | 41 | public class DummyStrategy implements Transaction { |
| 42 | 42 | ||
| 43 | private static final long serialVersionUID = 1L; | 43 | private static final long serialVersionUID = 1L; |
| 44 | - | 44 | + |
| 45 | private boolean markedRollback = false; | 45 | private boolean markedRollback = false; |
| 46 | 46 | ||
| 47 | private boolean active = false; | 47 | private boolean active = false; |
impl/core/src/test/java/transaction/rollback/TransactionManager.java
| @@ -97,35 +97,35 @@ public class TransactionManager { | @@ -97,35 +97,35 @@ public class TransactionManager { | ||
| 97 | return transactionPassedInSetRollbackOnlyMethod; | 97 | return transactionPassedInSetRollbackOnlyMethod; |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | - public static void setTransactionMarkedRollback(boolean markedRollback) { | 100 | + public static void setTransactionMarkedRollback(final boolean markedRollback) { |
| 101 | transactionMarkedRollback = markedRollback; | 101 | transactionMarkedRollback = markedRollback; |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | - public static void setTransactionActive(boolean active) { | 104 | + public static void setTransactionActive(final boolean active) { |
| 105 | transactionActive = active; | 105 | transactionActive = active; |
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | - public static void setTransactionPassedInIsActiveMethod(boolean passedInIsActiveMethod) { | 108 | + public static void setTransactionPassedInIsActiveMethod(final boolean passedInIsActiveMethod) { |
| 109 | transactionPassedInIsActiveMethod = passedInIsActiveMethod; | 109 | transactionPassedInIsActiveMethod = passedInIsActiveMethod; |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | - public static void setTransactionPassedInIsMarkedRollbackMethod(boolean passedInIsMarkedRollbackMethod) { | 112 | + public static void setTransactionPassedInIsMarkedRollbackMethod(final boolean passedInIsMarkedRollbackMethod) { |
| 113 | transactionPassedInIsMarkedRollbackMethod = passedInIsMarkedRollbackMethod; | 113 | transactionPassedInIsMarkedRollbackMethod = passedInIsMarkedRollbackMethod; |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | - public static void setTransactionPassedInBeginMethod(boolean passedInBeginMethod) { | 116 | + public static void setTransactionPassedInBeginMethod(final boolean passedInBeginMethod) { |
| 117 | transactionPassedInBeginMethod = passedInBeginMethod; | 117 | transactionPassedInBeginMethod = passedInBeginMethod; |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | - public static void setTransactionPassedInCommitMethod(boolean passedInCommitMethod) { | 120 | + public static void setTransactionPassedInCommitMethod(final boolean passedInCommitMethod) { |
| 121 | transactionPassedInCommitMethod = passedInCommitMethod; | 121 | transactionPassedInCommitMethod = passedInCommitMethod; |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | - public static void setTransactionPassedInRollbackMethod(boolean passedInRollbackMethod) { | 124 | + public static void setTransactionPassedInRollbackMethod(final boolean passedInRollbackMethod) { |
| 125 | transactionPassedInRollbackMethod = passedInRollbackMethod; | 125 | transactionPassedInRollbackMethod = passedInRollbackMethod; |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | - public static void setTransactionPassedInSetRollbackOnlyMethod(boolean passedInSetRollbackOnlyMethod) { | 128 | + public static void setTransactionPassedInSetRollbackOnlyMethod(final boolean passedInSetRollbackOnlyMethod) { |
| 129 | transactionPassedInSetRollbackOnlyMethod = passedInSetRollbackOnlyMethod; | 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,8 +41,8 @@ import br.gov.frameworkdemoiselle.stereotype.Controller; | ||
| 41 | import br.gov.frameworkdemoiselle.transaction.Transactional; | 41 | import br.gov.frameworkdemoiselle.transaction.Transactional; |
| 42 | 42 | ||
| 43 | @Controller | 43 | @Controller |
| 44 | -public class TransactionManagerWithDefaultRollback extends TransactionManager{ | ||
| 45 | - | 44 | +public class TransactionManagerWithDefaultRollback extends TransactionManager { |
| 45 | + | ||
| 46 | @Transactional | 46 | @Transactional |
| 47 | public void insert() { | 47 | public void insert() { |
| 48 | throw new TransactionExceptionWithDefaultRollback(); | 48 | throw new TransactionExceptionWithDefaultRollback(); |
impl/core/src/test/java/transaction/rollback/TransactionManagerWithRollback.java
| @@ -41,7 +41,7 @@ import br.gov.frameworkdemoiselle.stereotype.Controller; | @@ -41,7 +41,7 @@ import br.gov.frameworkdemoiselle.stereotype.Controller; | ||
| 41 | import br.gov.frameworkdemoiselle.transaction.Transactional; | 41 | import br.gov.frameworkdemoiselle.transaction.Transactional; |
| 42 | 42 | ||
| 43 | @Controller | 43 | @Controller |
| 44 | -public class TransactionManagerWithRollback extends TransactionManager{ | 44 | +public class TransactionManagerWithRollback extends TransactionManager { |
| 45 | 45 | ||
| 46 | @Transactional | 46 | @Transactional |
| 47 | public void insert() { | 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,16 +58,16 @@ import br.gov.frameworkdemoiselle.internal.context.ManagedContext; | ||
| 58 | 58 | ||
| 59 | @RunWith(Arquillian.class) | 59 | @RunWith(Arquillian.class) |
| 60 | public class TransactionRollbackTest { | 60 | public class TransactionRollbackTest { |
| 61 | - | 61 | + |
| 62 | @Inject | 62 | @Inject |
| 63 | private TransactionManagerWithDefaultRollback managerWithDefaultRollback; | 63 | private TransactionManagerWithDefaultRollback managerWithDefaultRollback; |
| 64 | - | 64 | + |
| 65 | @Inject | 65 | @Inject |
| 66 | private TransactionManagerWithRollback managerWithRollback; | 66 | private TransactionManagerWithRollback managerWithRollback; |
| 67 | - | 67 | + |
| 68 | @Inject | 68 | @Inject |
| 69 | private TransactionManagerWithoutRollback managerWithoutRollback; | 69 | private TransactionManagerWithoutRollback managerWithoutRollback; |
| 70 | - | 70 | + |
| 71 | @Deployment | 71 | @Deployment |
| 72 | public static JavaArchive createDeployment() { | 72 | public static JavaArchive createDeployment() { |
| 73 | JavaArchive deployment = Tests.createDeployment(TransactionRollbackTest.class); | 73 | JavaArchive deployment = Tests.createDeployment(TransactionRollbackTest.class); |
| @@ -78,19 +78,19 @@ public class TransactionRollbackTest { | @@ -78,19 +78,19 @@ public class TransactionRollbackTest { | ||
| 78 | public void activeContext() { | 78 | public void activeContext() { |
| 79 | ContextManager.activate(ManagedContext.class, RequestScoped.class); | 79 | ContextManager.activate(ManagedContext.class, RequestScoped.class); |
| 80 | } | 80 | } |
| 81 | - | 81 | + |
| 82 | @After | 82 | @After |
| 83 | - public void deactiveContext(){ | 83 | + public void deactiveContext() { |
| 84 | ContextManager.deactivate(ManagedContext.class, RequestScoped.class); | 84 | ContextManager.deactivate(ManagedContext.class, RequestScoped.class); |
| 85 | } | 85 | } |
| 86 | - | 86 | + |
| 87 | @Test | 87 | @Test |
| 88 | - public void transactionWithDefaultRollback(){ | ||
| 89 | - try{ | 88 | + public void transactionWithDefaultRollback() { |
| 89 | + try { | ||
| 90 | managerWithDefaultRollback.clean(); | 90 | managerWithDefaultRollback.clean(); |
| 91 | managerWithDefaultRollback.insert(); | 91 | managerWithDefaultRollback.insert(); |
| 92 | fail(); | 92 | fail(); |
| 93 | - }catch(TransactionExceptionWithDefaultRollback exception){ | 93 | + } catch (TransactionExceptionWithDefaultRollback exception) { |
| 94 | assertTrue(managerWithDefaultRollback.isTransactionPassedInIsActiveMethod()); | 94 | assertTrue(managerWithDefaultRollback.isTransactionPassedInIsActiveMethod()); |
| 95 | assertTrue(managerWithDefaultRollback.isTransactionPassedInBeginMethod()); | 95 | assertTrue(managerWithDefaultRollback.isTransactionPassedInBeginMethod()); |
| 96 | assertTrue(managerWithDefaultRollback.isTransactionMarkedRollback()); | 96 | assertTrue(managerWithDefaultRollback.isTransactionMarkedRollback()); |
| @@ -101,14 +101,14 @@ public class TransactionRollbackTest { | @@ -101,14 +101,14 @@ public class TransactionRollbackTest { | ||
| 101 | assertFalse(managerWithDefaultRollback.isTransactionActive()); | 101 | assertFalse(managerWithDefaultRollback.isTransactionActive()); |
| 102 | } | 102 | } |
| 103 | } | 103 | } |
| 104 | - | 104 | + |
| 105 | @Test | 105 | @Test |
| 106 | - public void transactionWithRollback(){ | ||
| 107 | - try{ | 106 | + public void transactionWithRollback() { |
| 107 | + try { | ||
| 108 | managerWithRollback.clean(); | 108 | managerWithRollback.clean(); |
| 109 | managerWithRollback.insert(); | 109 | managerWithRollback.insert(); |
| 110 | fail(); | 110 | fail(); |
| 111 | - }catch(TransactionExceptionWithRollback exception){ | 111 | + } catch (TransactionExceptionWithRollback exception) { |
| 112 | assertTrue(managerWithRollback.isTransactionPassedInIsActiveMethod()); | 112 | assertTrue(managerWithRollback.isTransactionPassedInIsActiveMethod()); |
| 113 | assertTrue(managerWithRollback.isTransactionPassedInBeginMethod()); | 113 | assertTrue(managerWithRollback.isTransactionPassedInBeginMethod()); |
| 114 | assertTrue(managerWithRollback.isTransactionMarkedRollback()); | 114 | assertTrue(managerWithRollback.isTransactionMarkedRollback()); |
| @@ -119,14 +119,14 @@ public class TransactionRollbackTest { | @@ -119,14 +119,14 @@ public class TransactionRollbackTest { | ||
| 119 | assertFalse(managerWithRollback.isTransactionActive()); | 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 | managerWithoutRollback.clean(); | 126 | managerWithoutRollback.clean(); |
| 127 | managerWithoutRollback.insert(); | 127 | managerWithoutRollback.insert(); |
| 128 | fail(); | 128 | fail(); |
| 129 | - }catch(TransactionExceptionWithoutRollback exception){ | 129 | + } catch (TransactionExceptionWithoutRollback exception) { |
| 130 | assertTrue(managerWithRollback.isTransactionPassedInIsActiveMethod()); | 130 | assertTrue(managerWithRollback.isTransactionPassedInIsActiveMethod()); |
| 131 | assertTrue(managerWithRollback.isTransactionPassedInBeginMethod()); | 131 | assertTrue(managerWithRollback.isTransactionPassedInBeginMethod()); |
| 132 | assertFalse(managerWithRollback.isTransactionMarkedRollback()); | 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,7 +144,7 @@ public class StringsTest { | ||
| 144 | assertTrue(result.contains("Test [name=myName, lastname=myLastname, nullField=null, this")); | 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 | String out = Strings.getString(in, params); | 148 | String out = Strings.getString(in, params); |
| 149 | assertEquals(expected, out); | 149 | assertEquals(expected, out); |
| 150 | } | 150 | } |
impl/extension/jdbc/src/main/java/br/gov/frameworkdemoiselle/internal/producer/DataSourceProducer.java
| @@ -21,7 +21,7 @@ import org.slf4j.Logger; | @@ -21,7 +21,7 @@ import org.slf4j.Logger; | ||
| 21 | import br.gov.frameworkdemoiselle.DemoiselleException; | 21 | import br.gov.frameworkdemoiselle.DemoiselleException; |
| 22 | import br.gov.frameworkdemoiselle.annotation.Name; | 22 | import br.gov.frameworkdemoiselle.annotation.Name; |
| 23 | import br.gov.frameworkdemoiselle.internal.configuration.JDBCConfig; | 23 | import br.gov.frameworkdemoiselle.internal.configuration.JDBCConfig; |
| 24 | -import br.gov.frameworkdemoiselle.transaction.BasicDataSourceProxy; | 24 | +import br.gov.frameworkdemoiselle.internal.proxy.BasicDataSourceProxy; |
| 25 | import br.gov.frameworkdemoiselle.util.Beans; | 25 | import br.gov.frameworkdemoiselle.util.Beans; |
| 26 | import br.gov.frameworkdemoiselle.util.ResourceBundle; | 26 | import br.gov.frameworkdemoiselle.util.ResourceBundle; |
| 27 | 27 |
impl/extension/jdbc/src/main/java/br/gov/frameworkdemoiselle/internal/proxy/BasicDataSourceProxy.java
0 → 100644
| @@ -0,0 +1,363 @@ | @@ -0,0 +1,363 @@ | ||
| 1 | +package br.gov.frameworkdemoiselle.internal.proxy; | ||
| 2 | + | ||
| 3 | +import java.io.PrintWriter; | ||
| 4 | +import java.io.Serializable; | ||
| 5 | +import java.sql.Connection; | ||
| 6 | +import java.sql.SQLException; | ||
| 7 | +import java.util.Collection; | ||
| 8 | + | ||
| 9 | +import org.apache.commons.dbcp.BasicDataSource; | ||
| 10 | + | ||
| 11 | +import br.gov.frameworkdemoiselle.DemoiselleException; | ||
| 12 | +import br.gov.frameworkdemoiselle.internal.configuration.JDBCConfig; | ||
| 13 | +import br.gov.frameworkdemoiselle.util.ResourceBundle; | ||
| 14 | + | ||
| 15 | +public class BasicDataSourceProxy extends BasicDataSource implements Serializable { | ||
| 16 | + | ||
| 17 | + private static final long serialVersionUID = 1L; | ||
| 18 | + | ||
| 19 | + private ResourceBundle bundle; | ||
| 20 | + | ||
| 21 | + private String dataSourceName; | ||
| 22 | + | ||
| 23 | + private JDBCConfig config; | ||
| 24 | + | ||
| 25 | + private transient BasicDataSource delegate; | ||
| 26 | + | ||
| 27 | + public BasicDataSourceProxy(String dataSourceName, JDBCConfig config, ResourceBundle bundle) { | ||
| 28 | + this.dataSourceName = dataSourceName; | ||
| 29 | + this.config = config; | ||
| 30 | + this.bundle = bundle; | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + private BasicDataSource getDelegate() { | ||
| 34 | + if (this.delegate == null) { | ||
| 35 | + BasicDataSource dataSource = new BasicDataSource(); | ||
| 36 | + | ||
| 37 | + try { | ||
| 38 | + String driver = config.getDriverClass().get(dataSourceName); | ||
| 39 | + String url = config.getUrl().get(dataSourceName); | ||
| 40 | + String username = config.getUsername().get(dataSourceName); | ||
| 41 | + String password = config.getPassword().get(dataSourceName); | ||
| 42 | + | ||
| 43 | + dataSource.setDriverClassName(driver); | ||
| 44 | + dataSource.setUrl(url); | ||
| 45 | + dataSource.setUsername(username); | ||
| 46 | + dataSource.setPassword(password); | ||
| 47 | + | ||
| 48 | + } catch (ClassCastException cause) { | ||
| 49 | + throw new DemoiselleException(bundle.getString("load-duplicated-configuration-failed"), cause); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + delegate = dataSource; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + return this.delegate; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + public boolean getDefaultAutoCommit() { | ||
| 59 | + return getDelegate().getDefaultAutoCommit(); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + public void setDefaultAutoCommit(boolean defaultAutoCommit) { | ||
| 63 | + getDelegate().setDefaultAutoCommit(defaultAutoCommit); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + public boolean getDefaultReadOnly() { | ||
| 67 | + return getDelegate().getDefaultReadOnly(); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + public void setDefaultReadOnly(boolean defaultReadOnly) { | ||
| 71 | + getDelegate().setDefaultReadOnly(defaultReadOnly); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + public int getDefaultTransactionIsolation() { | ||
| 75 | + return getDelegate().getDefaultTransactionIsolation(); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + public void setDefaultTransactionIsolation(int defaultTransactionIsolation) { | ||
| 79 | + getDelegate().setDefaultTransactionIsolation(defaultTransactionIsolation); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + public String getDefaultCatalog() { | ||
| 83 | + return getDelegate().getDefaultCatalog(); | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + public void setDefaultCatalog(String defaultCatalog) { | ||
| 87 | + getDelegate().setDefaultCatalog(defaultCatalog); | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + public String getDriverClassName() { | ||
| 91 | + return getDelegate().getDriverClassName(); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + public void setDriverClassName(String driverClassName) { | ||
| 95 | + getDelegate().setDriverClassName(driverClassName); | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + public ClassLoader getDriverClassLoader() { | ||
| 99 | + return getDelegate().getDriverClassLoader(); | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + public void setDriverClassLoader(ClassLoader driverClassLoader) { | ||
| 103 | + getDelegate().setDriverClassLoader(driverClassLoader); | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + public int getMaxActive() { | ||
| 107 | + return getDelegate().getMaxActive(); | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + public void setMaxActive(int maxActive) { | ||
| 111 | + getDelegate().setMaxActive(maxActive); | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + public int getMaxIdle() { | ||
| 115 | + return getDelegate().getMaxIdle(); | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + public void setMaxIdle(int maxIdle) { | ||
| 119 | + getDelegate().setMaxIdle(maxIdle); | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + public int getMinIdle() { | ||
| 123 | + return getDelegate().getMinIdle(); | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + public void setMinIdle(int minIdle) { | ||
| 127 | + getDelegate().setMinIdle(minIdle); | ||
| 128 | + } | ||
| 129 | + | ||
| 130 | + public int getInitialSize() { | ||
| 131 | + return getDelegate().getInitialSize(); | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + public void setInitialSize(int initialSize) { | ||
| 135 | + getDelegate().setInitialSize(initialSize); | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + public long getMaxWait() { | ||
| 139 | + return getDelegate().getMaxWait(); | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + public void setMaxWait(long maxWait) { | ||
| 143 | + getDelegate().setMaxWait(maxWait); | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + public boolean isPoolPreparedStatements() { | ||
| 147 | + return getDelegate().isPoolPreparedStatements(); | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + public void setPoolPreparedStatements(boolean poolingStatements) { | ||
| 151 | + getDelegate().setPoolPreparedStatements(poolingStatements); | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + public int getMaxOpenPreparedStatements() { | ||
| 155 | + return getDelegate().getMaxOpenPreparedStatements(); | ||
| 156 | + } | ||
| 157 | + | ||
| 158 | + public void setMaxOpenPreparedStatements(int maxOpenStatements) { | ||
| 159 | + getDelegate().setMaxOpenPreparedStatements(maxOpenStatements); | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + public boolean getTestOnBorrow() { | ||
| 163 | + return getDelegate().getTestOnBorrow(); | ||
| 164 | + } | ||
| 165 | + | ||
| 166 | + public void setTestOnBorrow(boolean testOnBorrow) { | ||
| 167 | + getDelegate().setTestOnBorrow(testOnBorrow); | ||
| 168 | + } | ||
| 169 | + | ||
| 170 | + public boolean getTestOnReturn() { | ||
| 171 | + return getDelegate().getTestOnReturn(); | ||
| 172 | + } | ||
| 173 | + | ||
| 174 | + public void setTestOnReturn(boolean testOnReturn) { | ||
| 175 | + getDelegate().setTestOnReturn(testOnReturn); | ||
| 176 | + } | ||
| 177 | + | ||
| 178 | + public long getTimeBetweenEvictionRunsMillis() { | ||
| 179 | + return getDelegate().getTimeBetweenEvictionRunsMillis(); | ||
| 180 | + } | ||
| 181 | + | ||
| 182 | + public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) { | ||
| 183 | + getDelegate().setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); | ||
| 184 | + } | ||
| 185 | + | ||
| 186 | + public int getNumTestsPerEvictionRun() { | ||
| 187 | + return getDelegate().getNumTestsPerEvictionRun(); | ||
| 188 | + } | ||
| 189 | + | ||
| 190 | + public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) { | ||
| 191 | + getDelegate().setNumTestsPerEvictionRun(numTestsPerEvictionRun); | ||
| 192 | + } | ||
| 193 | + | ||
| 194 | + public long getMinEvictableIdleTimeMillis() { | ||
| 195 | + return getDelegate().getMinEvictableIdleTimeMillis(); | ||
| 196 | + } | ||
| 197 | + | ||
| 198 | + public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) { | ||
| 199 | + getDelegate().setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); | ||
| 200 | + } | ||
| 201 | + | ||
| 202 | + public boolean getTestWhileIdle() { | ||
| 203 | + return getDelegate().getTestWhileIdle(); | ||
| 204 | + } | ||
| 205 | + | ||
| 206 | + public void setTestWhileIdle(boolean testWhileIdle) { | ||
| 207 | + getDelegate().setTestWhileIdle(testWhileIdle); | ||
| 208 | + } | ||
| 209 | + | ||
| 210 | + public int getNumActive() { | ||
| 211 | + return getDelegate().getNumActive(); | ||
| 212 | + } | ||
| 213 | + | ||
| 214 | + public int getNumIdle() { | ||
| 215 | + return getDelegate().getNumIdle(); | ||
| 216 | + } | ||
| 217 | + | ||
| 218 | + public String getPassword() { | ||
| 219 | + return getDelegate().getPassword(); | ||
| 220 | + } | ||
| 221 | + | ||
| 222 | + public void setPassword(String password) { | ||
| 223 | + getDelegate().setPassword(password); | ||
| 224 | + } | ||
| 225 | + | ||
| 226 | + public String getUrl() { | ||
| 227 | + return getDelegate().getUrl(); | ||
| 228 | + } | ||
| 229 | + | ||
| 230 | + public void setUrl(String url) { | ||
| 231 | + getDelegate().setUrl(url); | ||
| 232 | + } | ||
| 233 | + | ||
| 234 | + public String getUsername() { | ||
| 235 | + return getDelegate().getUsername(); | ||
| 236 | + } | ||
| 237 | + | ||
| 238 | + public void setUsername(String username) { | ||
| 239 | + getDelegate().setUsername(username); | ||
| 240 | + } | ||
| 241 | + | ||
| 242 | + public String getValidationQuery() { | ||
| 243 | + return getDelegate().getValidationQuery(); | ||
| 244 | + } | ||
| 245 | + | ||
| 246 | + public void setValidationQuery(String validationQuery) { | ||
| 247 | + getDelegate().setValidationQuery(validationQuery); | ||
| 248 | + } | ||
| 249 | + | ||
| 250 | + public int getValidationQueryTimeout() { | ||
| 251 | + return getDelegate().getValidationQueryTimeout(); | ||
| 252 | + } | ||
| 253 | + | ||
| 254 | + public void setValidationQueryTimeout(int timeout) { | ||
| 255 | + getDelegate().setValidationQueryTimeout(timeout); | ||
| 256 | + } | ||
| 257 | + | ||
| 258 | + @SuppressWarnings("rawtypes") | ||
| 259 | + public Collection getConnectionInitSqls() { | ||
| 260 | + return getDelegate().getConnectionInitSqls(); | ||
| 261 | + } | ||
| 262 | + | ||
| 263 | + @SuppressWarnings("rawtypes") | ||
| 264 | + public void setConnectionInitSqls(Collection connectionInitSqls) { | ||
| 265 | + getDelegate().setConnectionInitSqls(connectionInitSqls); | ||
| 266 | + } | ||
| 267 | + | ||
| 268 | + public void setAccessToUnderlyingConnectionAllowed(boolean allow) { | ||
| 269 | + getDelegate().setAccessToUnderlyingConnectionAllowed(allow); | ||
| 270 | + } | ||
| 271 | + | ||
| 272 | + public Connection getConnection(String user, String pass) throws SQLException { | ||
| 273 | + return getDelegate().getConnection(user, pass); | ||
| 274 | + } | ||
| 275 | + | ||
| 276 | + public int getLoginTimeout() throws SQLException { | ||
| 277 | + return getDelegate().getLoginTimeout(); | ||
| 278 | + } | ||
| 279 | + | ||
| 280 | + public PrintWriter getLogWriter() throws SQLException { | ||
| 281 | + return getDelegate().getLogWriter(); | ||
| 282 | + } | ||
| 283 | + | ||
| 284 | + public void setLoginTimeout(int loginTimeout) throws SQLException { | ||
| 285 | + getDelegate().setLoginTimeout(loginTimeout); | ||
| 286 | + } | ||
| 287 | + | ||
| 288 | + public void setLogWriter(PrintWriter logWriter) throws SQLException { | ||
| 289 | + getDelegate().setLogWriter(logWriter); | ||
| 290 | + } | ||
| 291 | + | ||
| 292 | + public boolean getRemoveAbandoned() { | ||
| 293 | + return getDelegate().getRemoveAbandoned(); | ||
| 294 | + } | ||
| 295 | + | ||
| 296 | + public void setRemoveAbandoned(boolean removeAbandoned) { | ||
| 297 | + getDelegate().setRemoveAbandoned(removeAbandoned); | ||
| 298 | + } | ||
| 299 | + | ||
| 300 | + public int getRemoveAbandonedTimeout() { | ||
| 301 | + return getDelegate().getRemoveAbandonedTimeout(); | ||
| 302 | + } | ||
| 303 | + | ||
| 304 | + public void setRemoveAbandonedTimeout(int removeAbandonedTimeout) { | ||
| 305 | + getDelegate().setRemoveAbandonedTimeout(removeAbandonedTimeout); | ||
| 306 | + } | ||
| 307 | + | ||
| 308 | + public boolean getLogAbandoned() { | ||
| 309 | + return getDelegate().getLogAbandoned(); | ||
| 310 | + } | ||
| 311 | + | ||
| 312 | + public void setLogAbandoned(boolean logAbandoned) { | ||
| 313 | + getDelegate().setLogAbandoned(logAbandoned); | ||
| 314 | + } | ||
| 315 | + | ||
| 316 | + public void addConnectionProperty(String name, String value) { | ||
| 317 | + getDelegate().addConnectionProperty(name, value); | ||
| 318 | + } | ||
| 319 | + | ||
| 320 | + public void removeConnectionProperty(String name) { | ||
| 321 | + getDelegate().removeConnectionProperty(name); | ||
| 322 | + } | ||
| 323 | + | ||
| 324 | + public void setConnectionProperties(String connectionProperties) { | ||
| 325 | + getDelegate().setConnectionProperties(connectionProperties); | ||
| 326 | + } | ||
| 327 | + | ||
| 328 | + public void close() throws SQLException { | ||
| 329 | + getDelegate().close(); | ||
| 330 | + } | ||
| 331 | + | ||
| 332 | + public boolean equals(Object arg0) { | ||
| 333 | + return getDelegate().equals(arg0); | ||
| 334 | + } | ||
| 335 | + | ||
| 336 | + public Connection getConnection() throws SQLException { | ||
| 337 | + return getDelegate().getConnection(); | ||
| 338 | + } | ||
| 339 | + | ||
| 340 | + public int hashCode() { | ||
| 341 | + return getDelegate().hashCode(); | ||
| 342 | + } | ||
| 343 | + | ||
| 344 | + public boolean isAccessToUnderlyingConnectionAllowed() { | ||
| 345 | + return getDelegate().isAccessToUnderlyingConnectionAllowed(); | ||
| 346 | + } | ||
| 347 | + | ||
| 348 | + public boolean isClosed() { | ||
| 349 | + return getDelegate().isClosed(); | ||
| 350 | + } | ||
| 351 | + | ||
| 352 | + public boolean isWrapperFor(Class<?> iface) throws SQLException { | ||
| 353 | + return getDelegate().isWrapperFor(iface); | ||
| 354 | + } | ||
| 355 | + | ||
| 356 | + public String toString() { | ||
| 357 | + return getDelegate().toString(); | ||
| 358 | + } | ||
| 359 | + | ||
| 360 | + public <T> T unwrap(Class<T> iface) throws SQLException { | ||
| 361 | + return getDelegate().unwrap(iface); | ||
| 362 | + } | ||
| 363 | +} |
impl/extension/jdbc/src/main/java/br/gov/frameworkdemoiselle/transaction/BasicDataSourceProxy.java
| @@ -1,363 +0,0 @@ | @@ -1,363 +0,0 @@ | ||
| 1 | -package br.gov.frameworkdemoiselle.transaction; | ||
| 2 | - | ||
| 3 | -import java.io.PrintWriter; | ||
| 4 | -import java.io.Serializable; | ||
| 5 | -import java.sql.Connection; | ||
| 6 | -import java.sql.SQLException; | ||
| 7 | -import java.util.Collection; | ||
| 8 | - | ||
| 9 | -import org.apache.commons.dbcp.BasicDataSource; | ||
| 10 | - | ||
| 11 | -import br.gov.frameworkdemoiselle.DemoiselleException; | ||
| 12 | -import br.gov.frameworkdemoiselle.internal.configuration.JDBCConfig; | ||
| 13 | -import br.gov.frameworkdemoiselle.util.ResourceBundle; | ||
| 14 | - | ||
| 15 | -public class BasicDataSourceProxy extends BasicDataSource implements Serializable { | ||
| 16 | - | ||
| 17 | - private static final long serialVersionUID = 1L; | ||
| 18 | - | ||
| 19 | - private ResourceBundle bundle; | ||
| 20 | - | ||
| 21 | - private String dataSourceName; | ||
| 22 | - | ||
| 23 | - private JDBCConfig config; | ||
| 24 | - | ||
| 25 | - private transient BasicDataSource delegate; | ||
| 26 | - | ||
| 27 | - public BasicDataSourceProxy(String dataSourceName, JDBCConfig config, ResourceBundle bundle) { | ||
| 28 | - this.dataSourceName = dataSourceName; | ||
| 29 | - this.config = config; | ||
| 30 | - this.bundle = bundle; | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - private BasicDataSource getDelegate() { | ||
| 34 | - if (this.delegate == null) { | ||
| 35 | - BasicDataSource dataSource = new BasicDataSource(); | ||
| 36 | - | ||
| 37 | - try { | ||
| 38 | - String driver = config.getDriverClass().get(dataSourceName); | ||
| 39 | - String url = config.getUrl().get(dataSourceName); | ||
| 40 | - String username = config.getUsername().get(dataSourceName); | ||
| 41 | - String password = config.getPassword().get(dataSourceName); | ||
| 42 | - | ||
| 43 | - dataSource.setDriverClassName(driver); | ||
| 44 | - dataSource.setUrl(url); | ||
| 45 | - dataSource.setUsername(username); | ||
| 46 | - dataSource.setPassword(password); | ||
| 47 | - | ||
| 48 | - } catch (ClassCastException cause) { | ||
| 49 | - throw new DemoiselleException(bundle.getString("load-duplicated-configuration-failed"), cause); | ||
| 50 | - } | ||
| 51 | - | ||
| 52 | - delegate = dataSource; | ||
| 53 | - } | ||
| 54 | - | ||
| 55 | - return this.delegate; | ||
| 56 | - } | ||
| 57 | - | ||
| 58 | - public boolean getDefaultAutoCommit() { | ||
| 59 | - return getDelegate().getDefaultAutoCommit(); | ||
| 60 | - } | ||
| 61 | - | ||
| 62 | - public void setDefaultAutoCommit(boolean defaultAutoCommit) { | ||
| 63 | - getDelegate().setDefaultAutoCommit(defaultAutoCommit); | ||
| 64 | - } | ||
| 65 | - | ||
| 66 | - public boolean getDefaultReadOnly() { | ||
| 67 | - return getDelegate().getDefaultReadOnly(); | ||
| 68 | - } | ||
| 69 | - | ||
| 70 | - public void setDefaultReadOnly(boolean defaultReadOnly) { | ||
| 71 | - getDelegate().setDefaultReadOnly(defaultReadOnly); | ||
| 72 | - } | ||
| 73 | - | ||
| 74 | - public int getDefaultTransactionIsolation() { | ||
| 75 | - return getDelegate().getDefaultTransactionIsolation(); | ||
| 76 | - } | ||
| 77 | - | ||
| 78 | - public void setDefaultTransactionIsolation(int defaultTransactionIsolation) { | ||
| 79 | - getDelegate().setDefaultTransactionIsolation(defaultTransactionIsolation); | ||
| 80 | - } | ||
| 81 | - | ||
| 82 | - public String getDefaultCatalog() { | ||
| 83 | - return getDelegate().getDefaultCatalog(); | ||
| 84 | - } | ||
| 85 | - | ||
| 86 | - public void setDefaultCatalog(String defaultCatalog) { | ||
| 87 | - getDelegate().setDefaultCatalog(defaultCatalog); | ||
| 88 | - } | ||
| 89 | - | ||
| 90 | - public String getDriverClassName() { | ||
| 91 | - return getDelegate().getDriverClassName(); | ||
| 92 | - } | ||
| 93 | - | ||
| 94 | - public void setDriverClassName(String driverClassName) { | ||
| 95 | - getDelegate().setDriverClassName(driverClassName); | ||
| 96 | - } | ||
| 97 | - | ||
| 98 | - public ClassLoader getDriverClassLoader() { | ||
| 99 | - return getDelegate().getDriverClassLoader(); | ||
| 100 | - } | ||
| 101 | - | ||
| 102 | - public void setDriverClassLoader(ClassLoader driverClassLoader) { | ||
| 103 | - getDelegate().setDriverClassLoader(driverClassLoader); | ||
| 104 | - } | ||
| 105 | - | ||
| 106 | - public int getMaxActive() { | ||
| 107 | - return getDelegate().getMaxActive(); | ||
| 108 | - } | ||
| 109 | - | ||
| 110 | - public void setMaxActive(int maxActive) { | ||
| 111 | - getDelegate().setMaxActive(maxActive); | ||
| 112 | - } | ||
| 113 | - | ||
| 114 | - public int getMaxIdle() { | ||
| 115 | - return getDelegate().getMaxIdle(); | ||
| 116 | - } | ||
| 117 | - | ||
| 118 | - public void setMaxIdle(int maxIdle) { | ||
| 119 | - getDelegate().setMaxIdle(maxIdle); | ||
| 120 | - } | ||
| 121 | - | ||
| 122 | - public int getMinIdle() { | ||
| 123 | - return getDelegate().getMinIdle(); | ||
| 124 | - } | ||
| 125 | - | ||
| 126 | - public void setMinIdle(int minIdle) { | ||
| 127 | - getDelegate().setMinIdle(minIdle); | ||
| 128 | - } | ||
| 129 | - | ||
| 130 | - public int getInitialSize() { | ||
| 131 | - return getDelegate().getInitialSize(); | ||
| 132 | - } | ||
| 133 | - | ||
| 134 | - public void setInitialSize(int initialSize) { | ||
| 135 | - getDelegate().setInitialSize(initialSize); | ||
| 136 | - } | ||
| 137 | - | ||
| 138 | - public long getMaxWait() { | ||
| 139 | - return getDelegate().getMaxWait(); | ||
| 140 | - } | ||
| 141 | - | ||
| 142 | - public void setMaxWait(long maxWait) { | ||
| 143 | - getDelegate().setMaxWait(maxWait); | ||
| 144 | - } | ||
| 145 | - | ||
| 146 | - public boolean isPoolPreparedStatements() { | ||
| 147 | - return getDelegate().isPoolPreparedStatements(); | ||
| 148 | - } | ||
| 149 | - | ||
| 150 | - public void setPoolPreparedStatements(boolean poolingStatements) { | ||
| 151 | - getDelegate().setPoolPreparedStatements(poolingStatements); | ||
| 152 | - } | ||
| 153 | - | ||
| 154 | - public int getMaxOpenPreparedStatements() { | ||
| 155 | - return getDelegate().getMaxOpenPreparedStatements(); | ||
| 156 | - } | ||
| 157 | - | ||
| 158 | - public void setMaxOpenPreparedStatements(int maxOpenStatements) { | ||
| 159 | - getDelegate().setMaxOpenPreparedStatements(maxOpenStatements); | ||
| 160 | - } | ||
| 161 | - | ||
| 162 | - public boolean getTestOnBorrow() { | ||
| 163 | - return getDelegate().getTestOnBorrow(); | ||
| 164 | - } | ||
| 165 | - | ||
| 166 | - public void setTestOnBorrow(boolean testOnBorrow) { | ||
| 167 | - getDelegate().setTestOnBorrow(testOnBorrow); | ||
| 168 | - } | ||
| 169 | - | ||
| 170 | - public boolean getTestOnReturn() { | ||
| 171 | - return getDelegate().getTestOnReturn(); | ||
| 172 | - } | ||
| 173 | - | ||
| 174 | - public void setTestOnReturn(boolean testOnReturn) { | ||
| 175 | - getDelegate().setTestOnReturn(testOnReturn); | ||
| 176 | - } | ||
| 177 | - | ||
| 178 | - public long getTimeBetweenEvictionRunsMillis() { | ||
| 179 | - return getDelegate().getTimeBetweenEvictionRunsMillis(); | ||
| 180 | - } | ||
| 181 | - | ||
| 182 | - public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) { | ||
| 183 | - getDelegate().setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); | ||
| 184 | - } | ||
| 185 | - | ||
| 186 | - public int getNumTestsPerEvictionRun() { | ||
| 187 | - return getDelegate().getNumTestsPerEvictionRun(); | ||
| 188 | - } | ||
| 189 | - | ||
| 190 | - public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) { | ||
| 191 | - getDelegate().setNumTestsPerEvictionRun(numTestsPerEvictionRun); | ||
| 192 | - } | ||
| 193 | - | ||
| 194 | - public long getMinEvictableIdleTimeMillis() { | ||
| 195 | - return getDelegate().getMinEvictableIdleTimeMillis(); | ||
| 196 | - } | ||
| 197 | - | ||
| 198 | - public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) { | ||
| 199 | - getDelegate().setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); | ||
| 200 | - } | ||
| 201 | - | ||
| 202 | - public boolean getTestWhileIdle() { | ||
| 203 | - return getDelegate().getTestWhileIdle(); | ||
| 204 | - } | ||
| 205 | - | ||
| 206 | - public void setTestWhileIdle(boolean testWhileIdle) { | ||
| 207 | - getDelegate().setTestWhileIdle(testWhileIdle); | ||
| 208 | - } | ||
| 209 | - | ||
| 210 | - public int getNumActive() { | ||
| 211 | - return getDelegate().getNumActive(); | ||
| 212 | - } | ||
| 213 | - | ||
| 214 | - public int getNumIdle() { | ||
| 215 | - return getDelegate().getNumIdle(); | ||
| 216 | - } | ||
| 217 | - | ||
| 218 | - public String getPassword() { | ||
| 219 | - return getDelegate().getPassword(); | ||
| 220 | - } | ||
| 221 | - | ||
| 222 | - public void setPassword(String password) { | ||
| 223 | - getDelegate().setPassword(password); | ||
| 224 | - } | ||
| 225 | - | ||
| 226 | - public String getUrl() { | ||
| 227 | - return getDelegate().getUrl(); | ||
| 228 | - } | ||
| 229 | - | ||
| 230 | - public void setUrl(String url) { | ||
| 231 | - getDelegate().setUrl(url); | ||
| 232 | - } | ||
| 233 | - | ||
| 234 | - public String getUsername() { | ||
| 235 | - return getDelegate().getUsername(); | ||
| 236 | - } | ||
| 237 | - | ||
| 238 | - public void setUsername(String username) { | ||
| 239 | - getDelegate().setUsername(username); | ||
| 240 | - } | ||
| 241 | - | ||
| 242 | - public String getValidationQuery() { | ||
| 243 | - return getDelegate().getValidationQuery(); | ||
| 244 | - } | ||
| 245 | - | ||
| 246 | - public void setValidationQuery(String validationQuery) { | ||
| 247 | - getDelegate().setValidationQuery(validationQuery); | ||
| 248 | - } | ||
| 249 | - | ||
| 250 | - public int getValidationQueryTimeout() { | ||
| 251 | - return getDelegate().getValidationQueryTimeout(); | ||
| 252 | - } | ||
| 253 | - | ||
| 254 | - public void setValidationQueryTimeout(int timeout) { | ||
| 255 | - getDelegate().setValidationQueryTimeout(timeout); | ||
| 256 | - } | ||
| 257 | - | ||
| 258 | - @SuppressWarnings("rawtypes") | ||
| 259 | - public Collection getConnectionInitSqls() { | ||
| 260 | - return getDelegate().getConnectionInitSqls(); | ||
| 261 | - } | ||
| 262 | - | ||
| 263 | - @SuppressWarnings("rawtypes") | ||
| 264 | - public void setConnectionInitSqls(Collection connectionInitSqls) { | ||
| 265 | - getDelegate().setConnectionInitSqls(connectionInitSqls); | ||
| 266 | - } | ||
| 267 | - | ||
| 268 | - public void setAccessToUnderlyingConnectionAllowed(boolean allow) { | ||
| 269 | - getDelegate().setAccessToUnderlyingConnectionAllowed(allow); | ||
| 270 | - } | ||
| 271 | - | ||
| 272 | - public Connection getConnection(String user, String pass) throws SQLException { | ||
| 273 | - return getDelegate().getConnection(user, pass); | ||
| 274 | - } | ||
| 275 | - | ||
| 276 | - public int getLoginTimeout() throws SQLException { | ||
| 277 | - return getDelegate().getLoginTimeout(); | ||
| 278 | - } | ||
| 279 | - | ||
| 280 | - public PrintWriter getLogWriter() throws SQLException { | ||
| 281 | - return getDelegate().getLogWriter(); | ||
| 282 | - } | ||
| 283 | - | ||
| 284 | - public void setLoginTimeout(int loginTimeout) throws SQLException { | ||
| 285 | - getDelegate().setLoginTimeout(loginTimeout); | ||
| 286 | - } | ||
| 287 | - | ||
| 288 | - public void setLogWriter(PrintWriter logWriter) throws SQLException { | ||
| 289 | - getDelegate().setLogWriter(logWriter); | ||
| 290 | - } | ||
| 291 | - | ||
| 292 | - public boolean getRemoveAbandoned() { | ||
| 293 | - return getDelegate().getRemoveAbandoned(); | ||
| 294 | - } | ||
| 295 | - | ||
| 296 | - public void setRemoveAbandoned(boolean removeAbandoned) { | ||
| 297 | - getDelegate().setRemoveAbandoned(removeAbandoned); | ||
| 298 | - } | ||
| 299 | - | ||
| 300 | - public int getRemoveAbandonedTimeout() { | ||
| 301 | - return getDelegate().getRemoveAbandonedTimeout(); | ||
| 302 | - } | ||
| 303 | - | ||
| 304 | - public void setRemoveAbandonedTimeout(int removeAbandonedTimeout) { | ||
| 305 | - getDelegate().setRemoveAbandonedTimeout(removeAbandonedTimeout); | ||
| 306 | - } | ||
| 307 | - | ||
| 308 | - public boolean getLogAbandoned() { | ||
| 309 | - return getDelegate().getLogAbandoned(); | ||
| 310 | - } | ||
| 311 | - | ||
| 312 | - public void setLogAbandoned(boolean logAbandoned) { | ||
| 313 | - getDelegate().setLogAbandoned(logAbandoned); | ||
| 314 | - } | ||
| 315 | - | ||
| 316 | - public void addConnectionProperty(String name, String value) { | ||
| 317 | - getDelegate().addConnectionProperty(name, value); | ||
| 318 | - } | ||
| 319 | - | ||
| 320 | - public void removeConnectionProperty(String name) { | ||
| 321 | - getDelegate().removeConnectionProperty(name); | ||
| 322 | - } | ||
| 323 | - | ||
| 324 | - public void setConnectionProperties(String connectionProperties) { | ||
| 325 | - getDelegate().setConnectionProperties(connectionProperties); | ||
| 326 | - } | ||
| 327 | - | ||
| 328 | - public void close() throws SQLException { | ||
| 329 | - getDelegate().close(); | ||
| 330 | - } | ||
| 331 | - | ||
| 332 | - public boolean equals(Object arg0) { | ||
| 333 | - return getDelegate().equals(arg0); | ||
| 334 | - } | ||
| 335 | - | ||
| 336 | - public Connection getConnection() throws SQLException { | ||
| 337 | - return getDelegate().getConnection(); | ||
| 338 | - } | ||
| 339 | - | ||
| 340 | - public int hashCode() { | ||
| 341 | - return getDelegate().hashCode(); | ||
| 342 | - } | ||
| 343 | - | ||
| 344 | - public boolean isAccessToUnderlyingConnectionAllowed() { | ||
| 345 | - return getDelegate().isAccessToUnderlyingConnectionAllowed(); | ||
| 346 | - } | ||
| 347 | - | ||
| 348 | - public boolean isClosed() { | ||
| 349 | - return getDelegate().isClosed(); | ||
| 350 | - } | ||
| 351 | - | ||
| 352 | - public boolean isWrapperFor(Class<?> iface) throws SQLException { | ||
| 353 | - return getDelegate().isWrapperFor(iface); | ||
| 354 | - } | ||
| 355 | - | ||
| 356 | - public String toString() { | ||
| 357 | - return getDelegate().toString(); | ||
| 358 | - } | ||
| 359 | - | ||
| 360 | - public <T> T unwrap(Class<T> iface) throws SQLException { | ||
| 361 | - return getDelegate().unwrap(iface); | ||
| 362 | - } | ||
| 363 | -} |
impl/extension/jdbc/src/main/java/br/gov/frameworkdemoiselle/transaction/JDBCTransaction.java
| @@ -36,7 +36,7 @@ | @@ -36,7 +36,7 @@ | ||
| 36 | */ | 36 | */ |
| 37 | package br.gov.frameworkdemoiselle.transaction; | 37 | package br.gov.frameworkdemoiselle.transaction; |
| 38 | 38 | ||
| 39 | -import static br.gov.frameworkdemoiselle.internal.implementation.StrategySelector.EXTENSIONS_L1_PRIORITY; | 39 | +import static br.gov.frameworkdemoiselle.annotation.Priority.L2_PRIORITY; |
| 40 | 40 | ||
| 41 | import java.io.Serializable; | 41 | import java.io.Serializable; |
| 42 | import java.sql.Connection; | 42 | import java.sql.Connection; |
| @@ -55,7 +55,7 @@ import br.gov.frameworkdemoiselle.util.Beans; | @@ -55,7 +55,7 @@ import br.gov.frameworkdemoiselle.util.Beans; | ||
| 55 | * @author SERPRO | 55 | * @author SERPRO |
| 56 | * @see Transaction | 56 | * @see Transaction |
| 57 | */ | 57 | */ |
| 58 | -@Priority(EXTENSIONS_L1_PRIORITY) | 58 | +@Priority(L2_PRIORITY) |
| 59 | public class JDBCTransaction implements Transaction { | 59 | public class JDBCTransaction implements Transaction { |
| 60 | 60 | ||
| 61 | private static final long serialVersionUID = 1L; | 61 | private static final long serialVersionUID = 1L; |
impl/extension/jpa/src/main/java/br/gov/frameworkdemoiselle/transaction/JPATransaction.java
| @@ -36,7 +36,7 @@ | @@ -36,7 +36,7 @@ | ||
| 36 | */ | 36 | */ |
| 37 | package br.gov.frameworkdemoiselle.transaction; | 37 | package br.gov.frameworkdemoiselle.transaction; |
| 38 | 38 | ||
| 39 | -import static br.gov.frameworkdemoiselle.internal.implementation.StrategySelector.EXTENSIONS_L1_PRIORITY; | 39 | +import static br.gov.frameworkdemoiselle.annotation.Priority.L2_PRIORITY; |
| 40 | 40 | ||
| 41 | import java.util.Collection; | 41 | import java.util.Collection; |
| 42 | 42 | ||
| @@ -53,7 +53,7 @@ import br.gov.frameworkdemoiselle.util.Beans; | @@ -53,7 +53,7 @@ import br.gov.frameworkdemoiselle.util.Beans; | ||
| 53 | * @author SERPRO | 53 | * @author SERPRO |
| 54 | * @see Transaction | 54 | * @see Transaction |
| 55 | */ | 55 | */ |
| 56 | -@Priority(EXTENSIONS_L1_PRIORITY) | 56 | +@Priority(L2_PRIORITY) |
| 57 | public class JPATransaction implements Transaction { | 57 | public class JPATransaction implements Transaction { |
| 58 | 58 | ||
| 59 | private static final long serialVersionUID = 1L; | 59 | private static final long serialVersionUID = 1L; |
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/FacesMessageAppender.java
0 → 100644
| @@ -0,0 +1,54 @@ | @@ -0,0 +1,54 @@ | ||
| 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.implementation; | ||
| 38 | + | ||
| 39 | +import static br.gov.frameworkdemoiselle.annotation.Priority.L3_PRIORITY; | ||
| 40 | +import br.gov.frameworkdemoiselle.annotation.Priority; | ||
| 41 | +import br.gov.frameworkdemoiselle.message.Message; | ||
| 42 | +import br.gov.frameworkdemoiselle.message.MessageAppender; | ||
| 43 | +import br.gov.frameworkdemoiselle.util.Faces; | ||
| 44 | + | ||
| 45 | +@Priority(L3_PRIORITY) | ||
| 46 | +public class FacesMessageAppender implements MessageAppender { | ||
| 47 | + | ||
| 48 | + private static final long serialVersionUID = 1L; | ||
| 49 | + | ||
| 50 | + @Override | ||
| 51 | + public void append(Message message) { | ||
| 52 | + Faces.addMessage(message); | ||
| 53 | + } | ||
| 54 | +} |