Commit 0ef1383de600f7d5b82b3465ceccadcb68114a5f
1 parent
51cafbf3
Exists in
master
Melhoria nas mensagens de erro e log
Showing
2 changed files
with
13 additions
and
8 deletions
Show diff stats
impl/extension/jdbc/src/main/java/br/gov/frameworkdemoiselle/internal/producer/ConnectionProducer.java
... | ... | @@ -71,8 +71,7 @@ public class ConnectionProducer implements Serializable { |
71 | 71 | |
72 | 72 | } catch (Exception cause) { |
73 | 73 | // TODO Colocar uma mensagem amigável |
74 | - | |
75 | - throw new DemoiselleException("", cause); | |
74 | + throw new DemoiselleException(cause); | |
76 | 75 | } |
77 | 76 | } |
78 | 77 | |
... | ... | @@ -131,20 +130,23 @@ public class ConnectionProducer implements Serializable { |
131 | 130 | |
132 | 131 | @PreDestroy |
133 | 132 | public void close() { |
134 | - for (Connection connection : cache.values()) { | |
133 | + Connection connection; | |
134 | + | |
135 | + for (String key : cache.keySet()) { | |
136 | + connection = cache.get(key); | |
137 | + | |
135 | 138 | try { |
136 | 139 | if (connection.isClosed()) { |
137 | - // TODO Logar um warning informando que a conexão já havia sido finalizada. | |
140 | + logger.warn(bundle.getString("connection-has-already-been-closed", key)); | |
138 | 141 | |
139 | 142 | } else { |
140 | 143 | connection.close(); |
141 | - // TODO Logar um info informando que a conexão foi finalizada. | |
144 | + | |
145 | + logger.info(bundle.getString("connection-was-closed", key)); | |
142 | 146 | } |
143 | 147 | |
144 | 148 | } catch (Exception cause) { |
145 | - // TODO Colocar uma mensagem amigável | |
146 | - | |
147 | - throw new DemoiselleException("", cause); | |
149 | + throw new DemoiselleException(bundle.getString("connection-close-failed", key), cause); | |
148 | 150 | } |
149 | 151 | } |
150 | 152 | ... | ... |
impl/extension/jdbc/src/main/resources/demoiselle-jdbc-bundle.properties
... | ... | @@ -34,6 +34,9 @@ |
34 | 34 | # 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. |
35 | 35 | |
36 | 36 | more-than-one-datasource-defined=Existe mais de um banco de dados definido. Utilize @{0} no ponto de inje\u00E7\u00E3o ou defina o atributo "frameworkdemoiselle.persistence.default.datasource.name" no arquivo demoiselle.properties. |
37 | +connection-was-closed=A conex\u00E3o "{0}" foi fechada. | |
38 | +connection-has-already-been-closed=A conex\u00E3o "{0}" j\u00E1 havia sido fechada. | |
39 | +connection-close-failed=Falha ao tentar fechar a conex\u00E3o "{0}" | |
37 | 40 | set-autocommit-failed=Falha ao tentar executar connection.setAutoCommit(false) numa transa\u00E7\u00E3o gerenciada. N\u00E3o se preocupe, este comportamento \u00E9 esperado. |
38 | 41 | load-jndi-datasource-failed=Falha ao tentar obter a conex\u00E3o "{0}" via JNDI. |
39 | 42 | load-duplicated-configuration-failed=Falha no carregamento das configura\u00E7\u00F5es JDBC. Verifique se existem valores duplicados indevidamente no demoiselle.properties. | ... | ... |