private CurrentSessionContext buildCurrentSessionContext() { String impl = properties.getProperty( Environment.CURRENT_SESSION_CONTEXT_CLASS ); // for backward-compatibility if ( impl == null ) { if ( canAccessTransactionManager() ) { impl = "jta"; } else { return null; } } if ( "jta".equals( impl ) ) { if ( ! transactionFactory().compatibleWithJtaSynchronization() ) { LOG.autoFlushWillNotWork(); } return new JTASessionContext( this ); } else if ( "thread".equals( impl ) ) { return new ThreadLocalSessionContext( this ); } else if ( "managed".equals( impl ) ) { return new ManagedSessionContext( this ); } else { try { Class implClass = serviceRegistry.getService( ClassLoaderService.class ).classForName( impl ); return ( CurrentSessionContext ) implClass .getConstructor( new Class[] { SessionFactoryImplementor.class } ) .newInstance( this ); } catch( Throwable t ) { LOG.unableToConstructCurrentSessionContext( impl, t ); return null; } } }
private CurrentSessionContext buildCurrentSessionContext() { String impl = properties .getProperty(Environment.CURRENT_SESSION_CONTEXT_CLASS); // for backward-compatibility if (impl == null) { if (canAccessTransactionManager()) { impl = "jta"; } else { return null; } } if ("jta".equals(impl)) { if (!transactionFactory().compatibleWithJtaSynchronization()) { LOG.autoFlushWillNotWork(); } return new JTASessionContext(this); } else if ("thread".equals(impl)) { return new ThreadLocalSessionContext(this); } else if ("managed".equals(impl)) { return new ManagedSessionContext(this); } else { try { Class implClass = serviceRegistry.getService( ClassLoaderService.class).classForName(impl); return (CurrentSessionContext) implClass.getConstructor( new Class[] { SessionFactoryImplementor.class }) .newInstance(this); } catch (Throwable t) { LOG.unableToConstructCurrentSessionContext(impl, t); return null; } } }