HHH-12544 - Add jipijapa hook to plug in specialized caching and transaction services

This commit is contained in:
Steve Ebersole 2018-05-08 10:55:26 -05:00
parent 350d330159
commit ed136d5f52
2 changed files with 7 additions and 44 deletions

View File

@ -33,17 +33,23 @@ import static org.jboss.as.jpa.hibernate5.JpaLogger.JPA_LOGGER;
* Implements the PersistenceProviderAdaptor for Hibernate * Implements the PersistenceProviderAdaptor for Hibernate
* *
* @author Scott Marlow * @author Scott Marlow
* @author Steve Ebersole
*/ */
public class HibernatePersistenceProviderAdaptor implements PersistenceProviderAdaptor, TwoPhaseBootstrapCapable { public class HibernatePersistenceProviderAdaptor implements PersistenceProviderAdaptor, TwoPhaseBootstrapCapable {
@SuppressWarnings("WeakerAccess")
public static final String NAMING_STRATEGY_JPA_COMPLIANT_IMPL = "org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl"; public static final String NAMING_STRATEGY_JPA_COMPLIANT_IMPL = "org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl";
private static final String HIBERNATE_EXTENDED_BEANMANAGER = "org.hibernate.resource.beans.container.spi.ExtendedBeanManager";
@SuppressWarnings("WeakerAccess")
public static final String HIBERNATE_EXTENDED_BEANMANAGER = "org.hibernate.resource.beans.container.spi.ExtendedBeanManager";
private volatile JtaManager jtaManager; private volatile JtaManager jtaManager;
private volatile Platform platform; private volatile Platform platform;
private static final String NONE = SharedCacheMode.NONE.name(); private static final String NONE = SharedCacheMode.NONE.name();
@Override @Override
public void injectJtaManager(JtaManager jtaManager) { public void injectJtaManager(JtaManager jtaManager) {
// todo : why? `this.jtaManager` is never used aside from setting here in this method
if ( this.jtaManager != jtaManager ) { if ( this.jtaManager != jtaManager ) {
this.jtaManager = jtaManager; this.jtaManager = jtaManager;
} }
@ -59,12 +65,6 @@ public class HibernatePersistenceProviderAdaptor implements PersistenceProviderA
@Override @Override
@SuppressWarnings({"deprecation", "unchecked"}) @SuppressWarnings({"deprecation", "unchecked"})
public void addProviderProperties(Map properties, PersistenceUnitMetadata pu) { public void addProviderProperties(Map properties, PersistenceUnitMetadata pu) {
putPropertyIfAbsent(
pu,
properties,
AvailableSettings.JPAQL_STRICT_COMPLIANCE,
"true"
); // JIPI-24 ignore jpql aliases case
putPropertyIfAbsent( pu, properties, AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true" ); putPropertyIfAbsent( pu, properties, AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true" );
putPropertyIfAbsent( pu, properties, AvailableSettings.KEYWORD_AUTO_QUOTING_ENABLED, "false" ); putPropertyIfAbsent( pu, properties, AvailableSettings.KEYWORD_AUTO_QUOTING_ENABLED, "false" );
putPropertyIfAbsent( putPropertyIfAbsent(
@ -75,12 +75,6 @@ public class HibernatePersistenceProviderAdaptor implements PersistenceProviderA
); );
putPropertyIfAbsent( pu, properties, AvailableSettings.SCANNER, HibernateArchiveScanner.class ); putPropertyIfAbsent( pu, properties, AvailableSettings.SCANNER, HibernateArchiveScanner.class );
properties.put( AvailableSettings.APP_CLASSLOADER, pu.getClassLoader() ); properties.put( AvailableSettings.APP_CLASSLOADER, pu.getClassLoader() );
putPropertyIfAbsent(
pu,
properties,
AvailableSettings.JTA_PLATFORM,
new JBossAppServerJtaPlatform( jtaManager )
);
putPropertyIfAbsent( putPropertyIfAbsent(
pu, pu,
properties, properties,

View File

@ -1,31 +0,0 @@
/*
* 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.jboss.as.jpa.hibernate5;
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformProvider;
/**
* @author Scott Marlow
*/
public class JtaPlatformProviderImpl implements JtaPlatformProvider {
private static volatile JBossAppServerJtaPlatform delegate;
public static JBossAppServerJtaPlatform getDelegate() {
return delegate;
}
public static void setDelegate(JBossAppServerJtaPlatform delegate) {
JtaPlatformProviderImpl.delegate = delegate;
}
@Override
public JtaPlatform getProvidedJtaPlatform() {
return delegate;
}
}