HHH-12763 - Log which JtaPlatform implementation is used at startup on info level
This commit is contained in:
parent
5164d8b5b3
commit
b94b126141
|
@ -49,6 +49,7 @@ public class JtaPlatformInitiator implements StandardServiceInitiator<JtaPlatfor
|
|||
platform = getFallbackProvider( configurationValues, registry );
|
||||
}
|
||||
|
||||
LOG.usingJtaPlatform( platform != null ? platform.getClass().getName() : "null" );
|
||||
return platform;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,14 +26,14 @@ public interface JtaPlatform extends Service {
|
|||
*
|
||||
* @return The {@link TransactionManager}
|
||||
*/
|
||||
public TransactionManager retrieveTransactionManager();
|
||||
TransactionManager retrieveTransactionManager();
|
||||
|
||||
/**
|
||||
* Locate the {@link UserTransaction}
|
||||
*
|
||||
* @return The {@link UserTransaction}
|
||||
*/
|
||||
public UserTransaction retrieveUserTransaction();
|
||||
UserTransaction retrieveUserTransaction();
|
||||
|
||||
/**
|
||||
* Determine an identifier for the given transaction appropriate for use in caching/lookup usages.
|
||||
|
@ -44,21 +44,21 @@ public interface JtaPlatform extends Service {
|
|||
* @param transaction The transaction to be identified.
|
||||
* @return An appropriate identifier
|
||||
*/
|
||||
public Object getTransactionIdentifier(Transaction transaction);
|
||||
Object getTransactionIdentifier(Transaction transaction);
|
||||
|
||||
/**
|
||||
* Can we currently register a {@link Synchronization}?
|
||||
*
|
||||
* @return True if registering a {@link Synchronization} is currently allowed; false otherwise.
|
||||
*/
|
||||
public boolean canRegisterSynchronization();
|
||||
boolean canRegisterSynchronization();
|
||||
|
||||
/**
|
||||
* Register a JTA {@link Synchronization} in the means defined by the platform.
|
||||
*
|
||||
* @param synchronization The synchronization to register
|
||||
*/
|
||||
public void registerSynchronization(Synchronization synchronization);
|
||||
void registerSynchronization(Synchronization synchronization);
|
||||
|
||||
/**
|
||||
* Obtain the current transaction status using whatever means is preferred for this platform
|
||||
|
@ -67,5 +67,5 @@ public interface JtaPlatform extends Service {
|
|||
*
|
||||
* @throws SystemException Indicates a problem access the underlying status
|
||||
*/
|
||||
public int getCurrentStatus() throws SystemException;
|
||||
int getCurrentStatus() throws SystemException;
|
||||
}
|
||||
|
|
|
@ -1814,4 +1814,8 @@ public interface CoreMessageLogger extends BasicLogger {
|
|||
@LogMessage(level = WARN)
|
||||
@Message(value = "Setting " + AvailableSettings.NATIVE_EXCEPTION_HANDLING_51_COMPLIANCE + "=true is not valid with JPA bootstrapping; setting will be ignored.", id = 489 )
|
||||
void nativeExceptionHandling51ComplianceJpaBootstrapping();
|
||||
|
||||
@LogMessage(level = INFO)
|
||||
@Message(value = "Using JtaPlatform implementation: [%s]", id = 490)
|
||||
void usingJtaPlatform(String jtaPlatformClassName);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.tool.schema;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.boot.MetadataSources;
|
||||
import org.hibernate.boot.model.process.internal.ScanningCoordinator;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.engine.transaction.jta.platform.internal.JtaPlatformInitiator;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.jta.TestingJtaBootstrap;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
import org.hibernate.testing.logger.LoggerInspectionRule;
|
||||
import org.hibernate.testing.logger.Triggerable;
|
||||
import org.hibernate.test.resource.transaction.jta.JtaPlatformStandardTestingImpl;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@TestForIssue( jiraKey = "HHH-12763" )
|
||||
public class JtaPlatformLoggingTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
@Rule
|
||||
public LoggerInspectionRule logInspection = new LoggerInspectionRule(
|
||||
Logger.getMessageLogger( CoreMessageLogger.class, JtaPlatformInitiator.class.getName() ) );
|
||||
|
||||
private Triggerable triggerable = logInspection.watchForLogMessages( "HHH000490" );
|
||||
|
||||
@Override
|
||||
protected void addSettings(Map settings) {
|
||||
TestingJtaBootstrap.prepare( settings );
|
||||
settings.put( AvailableSettings.TRANSACTION_COORDINATOR_STRATEGY, "jta" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
assertEquals(
|
||||
"HHH000490: Using JtaPlatform implementation: [org.hibernate.testing.jta.TestingJtaPlatformImpl]",
|
||||
triggerable.triggerMessage()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class[] getAnnotatedClasses() {
|
||||
return new Class[] {
|
||||
TestEntity.class
|
||||
};
|
||||
}
|
||||
|
||||
@Entity( name = "TestEntity" )
|
||||
@Table( name = "TestEntity" )
|
||||
public static class TestEntity {
|
||||
@Id
|
||||
public Integer id;
|
||||
String name;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue