Commit 2bbaddb1d28d6bd45d4ce0548d1c252a15f61a94
Exists in
master
Merge branch 'master' into 2.4.0
Showing
13 changed files
with
50 additions
and
28 deletions
Show diff stats
impl/core/src/main/java/br/gov/frameworkdemoiselle/configuration/Configuration.java
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoader.java
... | ... | @@ -82,9 +82,9 @@ public class ConfigurationLoader implements Serializable { |
82 | 82 | private ResourceBundle bundle; |
83 | 83 | |
84 | 84 | private Logger logger; |
85 | - | |
85 | + | |
86 | 86 | private CoreBootstrap bootstrap; |
87 | - | |
87 | + | |
88 | 88 | /** |
89 | 89 | * Loads a config class filling it with the corresponding values. |
90 | 90 | * |
... | ... | @@ -159,7 +159,17 @@ public class ConfigurationLoader implements Serializable { |
159 | 159 | |
160 | 160 | Configuration classAnnotation = type.getAnnotation(Configuration.class); |
161 | 161 | if (!Strings.isEmpty(classAnnotation.prefix())) { |
162 | - prefix = classAnnotation.prefix() + "."; | |
162 | + | |
163 | + prefix = classAnnotation.prefix(); | |
164 | + | |
165 | + if (prefix.charAt(prefix.length() - 1) != '.') { | |
166 | + getLogger().warn( | |
167 | + "ATENÇÃO!!! Informe o ponto (.) ao final da declaração do atributo prefix = \"" + prefix | |
168 | + + "\" da anotação @Configuration da classe " + type.getCanonicalName() | |
169 | + + " para evitar incompatibilidade com as próximas versões do Demoiselle."); | |
170 | + | |
171 | + prefix += "."; | |
172 | + } | |
163 | 173 | } |
164 | 174 | |
165 | 175 | return prefix; |
... | ... | @@ -196,6 +206,13 @@ public class ConfigurationLoader implements Serializable { |
196 | 206 | } |
197 | 207 | } |
198 | 208 | |
209 | + if (!field.getName().equals(key)) { | |
210 | + getLogger().warn( | |
211 | + "ATENÇÃO!!! Anote o atributo " + field.getName() + " da classe " | |
212 | + + field.getDeclaringClass().getCanonicalName() + " com @Name(\"" + key | |
213 | + + "\") para evitar incompatibilidade com as próximas versões do Demoiselle."); | |
214 | + } | |
215 | + | |
199 | 216 | if (matches == 0) { |
200 | 217 | getLogger().debug(getBundle().getString("configuration-key-not-found", key, conventions)); |
201 | 218 | } else if (matches > 1) { |
... | ... | @@ -445,12 +462,12 @@ public class ConfigurationLoader implements Serializable { |
445 | 462 | |
446 | 463 | return logger; |
447 | 464 | } |
448 | - | |
449 | - private CoreBootstrap getBootstrap(){ | |
450 | - if (bootstrap == null){ | |
465 | + | |
466 | + private CoreBootstrap getBootstrap() { | |
467 | + if (bootstrap == null) { | |
451 | 468 | bootstrap = Beans.getReference(CoreBootstrap.class); |
452 | 469 | } |
453 | - | |
470 | + | |
454 | 471 | return bootstrap; |
455 | 472 | } |
456 | 473 | } | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/PaginationConfig.java
... | ... | @@ -47,7 +47,7 @@ import br.gov.frameworkdemoiselle.configuration.Configuration; |
47 | 47 | * |
48 | 48 | * @author SERPRO |
49 | 49 | */ |
50 | -@Configuration(prefix = "frameworkdemoiselle.pagination") | |
50 | +@Configuration(prefix = "frameworkdemoiselle.pagination.") | |
51 | 51 | public class PaginationConfig implements Serializable { |
52 | 52 | |
53 | 53 | private static final long serialVersionUID = 1L; | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/SecurityConfigImpl.java
... | ... | @@ -38,19 +38,23 @@ package br.gov.frameworkdemoiselle.internal.configuration; |
38 | 38 | |
39 | 39 | import java.io.Serializable; |
40 | 40 | |
41 | +import br.gov.frameworkdemoiselle.annotation.Name; | |
41 | 42 | import br.gov.frameworkdemoiselle.configuration.Configuration; |
42 | 43 | import br.gov.frameworkdemoiselle.security.Authenticator; |
43 | 44 | import br.gov.frameworkdemoiselle.security.Authorizer; |
44 | 45 | |
45 | -@Configuration(prefix = "frameworkdemoiselle.security") | |
46 | +@Configuration(prefix = "frameworkdemoiselle.security.") | |
46 | 47 | public class SecurityConfigImpl implements Serializable, SecurityConfig { |
47 | 48 | |
48 | 49 | private static final long serialVersionUID = 1L; |
49 | 50 | |
51 | + @Name("enabled") | |
50 | 52 | private boolean enabled = true; |
51 | 53 | |
54 | + @Name("authenticator.class") | |
52 | 55 | private Class<? extends Authenticator> authenticatorClass; |
53 | 56 | |
57 | + @Name("authorizer.class") | |
54 | 58 | private Class<? extends Authorizer> authorizerClass; |
55 | 59 | |
56 | 60 | /* | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/TransactionConfig.java
... | ... | @@ -42,7 +42,7 @@ import br.gov.frameworkdemoiselle.annotation.Name; |
42 | 42 | import br.gov.frameworkdemoiselle.configuration.Configuration; |
43 | 43 | import br.gov.frameworkdemoiselle.transaction.Transaction; |
44 | 44 | |
45 | -@Configuration(prefix = "frameworkdemoiselle.transaction") | |
45 | +@Configuration(prefix = "frameworkdemoiselle.transaction.") | |
46 | 46 | public class TransactionConfig implements Serializable { |
47 | 47 | |
48 | 48 | private static final long serialVersionUID = 1L; | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/interceptor/ExceptionHandlerInterceptor.java
... | ... | @@ -69,11 +69,11 @@ public class ExceptionHandlerInterceptor implements Serializable { |
69 | 69 | |
70 | 70 | private final Map<Class<?>, Map<Class<?>, Method>> cache = new HashMap<Class<?>, Map<Class<?>, Method>>(); |
71 | 71 | |
72 | - private final boolean handleException(final Exception cause, final InvocationContext ic) throws Exception { | |
72 | + private final boolean handleException(final Exception cause, final Object target) throws Exception { | |
73 | 73 | getLogger().info(getBundle().getString("handling-exception", cause.getClass().getCanonicalName())); |
74 | 74 | |
75 | 75 | boolean handled = false; |
76 | - Class<?> type = getType(ic); | |
76 | + Class<?> type = getType(target); | |
77 | 77 | |
78 | 78 | if (!isLoaded(type)) { |
79 | 79 | loadHandlers(type); |
... | ... | @@ -81,22 +81,22 @@ public class ExceptionHandlerInterceptor implements Serializable { |
81 | 81 | |
82 | 82 | Method handler = getMethod(type, cause); |
83 | 83 | if (handler != null) { |
84 | - invoke(handler, ic.getTarget(), cause); | |
84 | + invoke(handler, target, cause); | |
85 | 85 | handled = true; |
86 | 86 | } |
87 | 87 | |
88 | 88 | return handled; |
89 | 89 | } |
90 | 90 | |
91 | - private final Class<?> getType(final InvocationContext ic) { | |
92 | - Class<?> type = ic.getTarget().getClass(); | |
91 | + private final Class<?> getType(final Object target) { | |
92 | + Class<?> type = target.getClass(); | |
93 | 93 | CoreBootstrap bootstrap = Beans.getReference(CoreBootstrap.class); |
94 | 94 | |
95 | 95 | if (!bootstrap.isAnnotatedType(type)) { |
96 | - type = type.getSuperclass(); | |
97 | 96 | getLogger().debug( |
98 | - getBundle().getString("proxy-detected", ic.getTarget().getClass(), | |
99 | - ic.getTarget().getClass().getSuperclass())); | |
97 | + getBundle().getString("proxy-detected", type, | |
98 | + type.getSuperclass())); | |
99 | + type = type.getSuperclass(); | |
100 | 100 | } |
101 | 101 | |
102 | 102 | return type; |
... | ... | @@ -183,13 +183,15 @@ public class ExceptionHandlerInterceptor implements Serializable { |
183 | 183 | |
184 | 184 | @AroundInvoke |
185 | 185 | public Object manage(final InvocationContext ic) throws Exception { |
186 | + Object target = null; | |
186 | 187 | Object result = null; |
187 | 188 | |
188 | 189 | try { |
190 | + target = ic.getTarget(); | |
189 | 191 | result = ic.proceed(); |
190 | 192 | |
191 | 193 | } catch (Exception cause) { |
192 | - if (!handleException(cause, ic)) { | |
194 | + if (!handleException(cause, target)) { | |
193 | 195 | throw cause; |
194 | 196 | } |
195 | 197 | } | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/util/Exceptions.java
... | ... | @@ -26,7 +26,7 @@ public final class Exceptions { |
26 | 26 | } |
27 | 27 | |
28 | 28 | public static boolean isApplicationException(final Throwable throwable) { |
29 | - return throwable.getClass().isAnnotationPresent(ApplicationException.class); | |
29 | + return throwable != null && throwable.getClass().isAnnotationPresent(ApplicationException.class); | |
30 | 30 | } |
31 | 31 | |
32 | 32 | public static void handleToRuntimeException(final Throwable throwable) throws RuntimeException { | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderTest.java
... | ... | @@ -133,7 +133,7 @@ public class ConfigurationLoaderTest { |
133 | 133 | |
134 | 134 | } |
135 | 135 | |
136 | - @Configuration(prefix = "frameworkdemoiselle.configurationtest") | |
136 | + @Configuration(prefix = "frameworkdemoiselle.configurationtest.") | |
137 | 137 | public class ConfigurationWithPrefix { |
138 | 138 | |
139 | 139 | @Name("nameConfiguration") |
... | ... | @@ -282,7 +282,7 @@ public class ConfigurationLoaderTest { |
282 | 282 | |
283 | 283 | } |
284 | 284 | |
285 | - @Configuration(prefix = "br.gov.frameworkdemoiselle") | |
285 | + @Configuration(prefix = "br.gov.frameworkdemoiselle.") | |
286 | 286 | public class ConfigurationPropertiesSuccessWithPrefixNonAmbiguous { |
287 | 287 | |
288 | 288 | protected String success; | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/ExceptionHandlerInterceptorTest.java
... | ... | @@ -155,6 +155,7 @@ public class ExceptionHandlerInterceptorTest { |
155 | 155 | @Test |
156 | 156 | public void manageSuccessfully() throws Throwable { |
157 | 157 | expect(this.context.proceed()).andReturn(null); |
158 | + expect(this.context.getTarget()).andReturn(null); | |
158 | 159 | replayAll(); |
159 | 160 | assertEquals(null, this.interceptor.manage(this.context)); |
160 | 161 | verify(); | ... | ... |
impl/extension/jpa/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/EntityManagerConfig.java
... | ... | @@ -44,7 +44,7 @@ import br.gov.frameworkdemoiselle.configuration.Configuration; |
44 | 44 | /** |
45 | 45 | * Configuration class responsible for retrieving specific entity manager parameter values from properties file. |
46 | 46 | */ |
47 | -@Configuration(prefix = "frameworkdemoiselle.persistence") | |
47 | +@Configuration(prefix = "frameworkdemoiselle.persistence.") | |
48 | 48 | public class EntityManagerConfig implements Serializable { |
49 | 49 | |
50 | 50 | private static final long serialVersionUID = 1L; | ... | ... |
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ExceptionHandlerConfig.java
... | ... | @@ -41,7 +41,7 @@ import java.io.Serializable; |
41 | 41 | import br.gov.frameworkdemoiselle.annotation.Name; |
42 | 42 | import br.gov.frameworkdemoiselle.configuration.Configuration; |
43 | 43 | |
44 | -@Configuration(prefix = "frameworkdemoiselle.handle") | |
44 | +@Configuration(prefix = "frameworkdemoiselle.handle.") | |
45 | 45 | public class ExceptionHandlerConfig implements Serializable { |
46 | 46 | |
47 | 47 | private static final long serialVersionUID = 1L; | ... | ... |
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/JsfSecurityConfig.java
... | ... | @@ -41,7 +41,7 @@ import java.io.Serializable; |
41 | 41 | import br.gov.frameworkdemoiselle.annotation.Name; |
42 | 42 | import br.gov.frameworkdemoiselle.configuration.Configuration; |
43 | 43 | |
44 | -@Configuration(prefix = "frameworkdemoiselle.security") | |
44 | +@Configuration(prefix = "frameworkdemoiselle.security.") | |
45 | 45 | public class JsfSecurityConfig implements Serializable { |
46 | 46 | |
47 | 47 | private static final long serialVersionUID = 1L; |
... | ... | @@ -49,7 +49,6 @@ public class JsfSecurityConfig implements Serializable { |
49 | 49 | @Name("login.page") |
50 | 50 | private String loginPage = "/login"; |
51 | 51 | |
52 | - // @Name("welcome.page") | |
53 | 52 | @Name("redirect.after.login") |
54 | 53 | private String redirectAfterLogin = "/index"; |
55 | 54 | ... | ... |
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ApplicationExceptionHandler.java
... | ... | @@ -108,7 +108,7 @@ public class ApplicationExceptionHandler extends AbstractExceptionHandler { |
108 | 108 | protected Throwable getRoot(final Throwable throwable) { |
109 | 109 | Throwable root = throwable; |
110 | 110 | |
111 | - while (!Exceptions.isApplicationException(root)) { | |
111 | + while (root != null && !Exceptions.isApplicationException(root)) { | |
112 | 112 | root = root.getCause(); |
113 | 113 | } |
114 | 114 | ... | ... |