Search in sources :

Example 1 with JtaPlatformProvider

use of org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformProvider in project hibernate-orm by hibernate.

the class StandardJtaPlatformResolver method resolveJtaPlatform.

@Override
public JtaPlatform resolveJtaPlatform(Map configurationValues, ServiceRegistryImplementor registry) {
    final ClassLoaderService classLoaderService = registry.getService(ClassLoaderService.class);
    // Initially look for a JtaPlatformProvider
    for (JtaPlatformProvider provider : classLoaderService.loadJavaServices(JtaPlatformProvider.class)) {
        final JtaPlatform providedPlatform = provider.getProvidedJtaPlatform();
        log.tracef("Located JtaPlatformProvider [%s] provided JtaPlaform : %s", provider, providedPlatform);
        if (providedPlatform != null) {
            return providedPlatform;
        }
    }
    // JBoss ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    try {
        classLoaderService.classForName(JBossStandAloneJtaPlatform.JBOSS_TM_CLASS_NAME);
        classLoaderService.classForName(JBossStandAloneJtaPlatform.JBOSS_UT_CLASS_NAME);
        // should be relying on that
        return new JBossStandAloneJtaPlatform();
    } catch (ClassLoadingException ignore) {
    }
    // Bitronix ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    try {
        classLoaderService.classForName(BitronixJtaPlatform.TM_CLASS_NAME);
        return new BitronixJtaPlatform();
    } catch (ClassLoadingException ignore) {
    }
    // JOnAS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    try {
        classLoaderService.classForName(JOnASJtaPlatform.TM_CLASS_NAME);
        return new JOnASJtaPlatform();
    } catch (ClassLoadingException ignore) {
    }
    // JOTM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    try {
        classLoaderService.classForName(JOTMJtaPlatform.TM_CLASS_NAME);
        return new JOTMJtaPlatform();
    } catch (ClassLoadingException ignore) {
    }
    // WebSphere Liberty ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    try {
        classLoaderService.classForName(WebSphereLibertyJtaPlatform.TMF_CLASS_NAME);
        return new WebSphereLibertyJtaPlatform();
    } catch (ClassLoadingException ignore) {
    }
    // WebSphere traditional ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    for (WebSphereJtaPlatform.WebSphereEnvironment webSphereEnvironment : WebSphereJtaPlatform.WebSphereEnvironment.values()) {
        try {
            Class accessClass = classLoaderService.classForName(webSphereEnvironment.getTmAccessClassName());
            return new WebSphereJtaPlatform(accessClass, webSphereEnvironment);
        } catch (ClassLoadingException ignore) {
        }
    }
    // Finally, return the default...
    log.debugf("Could not resolve JtaPlatform, using default [%s]", NoJtaPlatform.class.getName());
    return NoJtaPlatform.INSTANCE;
}
Also used : JtaPlatform(org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform) ClassLoadingException(org.hibernate.boot.registry.classloading.spi.ClassLoadingException) JtaPlatformProvider(org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformProvider) ClassLoaderService(org.hibernate.boot.registry.classloading.spi.ClassLoaderService)

Aggregations

ClassLoaderService (org.hibernate.boot.registry.classloading.spi.ClassLoaderService)1 ClassLoadingException (org.hibernate.boot.registry.classloading.spi.ClassLoadingException)1 JtaPlatform (org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform)1 JtaPlatformProvider (org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformProvider)1