private static final Logger log = Logger.getLogger( StandardJtaPlatformResolver.class );
@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();
if ( providedPlatform!= null ) {
return providedPlatform;
}
}
// look for classes on the ClassLoader (via service) that we know indicate certain JTA impls or
// indicate running in certain environments with known JTA impls.
//
// IMPL NOTE : essentially we attempt Class lookups and use the exceptions from the class(es) not
// being found as the indicator
// JBoss ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
try {
classLoaderService.classForName( JBossStandAloneJtaPlatform.JBOSS_TM_CLASS_NAME );
classLoaderService.classForName( JBossStandAloneJtaPlatform.JBOSS_UT_CLASS_NAME );
// we know that the JBoss TS classes are available
// if neither of these look-ups resulted in an error (no such class), then JBossTM is available on
// the classpath
//
// todo : we cannot really distinguish between the need for JBossStandAloneJtaPlatform versus JBossApServerJtaPlatform
// but discussions with David led to the JtaPlatformProvider solution above, so inside JBoss AS we
// 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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
for ( WebSphereJtaPlatform.WebSphereEnvironment webSphereEnvironment
: WebSphereJtaPlatform.WebSphereEnvironment.values() ) {
try {
Class accessClass = classLoaderService.classForName( webSphereEnvironment.getTmAccessClassName() );
return new WebSphereJtaPlatform( accessClass, webSphereEnvironment );
}
catch (ClassLoadingException ignore) {
}
}