Commit 8f6aabb76719734a5953d14e7667273dbf3a599a
1 parent
2b60ea3f
Exists in
master
Renomeando a classe de configuração
Showing
4 changed files
with
99 additions
and
98 deletions
Show diff stats
impl/extension/jdbc/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/JDBCConfig.java
0 → 100644
| ... | ... | @@ -0,0 +1,91 @@ |
| 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.configuration; | |
| 38 | + | |
| 39 | +import java.io.Serializable; | |
| 40 | +import java.util.Map; | |
| 41 | + | |
| 42 | +import br.gov.frameworkdemoiselle.annotation.Name; | |
| 43 | +import br.gov.frameworkdemoiselle.configuration.Configuration; | |
| 44 | + | |
| 45 | +@Configuration(prefix = "frameworkdemoiselle.persistence.") | |
| 46 | +public class JDBCConfig implements Serializable { | |
| 47 | + | |
| 48 | + private static final long serialVersionUID = 1L; | |
| 49 | + | |
| 50 | + @Name("default.datasource.name") | |
| 51 | + private String defaultDataDourceName; | |
| 52 | + | |
| 53 | + @Name("jndi.name") | |
| 54 | + private Map<String, String> jndiName; | |
| 55 | + | |
| 56 | + @Name("driver.class") | |
| 57 | + private Map<String, String> driverClass; | |
| 58 | + | |
| 59 | + @Name("url") | |
| 60 | + private Map<String, String> url; | |
| 61 | + | |
| 62 | + @Name("username") | |
| 63 | + private Map<String, String> username; | |
| 64 | + | |
| 65 | + @Name("password") | |
| 66 | + private Map<String, String> password; | |
| 67 | + | |
| 68 | + public String getDefaultDataDourceName() { | |
| 69 | + return defaultDataDourceName; | |
| 70 | + } | |
| 71 | + | |
| 72 | + public Map<String, String> getJndiName() { | |
| 73 | + return jndiName; | |
| 74 | + } | |
| 75 | + | |
| 76 | + public Map<String, String> getDriverClass() { | |
| 77 | + return driverClass; | |
| 78 | + } | |
| 79 | + | |
| 80 | + public Map<String, String> getUrl() { | |
| 81 | + return url; | |
| 82 | + } | |
| 83 | + | |
| 84 | + public Map<String, String> getUsername() { | |
| 85 | + return username; | |
| 86 | + } | |
| 87 | + | |
| 88 | + public Map<String, String> getPassword() { | |
| 89 | + return password; | |
| 90 | + } | |
| 91 | +} | ... | ... |
impl/extension/jdbc/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/JdbcConfig.java
| ... | ... | @@ -1,91 +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.configuration; | |
| 38 | - | |
| 39 | -import java.io.Serializable; | |
| 40 | -import java.util.Map; | |
| 41 | - | |
| 42 | -import br.gov.frameworkdemoiselle.annotation.Name; | |
| 43 | -import br.gov.frameworkdemoiselle.configuration.Configuration; | |
| 44 | - | |
| 45 | -@Configuration(prefix = "frameworkdemoiselle.persistence.") | |
| 46 | -public class JdbcConfig implements Serializable { | |
| 47 | - | |
| 48 | - private static final long serialVersionUID = 1L; | |
| 49 | - | |
| 50 | - @Name("default.datasource.name") | |
| 51 | - private String defaultDataDourceName; | |
| 52 | - | |
| 53 | - @Name("jndi.name") | |
| 54 | - private Map<String, String> jndiName; | |
| 55 | - | |
| 56 | - @Name("driver.class") | |
| 57 | - private Map<String, String> driverClass; | |
| 58 | - | |
| 59 | - @Name("url") | |
| 60 | - private Map<String, String> url; | |
| 61 | - | |
| 62 | - @Name("username") | |
| 63 | - private Map<String, String> username; | |
| 64 | - | |
| 65 | - @Name("password") | |
| 66 | - private Map<String, String> password; | |
| 67 | - | |
| 68 | - public String getDefaultDataDourceName() { | |
| 69 | - return defaultDataDourceName; | |
| 70 | - } | |
| 71 | - | |
| 72 | - public Map<String, String> getJndiName() { | |
| 73 | - return jndiName; | |
| 74 | - } | |
| 75 | - | |
| 76 | - public Map<String, String> getDriverClass() { | |
| 77 | - return driverClass; | |
| 78 | - } | |
| 79 | - | |
| 80 | - public Map<String, String> getUrl() { | |
| 81 | - return url; | |
| 82 | - } | |
| 83 | - | |
| 84 | - public Map<String, String> getUsername() { | |
| 85 | - return username; | |
| 86 | - } | |
| 87 | - | |
| 88 | - public Map<String, String> getPassword() { | |
| 89 | - return password; | |
| 90 | - } | |
| 91 | -} |
impl/extension/jdbc/src/main/java/br/gov/frameworkdemoiselle/internal/producer/ConnectionProducer.java
| ... | ... | @@ -19,7 +19,7 @@ import org.slf4j.Logger; |
| 19 | 19 | |
| 20 | 20 | import br.gov.frameworkdemoiselle.DemoiselleException; |
| 21 | 21 | import br.gov.frameworkdemoiselle.annotation.Name; |
| 22 | -import br.gov.frameworkdemoiselle.internal.configuration.JdbcConfig; | |
| 22 | +import br.gov.frameworkdemoiselle.internal.configuration.JDBCConfig; | |
| 23 | 23 | import br.gov.frameworkdemoiselle.internal.proxy.ConnectionProxy; |
| 24 | 24 | import br.gov.frameworkdemoiselle.util.ResourceBundle; |
| 25 | 25 | |
| ... | ... | @@ -49,7 +49,7 @@ public class ConnectionProducer implements Serializable { |
| 49 | 49 | |
| 50 | 50 | @Default |
| 51 | 51 | @Produces |
| 52 | - public Connection create(InjectionPoint ip, JdbcConfig config) { | |
| 52 | + public Connection create(InjectionPoint ip, JDBCConfig config) { | |
| 53 | 53 | String name = getName(ip, config); |
| 54 | 54 | return new ConnectionProxy(name); |
| 55 | 55 | } |
| ... | ... | @@ -63,6 +63,7 @@ public class ConnectionProducer implements Serializable { |
| 63 | 63 | } else { |
| 64 | 64 | try { |
| 65 | 65 | result = producer.create(name).getConnection(); |
| 66 | + result.setAutoCommit(false); | |
| 66 | 67 | |
| 67 | 68 | cache.put(name, result); |
| 68 | 69 | this.logger.info(bundle.getString("connection-was-created", name)); |
| ... | ... | @@ -77,7 +78,7 @@ public class ConnectionProducer implements Serializable { |
| 77 | 78 | return result; |
| 78 | 79 | } |
| 79 | 80 | |
| 80 | - private String getName(InjectionPoint ip, JdbcConfig config) { | |
| 81 | + private String getName(InjectionPoint ip, JDBCConfig config) { | |
| 81 | 82 | String result; |
| 82 | 83 | |
| 83 | 84 | if (ip != null && ip.getAnnotated() != null && ip.getAnnotated().isAnnotationPresent(Name.class)) { |
| ... | ... | @@ -96,7 +97,7 @@ public class ConnectionProducer implements Serializable { |
| 96 | 97 | return result; |
| 97 | 98 | } |
| 98 | 99 | |
| 99 | - private String getNameFromProperties(JdbcConfig config) { | |
| 100 | + private String getNameFromProperties(JDBCConfig config) { | |
| 100 | 101 | String result = config.getDefaultDataDourceName(); |
| 101 | 102 | |
| 102 | 103 | if (result != null) { | ... | ... |
impl/extension/jdbc/src/main/java/br/gov/frameworkdemoiselle/internal/producer/DataSourceProducer.java
| ... | ... | @@ -20,7 +20,7 @@ import org.slf4j.Logger; |
| 20 | 20 | |
| 21 | 21 | import br.gov.frameworkdemoiselle.DemoiselleException; |
| 22 | 22 | import br.gov.frameworkdemoiselle.annotation.Name; |
| 23 | -import br.gov.frameworkdemoiselle.internal.configuration.JdbcConfig; | |
| 23 | +import br.gov.frameworkdemoiselle.internal.configuration.JDBCConfig; | |
| 24 | 24 | import br.gov.frameworkdemoiselle.util.Beans; |
| 25 | 25 | import br.gov.frameworkdemoiselle.util.ResourceBundle; |
| 26 | 26 | |
| ... | ... | @@ -58,7 +58,7 @@ public class DataSourceProducer implements Serializable { |
| 58 | 58 | private Set<String> getDataSourceNames(ClassLoader classLoader) { |
| 59 | 59 | Set<String> result = new HashSet<String>(); |
| 60 | 60 | |
| 61 | - JdbcConfig config = Beans.getReference(JdbcConfig.class); | |
| 61 | + JDBCConfig config = Beans.getReference(JDBCConfig.class); | |
| 62 | 62 | |
| 63 | 63 | if (config.getJndiName() != null) { |
| 64 | 64 | result.addAll(config.getJndiName().keySet()); |
| ... | ... | @@ -109,7 +109,7 @@ public class DataSourceProducer implements Serializable { |
| 109 | 109 | DataSource result; |
| 110 | 110 | |
| 111 | 111 | try { |
| 112 | - JdbcConfig config = Beans.getReference(JdbcConfig.class); | |
| 112 | + JDBCConfig config = Beans.getReference(JDBCConfig.class); | |
| 113 | 113 | Map<String, String> jndiMap = config.getJndiName(); |
| 114 | 114 | |
| 115 | 115 | if (jndiMap != null) { | ... | ... |