From 682c0642e230b6859c17edeb6f649d31e907700b Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Tue, 17 Nov 2015 10:21:58 -0600 Subject: [PATCH] HHH-10178 - Move Geronimo JTA jar to provided configuration (non-transitive) (cherry picked from commit 4793ca30a2f1d16691b3dcc1976dc78c7ef9d7ba) --- .../c3p0/internal/C3P0MessageLogger.java | 3 +- hibernate-core/hibernate-core.gradle | 4 +- .../DriverManagerConnectionProviderImpl.java | 5 +- .../hibernate/internal/CoreMessageLogger.java | 35 +-------- .../internal/log/ConnectionPoolingLogger.java | 71 +++++++++++++++++++ hibernate-ehcache/hibernate-ehcache.gradle | 1 + .../hibernate-entitymanager.gradle | 3 +- hibernate-envers/hibernate-envers.gradle | 2 + .../hibernate-infinispan.gradle | 2 + hibernate-osgi/hibernate-osgi.gradle | 1 + .../internal/ProxoolConnectionProvider.java | 2 +- .../internal/ProxoolMessageLogger.java | 14 ++-- 12 files changed, 91 insertions(+), 52 deletions(-) create mode 100644 hibernate-core/src/main/java/org/hibernate/internal/log/ConnectionPoolingLogger.java diff --git a/hibernate-c3p0/src/main/java/org/hibernate/c3p0/internal/C3P0MessageLogger.java b/hibernate-c3p0/src/main/java/org/hibernate/c3p0/internal/C3P0MessageLogger.java index 37309c41ae..44a1cde28f 100644 --- a/hibernate-c3p0/src/main/java/org/hibernate/c3p0/internal/C3P0MessageLogger.java +++ b/hibernate-c3p0/src/main/java/org/hibernate/c3p0/internal/C3P0MessageLogger.java @@ -9,6 +9,7 @@ package org.hibernate.c3p0.internal; import java.sql.SQLException; import org.hibernate.internal.CoreMessageLogger; +import org.hibernate.internal.log.ConnectionPoolingLogger; import org.jboss.logging.annotations.Cause; import org.jboss.logging.annotations.LogMessage; @@ -25,7 +26,7 @@ import static org.jboss.logging.Logger.Level.WARN; * New messages must be added after the last message defined to ensure message codes are unique. */ @MessageLogger(projectCode = "HHH") -public interface C3P0MessageLogger extends CoreMessageLogger { +public interface C3P0MessageLogger extends ConnectionPoolingLogger { /** * Log a message (WARN) about conflicting {@code hibernate.c3p0.XYZ} and {@code c3p0.XYZ} settings diff --git a/hibernate-core/hibernate-core.gradle b/hibernate-core/hibernate-core.gradle index a8d9b5037f..78dc7c3bf8 100644 --- a/hibernate-core/hibernate-core.gradle +++ b/hibernate-core/hibernate-core.gradle @@ -15,7 +15,6 @@ dependencies { compile( libraries.javassist ) compile( libraries.antlr ) compile( libraries.jandex ) - compile( libraries.jta ) // We need dom4j for a number of things temporarily: // 1) (unsupported) EntityMode.DOM4J support @@ -26,9 +25,10 @@ dependencies { antlr( libraries.antlr ) - provided( libraries.ant ) + provided( libraries.jta ) provided( libraries.jacc ) provided( libraries.validation ) + provided( libraries.ant ) provided( libraries.classmate ) testCompile( project(':hibernate-testing') ) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DriverManagerConnectionProviderImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DriverManagerConnectionProviderImpl.java index b7c8f43057..80dc60b29c 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DriverManagerConnectionProviderImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DriverManagerConnectionProviderImpl.java @@ -19,8 +19,7 @@ import org.hibernate.HibernateException; import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.cfg.AvailableSettings; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; -import org.hibernate.internal.CoreLogging; -import org.hibernate.internal.CoreMessageLogger; +import org.hibernate.internal.log.ConnectionPoolingLogger; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.service.UnknownUnwrapTypeException; import org.hibernate.service.spi.Configurable; @@ -44,7 +43,7 @@ import org.hibernate.service.spi.Stoppable; public class DriverManagerConnectionProviderImpl implements ConnectionProvider, Configurable, Stoppable, ServiceRegistryAwareService { - private static final CoreMessageLogger log = CoreLogging.messageLogger( DriverManagerConnectionProviderImpl.class ); + private static final ConnectionPoolingLogger log = ConnectionPoolingLogger.CONNECTIONS_LOGGER; public static final String MIN_SIZE = "hibernate.connection.min_pool_size"; public static final String INITIAL_SIZE = "hibernate.connection.initial_pool_size"; diff --git a/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java b/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java index da111a8979..5665248de6 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java @@ -67,7 +67,7 @@ public interface CoreMessageLogger extends BasicLogger { void autoCommitMode(boolean autocommit); @LogMessage(level = WARN) - @Message(value = "JTASessionContext being used with JDBCTransactionFactory; auto-flush will not operate correctly with getCurrentSession()", + @Message(value = "JTASessionContext being used with JDBC transactions; auto-flush will not operate correctly with getCurrentSession()", id = 8) void autoFlushWillNotWork(); @@ -96,10 +96,6 @@ public interface CoreMessageLogger extends BasicLogger { @Message(value = "Calling joinTransaction() on a non JTA EntityManager", id = 27) void callingJoinTransactionOnNonJtaEntityManager(); - @LogMessage(level = INFO) - @Message(value = "Cleaning up connection pool [%s]", id = 30) - void cleaningUpConnectionPool(String url); - @LogMessage(level = DEBUG) @Message(value = "Closing", id = 31) void closing(); @@ -160,10 +156,6 @@ public interface CoreMessageLogger extends BasicLogger { @Message(value = "Configuring from XML document", id = 45) void configuringFromXmlDocument(); - @LogMessage(level = INFO) - @Message(value = "Connection properties: %s", id = 46) - void connectionProperties(Properties connectionProps); - @LogMessage(level = INFO) @Message(value = "Connections obtained: %s", id = 48) void connectionsObtained(long connectCount); @@ -483,20 +475,9 @@ public interface CoreMessageLogger extends BasicLogger { @Message(value = "%s = false breaks the EJB3 specification", id = 144) void jdbcAutoCommitFalseBreaksEjb3Spec(String autocommit); - @LogMessage(level = WARN) - @Message(value = "No JDBC Driver class was specified by property %s", id = 148) - void jdbcDriverNotSpecified(String driver); - - @LogMessage(level = INFO) - @Message(value = "JDBC isolation level: %s", id = 149) - void jdbcIsolationLevel(String isolationLevelToString); - @Message(value = "JDBC rollback failed", id = 151) String jdbcRollbackFailed(); - @Message(value = "JDBC URL was not specified by property %s", id = 152) - String jdbcUrlNotSpecified(String url); - @LogMessage(level = INFO) @Message(value = "JNDI InitialContext properties:%s", id = 154) void jndiInitialContextProperties(Hashtable hash); @@ -992,10 +973,6 @@ public interface CoreMessageLogger extends BasicLogger { @Message(value = "IOException occurred closing output stream", id = 292) void unableToCloseOutputStream(@Cause IOException e); - @LogMessage(level = WARN) - @Message(value = "Problem closing pooled connection", id = 293) - void unableToClosePooledConnection(@Cause SQLException e); - @LogMessage(level = ERROR) @Message(value = "Could not close session", id = 294) void unableToCloseSession(@Cause HibernateException e); @@ -1437,16 +1414,6 @@ public interface CoreMessageLogger extends BasicLogger { @Message(value = "Using dialect: %s", id = 400) void usingDialect(Dialect dialect); - @LogMessage(level = INFO) - @Message(value = "using driver [%s] at URL [%s]", id = 401) - void usingDriver( - String driverClassName, - String url); - - @LogMessage(level = WARN) - @Message(value = "Using Hibernate built-in connection pool (not for production use!)", id = 402) - void usingHibernateBuiltInConnectionPool(); - @LogMessage(level = ERROR) @Message(value = "Don't use old DTDs, read the Hibernate 3.x Migration Guide!", id = 404) void usingOldDtd(); diff --git a/hibernate-core/src/main/java/org/hibernate/internal/log/ConnectionPoolingLogger.java b/hibernate-core/src/main/java/org/hibernate/internal/log/ConnectionPoolingLogger.java new file mode 100644 index 0000000000..b23a5d955d --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/internal/log/ConnectionPoolingLogger.java @@ -0,0 +1,71 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.internal.log; + +import java.sql.SQLException; +import java.util.Properties; + +import org.jboss.logging.BasicLogger; +import org.jboss.logging.Logger; +import org.jboss.logging.annotations.Cause; +import org.jboss.logging.annotations.LogMessage; +import org.jboss.logging.annotations.Message; +import org.jboss.logging.annotations.MessageLogger; +import org.jboss.logging.annotations.ValidIdRange; + +import static org.jboss.logging.Logger.Level.INFO; +import static org.jboss.logging.Logger.Level.WARN; + +/** + * @author Steve Ebersole + */ +@MessageLogger( projectCode = "HHH" ) +@ValidIdRange( min = 10001001, max = 10001500 ) +public interface ConnectionPoolingLogger extends BasicLogger { + /** + * Static access to the logging instance + */ + public static final ConnectionPoolingLogger CONNECTIONS_LOGGER = Logger.getMessageLogger( + ConnectionPoolingLogger.class, + "org.hibernate.orm.connections" + ); + + @LogMessage(level = INFO) + @Message(value = "Connection properties: %s", id = 10001001) + void connectionProperties(Properties connectionProps); + + @LogMessage(level = WARN) + @Message(value = "Using Hibernate built-in connection pool (not for production use!)", id = 10001002) + void usingHibernateBuiltInConnectionPool(); + + @LogMessage(level = INFO) + @Message(value = "Autocommit mode: %s", id = 10001003) + void autoCommitMode(boolean autocommit); + + @Message(value = "JDBC URL was not specified by property %s", id = 10001004) + String jdbcUrlNotSpecified(String url); + + @LogMessage(level = INFO) + @Message(value = "using driver [%s] at URL [%s]", id = 10001005) + void usingDriver(String driverClassName, String url); + + @LogMessage(level = WARN) + @Message(value = "No JDBC Driver class was specified by property %s", id = 10001006) + void jdbcDriverNotSpecified(String driver); + + @LogMessage(level = INFO) + @Message(value = "JDBC isolation level: %s", id = 10001007) + void jdbcIsolationLevel(String isolationLevelToString); + + @LogMessage(level = INFO) + @Message(value = "Cleaning up connection pool [%s]", id = 10001008) + void cleaningUpConnectionPool(String url); + + @LogMessage(level = WARN) + @Message(value = "Problem closing pooled connection", id = 10001009) + void unableToClosePooledConnection(@Cause SQLException e); +} diff --git a/hibernate-ehcache/hibernate-ehcache.gradle b/hibernate-ehcache/hibernate-ehcache.gradle index 516b44fd0d..a8a91dd45d 100644 --- a/hibernate-ehcache/hibernate-ehcache.gradle +++ b/hibernate-ehcache/hibernate-ehcache.gradle @@ -7,6 +7,7 @@ dependencies { compile project( ':hibernate-core' ) compile( libraries.ehcache ) + provided( libraries.jta ) testCompile project( ':hibernate-testing' ) } diff --git a/hibernate-entitymanager/hibernate-entitymanager.gradle b/hibernate-entitymanager/hibernate-entitymanager.gradle index bf151386cb..d5cca76e40 100755 --- a/hibernate-entitymanager/hibernate-entitymanager.gradle +++ b/hibernate-entitymanager/hibernate-entitymanager.gradle @@ -22,9 +22,10 @@ dependencies { compile( libraries.dom4j ) compile( libraries.commons_annotations ) compile( libraries.jpa ) - compile( libraries.jta ) compile( libraries.javassist ) + provided( libraries.jta ) + provided( "javax.enterprise:cdi-api:1.1-PFD" ) testCompile( project(':hibernate-testing') ) diff --git a/hibernate-envers/hibernate-envers.gradle b/hibernate-envers/hibernate-envers.gradle index 10d0b458ac..d391eef26b 100644 --- a/hibernate-envers/hibernate-envers.gradle +++ b/hibernate-envers/hibernate-envers.gradle @@ -10,6 +10,8 @@ dependencies { compile( project( ':hibernate-core' ) ) compile( project( ':hibernate-entitymanager' ) ) + provided( libraries.jta ) + provided( [group: 'org.hibernate', name: 'hibernate-tools', version: '3.2.0.ga'] ) provided( libraries.ant ) provided( project( ':hibernate-jpamodelgen' ) ) diff --git a/hibernate-infinispan/hibernate-infinispan.gradle b/hibernate-infinispan/hibernate-infinispan.gradle index 92cd351cb5..6f52b8adc3 100644 --- a/hibernate-infinispan/hibernate-infinispan.gradle +++ b/hibernate-infinispan/hibernate-infinispan.gradle @@ -18,6 +18,8 @@ dependencies { compile( libraries.infinispan ) compile( libraries.rhq ) + provided( libraries.jta ) + testCompile project( ':hibernate-testing' ) testCompile( libraries.infinispan_test ) testCompile( libraries.jboss_common_core ) diff --git a/hibernate-osgi/hibernate-osgi.gradle b/hibernate-osgi/hibernate-osgi.gradle index 225641c0a8..5512235300 100644 --- a/hibernate-osgi/hibernate-osgi.gradle +++ b/hibernate-osgi/hibernate-osgi.gradle @@ -44,6 +44,7 @@ dependencies { compile( project( ':hibernate-core' ) ) compile( project( ':hibernate-entitymanager' ) ) + compile( libraries.jta ) // MUST use 4.3.1! 4.3.0 was compiled with "-target jsr14". // http://blog.osgi.org/2012/10/43-companion-code-for-java-7.html diff --git a/hibernate-proxool/src/main/java/org/hibernate/proxool/internal/ProxoolConnectionProvider.java b/hibernate-proxool/src/main/java/org/hibernate/proxool/internal/ProxoolConnectionProvider.java index b3d9c6ccf1..7b4c8b6ea0 100644 --- a/hibernate-proxool/src/main/java/org/hibernate/proxool/internal/ProxoolConnectionProvider.java +++ b/hibernate-proxool/src/main/java/org/hibernate/proxool/internal/ProxoolConnectionProvider.java @@ -193,7 +193,7 @@ public class ProxoolConnectionProvider LOG.jdbcIsolationLevel( ConnectionProviderInitiator.toIsolationNiceName( isolation ) ); autocommit = ConfigurationHelper.getBoolean( Environment.AUTOCOMMIT, props ); - LOG.autoCommmitMode( autocommit ); + LOG.autoCommitMode( autocommit ); } private Reader getConfigStreamReader(String resource) { diff --git a/hibernate-proxool/src/main/java/org/hibernate/proxool/internal/ProxoolMessageLogger.java b/hibernate-proxool/src/main/java/org/hibernate/proxool/internal/ProxoolMessageLogger.java index 7eb242d468..a091cc4e7e 100644 --- a/hibernate-proxool/src/main/java/org/hibernate/proxool/internal/ProxoolMessageLogger.java +++ b/hibernate-proxool/src/main/java/org/hibernate/proxool/internal/ProxoolMessageLogger.java @@ -7,10 +7,12 @@ package org.hibernate.proxool.internal; import org.hibernate.internal.CoreMessageLogger; +import org.hibernate.internal.log.ConnectionPoolingLogger; import org.jboss.logging.annotations.LogMessage; import org.jboss.logging.annotations.Message; import org.jboss.logging.annotations.MessageLogger; +import org.jboss.logging.annotations.ValidIdRange; import static org.jboss.logging.Logger.Level.INFO; @@ -21,16 +23,8 @@ import static org.jboss.logging.Logger.Level.INFO; * New messages must be added after the last message defined to ensure message codes are unique. */ @MessageLogger(projectCode = "HHH") -public interface ProxoolMessageLogger extends CoreMessageLogger { - - /** - * Logs the autocommit mode to be used for pooled connections - * - * @param autocommit The autocommit mode - */ - @LogMessage(level = INFO) - @Message(value = "Autocommit mode: %s", id = 30001) - void autoCommmitMode(boolean autocommit); +@ValidIdRange( min = 30001, max = 35000 ) +public interface ProxoolMessageLogger extends ConnectionPoolingLogger { /** * Logs the name of a named pool to be used for configuration information