HHH-5949 - Migrate, complete and integrate TransactionFactory as a service

This commit is contained in:
Steve Ebersole 2011-03-07 10:48:32 -06:00
parent 16464ae8be
commit e1c03f28fd
2 changed files with 608 additions and 577 deletions

View File

@ -53,6 +53,7 @@ public class JtaPlatformInitiator implements ServiceInitiator<JtaPlatform> {
return JtaPlatform.class;
}
@SuppressWarnings( {"unchecked"})
@Override
public JtaPlatform initiateService(Map configVales, ServiceRegistry registry) {
final Object platform = getConfiguredPlatform( configVales, registry );
@ -64,14 +65,27 @@ public class JtaPlatformInitiator implements ServiceInitiator<JtaPlatform> {
return (JtaPlatform) platform;
}
final String platformImplName = platform.toString();
final Class<JtaPlatform> jtaPlatformImplClass;
if ( Class.class.isInstance( platform ) ) {
jtaPlatformImplClass = (Class<JtaPlatform>) platform;
}
else {
final String platformImplName = platform.toString();
final ClassLoaderService classLoaderService = registry.getService( ClassLoaderService.class );
try {
jtaPlatformImplClass = (Class<JtaPlatform>) classLoaderService.classForName( platformImplName );
}
catch ( Exception e ) {
throw new HibernateException( "Unable to locate specified JtaPlatform class [" + platformImplName + "]", e );
}
}
ClassLoaderService classLoaderService = registry.getService( ClassLoaderService.class );
try {
return (JtaPlatform) classLoaderService.classForName( platformImplName ).newInstance();
return jtaPlatformImplClass.newInstance();
}
catch ( Exception e ) {
throw new HibernateException( "Unable to create specified JtaPlatform class [" + platformImplName + "]", e );
throw new HibernateException( "Unable to create specified JtaPlatform class [" + jtaPlatformImplClass.getName() + "]", e );
}
}