Commit bcae1247972decad830ddab32fa4423fdc337ad7
1 parent
1db622de
Exists in
master
Definindo os pontos de log
Showing
13 changed files
with
147 additions
and
39 deletions
Show diff stats
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/CoreBootstrap.java
... | ... | @@ -77,14 +77,14 @@ public class CoreBootstrap implements Extension { |
77 | 77 | getLogger().info(getBundle().getString("engine-on")); |
78 | 78 | |
79 | 79 | Beans.setBeanManager(beanManager); |
80 | - getLogger().info(getBundle().getString("setting-up-bean-manager", Beans.class.getCanonicalName())); | |
80 | + getLogger().trace(getBundle().getString("setting-up-bean-manager", Beans.class.getCanonicalName())); | |
81 | 81 | } |
82 | 82 | |
83 | 83 | public void takeOff(@Observes final AfterDeploymentValidation event) { |
84 | - getLogger().info(getBundle().getString("taking-off")); | |
84 | + getLogger().trace(getBundle().getString("taking-off")); | |
85 | 85 | } |
86 | 86 | |
87 | 87 | public void engineOff(@Observes final BeforeShutdown event) { |
88 | - getLogger().info(getBundle().getString("engine-off")); | |
88 | + getLogger().trace(getBundle().getString("engine-off")); | |
89 | 89 | } |
90 | 90 | } | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/AbstractCustomContext.java
... | ... | @@ -121,17 +121,17 @@ public abstract class AbstractCustomContext implements CustomContext { |
121 | 121 | try{ |
122 | 122 | Context ctx = beanManager.getContext(this.getScope()); |
123 | 123 | if (ctx!=null){ |
124 | - getLogger().debug( getBundle().getString("custom-context-already-activated" , this.getClass().getCanonicalName() , this.getScope().getSimpleName() , ctx.getClass().getCanonicalName() ) ); | |
124 | + getLogger().trace( getBundle().getString("custom-context-already-activated" , this.getClass().getCanonicalName() , this.getScope().getSimpleName() , ctx.getClass().getCanonicalName() ) ); | |
125 | 125 | } |
126 | 126 | } |
127 | 127 | catch(ContextNotActiveException ce){ |
128 | 128 | success = this.active = true; |
129 | - getLogger().debug( getBundle().getString("custom-context-was-activated" , this.getClass().getCanonicalName() , this.getScope().getSimpleName() ) ); | |
129 | + getLogger().trace( getBundle().getString("custom-context-was-activated" , this.getClass().getCanonicalName() , this.getScope().getSimpleName() ) ); | |
130 | 130 | } |
131 | 131 | } |
132 | 132 | else{ |
133 | 133 | success = this.active = true; |
134 | - getLogger().debug( getBundle().getString("custom-context-was-activated" , this.getClass().getCanonicalName() , this.getScope().getSimpleName() ) ); | |
134 | + getLogger().trace( getBundle().getString("custom-context-was-activated" , this.getClass().getCanonicalName() , this.getScope().getSimpleName() ) ); | |
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
... | ... | @@ -152,7 +152,7 @@ public abstract class AbstractCustomContext implements CustomContext { |
152 | 152 | |
153 | 153 | Logger logger = getLogger(); |
154 | 154 | ResourceBundle bundle = getBundle(); |
155 | - logger.debug( bundle.getString("custom-context-was-deactivated" , this.getClass().getCanonicalName() , this.getScope().getSimpleName() ) ); | |
155 | + logger.trace( bundle.getString("custom-context-was-deactivated" , this.getClass().getCanonicalName() , this.getScope().getSimpleName() ) ); | |
156 | 156 | } |
157 | 157 | } |
158 | 158 | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/CustomContextProducer.java
... | ... | @@ -101,7 +101,7 @@ public class CustomContextProducer { |
101 | 101 | |
102 | 102 | if (!getContexts().contains(context)){ |
103 | 103 | getContexts().add(context); |
104 | - logger.debug( bundle.getString("bootstrap-context-added", context.getClass().getCanonicalName() , context.getScope().getSimpleName() ) ); | |
104 | + logger.trace( bundle.getString("bootstrap-context-added", context.getClass().getCanonicalName() , context.getScope().getSimpleName() ) ); | |
105 | 105 | } |
106 | 106 | else{ |
107 | 107 | logger.warn( bundle.getString("bootstrap-context-already-managed", context.getClass().getCanonicalName() , context.getScope().getSimpleName() ) ); |
... | ... | @@ -204,7 +204,7 @@ public class CustomContextProducer { |
204 | 204 | } |
205 | 205 | |
206 | 206 | if (producedContext!=null){ |
207 | - getLogger().debug( getBundle().getString("custom-context-selected" , producedContext.getClass().getCanonicalName()) ); | |
207 | + getLogger().trace( getBundle().getString("custom-context-selected" , producedContext.getClass().getCanonicalName()) ); | |
208 | 208 | } |
209 | 209 | |
210 | 210 | return producedContext; | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConfigurationImpl.java
... | ... | @@ -46,19 +46,21 @@ public class ConfigurationImpl implements Serializable { |
46 | 46 | private static final long serialVersionUID = 1L; |
47 | 47 | |
48 | 48 | @Ignore |
49 | - private boolean loaded = false; | |
49 | + private Boolean loaded = false; | |
50 | 50 | |
51 | 51 | @SuppressWarnings("unused") |
52 | - private synchronized void load(Object instance) throws Throwable { | |
53 | - if (!loaded) { | |
54 | - loaded = true; | |
52 | + private void load(Object instance) throws Throwable { | |
53 | + synchronized (loaded) { | |
54 | + if (!loaded) { | |
55 | + loaded = true; | |
55 | 56 | |
56 | - try { | |
57 | - Beans.getReference(ConfigurationLoader.class).load(instance); | |
57 | + try { | |
58 | + Beans.getReference(ConfigurationLoader.class).load(instance); | |
58 | 59 | |
59 | - } catch (Throwable cause) { | |
60 | - loaded = false; | |
61 | - throw cause; | |
60 | + } catch (Throwable cause) { | |
61 | + loaded = false; | |
62 | + throw cause; | |
63 | + } | |
62 | 64 | } |
63 | 65 | } |
64 | 66 | } | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConfigurationLoader.java
... | ... | @@ -100,11 +100,11 @@ public class ConfigurationLoader implements Serializable { |
100 | 100 | private Collection<Field> fields; |
101 | 101 | |
102 | 102 | public void load(Object object) throws ConfigurationException { |
103 | - load(object,true); | |
103 | + load(object, true); | |
104 | 104 | } |
105 | - | |
106 | - public void load(Object object,boolean logLoadingProcess) throws ConfigurationException { | |
107 | - if (logLoadingProcess){ | |
105 | + | |
106 | + public void load(Object object, boolean logLoadingProcess) throws ConfigurationException { | |
107 | + if (logLoadingProcess) { | |
108 | 108 | getLogger().debug(getBundle().getString("loading-configuration-class", object.getClass().getName())); |
109 | 109 | } |
110 | 110 | |
... | ... | @@ -223,7 +223,7 @@ public class ConfigurationLoader implements Serializable { |
223 | 223 | Object finalValue = (loadedValue == null ? defaultValue : loadedValue); |
224 | 224 | |
225 | 225 | if (loadedValue == null) { |
226 | - getLogger().debug(getBundle().getString("configuration-key-not-found", this.prefix + getKey(field))); | |
226 | + getLogger().trace(getBundle().getString("configuration-key-not-found", this.prefix + getKey(field))); | |
227 | 227 | } |
228 | 228 | |
229 | 229 | Reflections.setFieldValue(field, this.object, finalValue); |
... | ... | @@ -248,7 +248,8 @@ public class ConfigurationLoader implements Serializable { |
248 | 248 | } |
249 | 249 | |
250 | 250 | catch (Exception cause) { |
251 | - throw new ConfigurationException(getBundle().getString("configuration-generic-extraction-error", field.getType().toString(), getValueExtractor(field).getClass().getCanonicalName()), cause); | |
251 | + throw new ConfigurationException(getBundle().getString("configuration-generic-extraction-error", | |
252 | + field.getType().toString(), getValueExtractor(field).getClass().getCanonicalName()), cause); | |
252 | 253 | } |
253 | 254 | |
254 | 255 | return value; | ... | ... |
impl/core/src/main/resources/demoiselle-core-bundle.properties
... | ... | @@ -33,7 +33,7 @@ |
33 | 33 | # ou escreva para a Fundação do Software Livre (FSF) Inc., |
34 | 34 | # 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. |
35 | 35 | |
36 | -engine-on=Ligando os motores do Demoiselle ${project.version} | |
36 | +engine-on=Iniciando o Demoiselle Framework ${project.version} | |
37 | 37 | resource-not-found=Arquivo {0} n\u00E3o foi encontrado |
38 | 38 | key-not-found=A chave {0} n\u00E3o foi encontrada |
39 | 39 | ambiguous-strategy-resolution=Foi detectada ambiguidade da interface {0} com as seguintes implementa\u00E7\u00F5es\: {1}. Para resolver o conflito, defina explicitamente a implementa\u00E7\u00E3o no demoiselle.properties. |
... | ... | @@ -59,17 +59,17 @@ bootstrap-context-already-managed=O contexto {0} para o escopo {1} j\u00E1 foi a |
59 | 59 | bootstrap-context-added=Adicionando o contexto {0} para o escopo {1} |
60 | 60 | |
61 | 61 | loading-configuration-class=Carregando a classe de configura\u00E7\u00E3o {0} |
62 | -configuration-field-loaded=Configura\u00E7\u00E3o {0} atribu\u00EDda a {1} com o valor {2} | |
62 | +configuration-field-loaded={0}: {2} | |
63 | 63 | configuration-attribute-is-mandatory=A configura\u00E7\u00E3o {0} \u00E9 obrigat\u00F3ria, mas n\u00E3o foi encontrada em {1} |
64 | -configuration-name-attribute-cant-be-empty=A nota\u00E7\u00E3o Name n\u00E3o pode estar em branco | |
64 | +configuration-name-attribute-cant-be-empty=A nota\u00E7\u00E3o @Name n\u00E3o pode estar em branco | |
65 | 65 | configuration-generic-extraction-error=Ocorreu um erro durante a extra\u00E7\u00E3o do tipo {0} com o extrator {1} |
66 | 66 | configuration-dot-after-prefix=N\u00E3o \u00E9 necess\u00E1rio adicionar o ponto ap\u00F3s o prefixo para uma classe de configura\u00E7\u00E3o. \u00C9 recomendado que sejam retirados, pois poder\u00E3o causar erros em vers\u00F5es futuras do Framework. |
67 | -configuration-key-not-found=Chave de configura\u00E7\u00E3o {0} n\u00E3o encontrada | |
67 | +configuration-key-not-found={0}\: [n\u00E3o encontrada] | |
68 | 68 | configuration-extractor-not-found=N\u00E3o foi poss\u00EDvel encontrar a classe extratora para o atributo {0}. Implemente a interface {1} para criar sua classe extratora. |
69 | 69 | configuration-not-conversion=N\u00E3o \u00E9 poss\u00EDvel converter o valor {0} para o tipo {1} |
70 | 70 | |
71 | 71 | transaction-not-defined=Nenhuma transa\u00E7\u00E3o foi definida. Para utilizar @{0} \u00E9 preciso definir a propriedade frameworkdemoiselle.transaction.class com a estrat\u00E9gia de transa\u00E7\u00E3o desejada no arquivo demoiselle.properties |
72 | -executing-all=Executando todos os \: {0} | |
72 | +executing-all=Executando m\u00E9todos anotados com @{0} | |
73 | 73 | custom-context-selected=Produzindo inst\u00E2ncia do contexto {0} |
74 | 74 | custom-context-was-activated=O contexto {0} foi ativado para o escopo {1} |
75 | 75 | custom-context-was-deactivated=O contexto {0} foi desativado para o escopo {1} | ... | ... |
impl/extension/rest/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/AuthenticationExceptionMapper.java
... | ... | @@ -6,13 +6,28 @@ import javax.ws.rs.core.Response; |
6 | 6 | import javax.ws.rs.ext.ExceptionMapper; |
7 | 7 | import javax.ws.rs.ext.Provider; |
8 | 8 | |
9 | +import org.slf4j.Logger; | |
10 | + | |
9 | 11 | import br.gov.frameworkdemoiselle.security.AuthenticationException; |
12 | +import br.gov.frameworkdemoiselle.util.Beans; | |
13 | +import br.gov.frameworkdemoiselle.util.NameQualifier; | |
10 | 14 | |
11 | 15 | @Provider |
12 | 16 | public class AuthenticationExceptionMapper implements ExceptionMapper<AuthenticationException> { |
13 | 17 | |
18 | + private transient Logger logger; | |
19 | + | |
14 | 20 | @Override |
15 | 21 | public Response toResponse(AuthenticationException exception) { |
22 | + getLogger().info(exception.getMessage()); | |
16 | 23 | return Response.status(SC_UNAUTHORIZED).entity(exception.getMessage()).type("text/plain").build(); |
17 | 24 | } |
25 | + | |
26 | + private Logger getLogger() { | |
27 | + if (logger == null) { | |
28 | + logger = Beans.getReference(Logger.class, new NameQualifier(AuthenticationExceptionMapper.class.getName())); | |
29 | + } | |
30 | + | |
31 | + return logger; | |
32 | + } | |
18 | 33 | } | ... | ... |
impl/extension/rest/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/AuthorizationExceptionMapper.java
... | ... | @@ -6,13 +6,28 @@ import javax.ws.rs.core.Response; |
6 | 6 | import javax.ws.rs.ext.ExceptionMapper; |
7 | 7 | import javax.ws.rs.ext.Provider; |
8 | 8 | |
9 | +import org.slf4j.Logger; | |
10 | + | |
9 | 11 | import br.gov.frameworkdemoiselle.security.AuthorizationException; |
12 | +import br.gov.frameworkdemoiselle.util.Beans; | |
13 | +import br.gov.frameworkdemoiselle.util.NameQualifier; | |
10 | 14 | |
11 | 15 | @Provider |
12 | 16 | public class AuthorizationExceptionMapper implements ExceptionMapper<AuthorizationException> { |
13 | 17 | |
18 | + private transient Logger logger; | |
19 | + | |
14 | 20 | @Override |
15 | 21 | public Response toResponse(AuthorizationException exception) { |
22 | + getLogger().info(exception.getMessage()); | |
16 | 23 | return Response.status(SC_FORBIDDEN).build(); |
17 | 24 | } |
25 | + | |
26 | + private Logger getLogger() { | |
27 | + if (logger == null) { | |
28 | + logger = Beans.getReference(Logger.class, new NameQualifier(AuthorizationExceptionMapper.class.getName())); | |
29 | + } | |
30 | + | |
31 | + return logger; | |
32 | + } | |
18 | 33 | } | ... | ... |
impl/extension/rest/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConstraintViolationExceptionMapper.java
... | ... | @@ -8,21 +8,47 @@ import javax.ws.rs.core.Response; |
8 | 8 | import javax.ws.rs.ext.ExceptionMapper; |
9 | 9 | import javax.ws.rs.ext.Provider; |
10 | 10 | |
11 | +import org.slf4j.Logger; | |
12 | + | |
11 | 13 | import br.gov.frameworkdemoiselle.UnprocessableEntityException; |
14 | +import br.gov.frameworkdemoiselle.util.Beans; | |
15 | +import br.gov.frameworkdemoiselle.util.NameQualifier; | |
16 | +import br.gov.frameworkdemoiselle.util.ResourceBundle; | |
12 | 17 | |
13 | 18 | @Provider |
14 | 19 | public class ConstraintViolationExceptionMapper implements ExceptionMapper<ConstraintViolationException> { |
15 | 20 | |
21 | + private transient ResourceBundle bundle; | |
22 | + | |
23 | + private transient Logger logger; | |
24 | + | |
16 | 25 | @Override |
17 | 26 | public Response toResponse(ConstraintViolationException exception) { |
18 | 27 | UnprocessableEntityException failed = new UnprocessableEntityException(); |
28 | + int status = new UnprocessableEntityException().getStatusCode(); | |
19 | 29 | |
20 | 30 | for (Iterator<ConstraintViolation<?>> iter = exception.getConstraintViolations().iterator(); iter.hasNext();) { |
21 | 31 | ConstraintViolation<?> violation = iter.next(); |
22 | 32 | failed.addViolation(violation.getPropertyPath().toString(), violation.getMessage()); |
23 | 33 | } |
24 | 34 | |
25 | - int status = new UnprocessableEntityException().getStatusCode(); | |
35 | + getLogger().debug(getBundle().getString("mapping-violations", status, failed.getViolations().toString())); | |
26 | 36 | return Response.status(status).entity(failed.getViolations()).build(); |
27 | 37 | } |
38 | + | |
39 | + private ResourceBundle getBundle() { | |
40 | + if (bundle == null) { | |
41 | + bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-rest-bundle")); | |
42 | + } | |
43 | + | |
44 | + return bundle; | |
45 | + } | |
46 | + | |
47 | + private Logger getLogger() { | |
48 | + if (logger == null) { | |
49 | + logger = Beans.getReference(Logger.class, new NameQualifier(HttpViolationExceptionMapper.class.getName())); | |
50 | + } | |
51 | + | |
52 | + return logger; | |
53 | + } | |
28 | 54 | } | ... | ... |
impl/extension/rest/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultExceptionMapper.java
... | ... | @@ -16,14 +16,31 @@ import br.gov.frameworkdemoiselle.util.NameQualifier; |
16 | 16 | @Provider |
17 | 17 | public class DefaultExceptionMapper implements ExceptionMapper<Throwable> { |
18 | 18 | |
19 | + private transient ResourceBundle bundle; | |
20 | + | |
21 | + private transient Logger logger; | |
22 | + | |
19 | 23 | @Override |
20 | 24 | public Response toResponse(Throwable exception) { |
21 | - ResourceBundle bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-rest-bundle")); | |
22 | - Logger logger = Beans.getReference(Logger.class); | |
23 | - | |
24 | - logger.error(exception.getMessage(), exception); | |
25 | + String message = getBundle().getString("internal.server.error"); | |
26 | + getLogger().error(message, exception); | |
25 | 27 | |
26 | - String message = bundle.getString("internal.server.error"); | |
27 | 28 | return Response.status(INTERNAL_SERVER_ERROR).entity(message).build(); |
28 | 29 | } |
30 | + | |
31 | + private ResourceBundle getBundle() { | |
32 | + if (bundle == null) { | |
33 | + bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-rest-bundle")); | |
34 | + } | |
35 | + | |
36 | + return bundle; | |
37 | + } | |
38 | + | |
39 | + private Logger getLogger() { | |
40 | + if (logger == null) { | |
41 | + logger = Beans.getReference(Logger.class, new NameQualifier(DefaultExceptionMapper.class.getName())); | |
42 | + } | |
43 | + | |
44 | + return logger; | |
45 | + } | |
29 | 46 | } | ... | ... |
impl/extension/rest/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/HttpViolationExceptionMapper.java
... | ... | @@ -6,17 +6,48 @@ import javax.ws.rs.core.Response; |
6 | 6 | import javax.ws.rs.ext.ExceptionMapper; |
7 | 7 | import javax.ws.rs.ext.Provider; |
8 | 8 | |
9 | +import org.slf4j.Logger; | |
10 | + | |
9 | 11 | import br.gov.frameworkdemoiselle.HttpViolationException; |
10 | 12 | import br.gov.frameworkdemoiselle.HttpViolationException.Violation; |
13 | +import br.gov.frameworkdemoiselle.util.Beans; | |
14 | +import br.gov.frameworkdemoiselle.util.NameQualifier; | |
15 | +import br.gov.frameworkdemoiselle.util.ResourceBundle; | |
11 | 16 | |
12 | 17 | @Provider |
13 | 18 | public class HttpViolationExceptionMapper implements ExceptionMapper<HttpViolationException> { |
14 | 19 | |
20 | + private transient ResourceBundle bundle; | |
21 | + | |
22 | + private transient Logger logger; | |
23 | + | |
15 | 24 | @Override |
16 | 25 | public Response toResponse(HttpViolationException exception) { |
17 | 26 | Set<Violation> violations = exception.getViolations(); |
18 | - violations = violations.isEmpty() ? null : violations; | |
27 | + int status = exception.getStatusCode(); | |
28 | + | |
29 | + if (violations.isEmpty()) { | |
30 | + violations = null; | |
31 | + } else { | |
32 | + getLogger().debug(getBundle().getString("mapping-violations", status, violations.toString())); | |
33 | + } | |
34 | + | |
35 | + return Response.status(status).entity(violations).build(); | |
36 | + } | |
37 | + | |
38 | + private ResourceBundle getBundle() { | |
39 | + if (bundle == null) { | |
40 | + bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-rest-bundle")); | |
41 | + } | |
42 | + | |
43 | + return bundle; | |
44 | + } | |
45 | + | |
46 | + private Logger getLogger() { | |
47 | + if (logger == null) { | |
48 | + logger = Beans.getReference(Logger.class, new NameQualifier(HttpViolationExceptionMapper.class.getName())); | |
49 | + } | |
19 | 50 | |
20 | - return Response.status(exception.getStatusCode()).entity(violations).build(); | |
51 | + return logger; | |
21 | 52 | } |
22 | 53 | } | ... | ... |
impl/extension/rest/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/SessionNotPermittedListener.java
... | ... | @@ -9,8 +9,8 @@ public class SessionNotPermittedListener implements HttpSessionListener { |
9 | 9 | |
10 | 10 | @Override |
11 | 11 | public void sessionCreated(HttpSessionEvent event) { |
12 | -// event.getSession().invalidate(); | |
13 | -// throw new IllegalStateException("Session use is not permitted."); | |
12 | + // event.getSession().invalidate(); | |
13 | + // throw new IllegalStateException("Session use is not permitted."); | |
14 | 14 | } |
15 | 15 | |
16 | 16 | @Override | ... | ... |
impl/extension/rest/src/main/resources/demoiselle-rest-bundle.properties