Revert "Implement SessionFactoryImplementor in SF proxies"

This reverts commit 08ccd19c76.

Issue: SPR-8469
This commit is contained in:
Chris Beams 2011-10-09 07:55:21 +00:00
parent 363e08df22
commit b82d5ae8da
2 changed files with 7 additions and 13 deletions

View File

@ -33,7 +33,6 @@ import org.hibernate.SessionFactory;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.cfg.AnnotationConfiguration; import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.classic.Session; import org.hibernate.classic.Session;
import org.hibernate.engine.SessionFactoryImplementor;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanCreationException;
@ -132,11 +131,10 @@ public class HibernateSessionFactoryConfigurationTests {
} }
@Test @Test
public void builtSessionFactoryIsProxyImplementingDisposableBeanAndSessionFactoryImplementor() { public void builtSessionFactoryIsDisposableBeanProxy() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(AnnotationSessionFactoryConfig.class); AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(AnnotationSessionFactoryConfig.class);
SessionFactory sessionFactory = ctx.getBean(SessionFactory.class); SessionFactory sessionFactory = ctx.getBean(SessionFactory.class);
assertThat(sessionFactory, instanceOf(DisposableBean.class)); assertThat(sessionFactory, instanceOf(DisposableBean.class));
assertThat(sessionFactory, instanceOf(SessionFactoryImplementor.class));
assertThat(sessionFactory.toString(), startsWith("DisposableBean proxy for SessionFactory")); assertThat(sessionFactory.toString(), startsWith("DisposableBean proxy for SessionFactory"));
ctx.close(); ctx.close();
assertTrue("SessionFactory was not closed as expected", sessionFactory.isClosed()); assertTrue("SessionFactory was not closed as expected", sessionFactory.isClosed());

View File

@ -232,9 +232,8 @@ public abstract class SessionFactoryBuilderSupport<This extends SessionFactoryBu
/** /**
* Build the underlying Hibernate SessionFactory. * Build the underlying Hibernate SessionFactory.
* @return the {@code SessionFactory}, potentially wrapped as a * @return the raw SessionFactory (potentially to be wrapped with a
* {@code DisposableBean} and/or transaction-aware proxy before it is exposed to the * transaction-aware proxy before it is exposed to the application)
* application.
* @throws Exception in case of initialization failure * @throws Exception in case of initialization failure
*/ */
public SessionFactory buildSessionFactory() throws Exception { public SessionFactory buildSessionFactory() throws Exception {
@ -245,9 +244,8 @@ public abstract class SessionFactoryBuilderSupport<This extends SessionFactoryBu
/** /**
* Populate the underlying {@code Configuration} instance with the various * Populate the underlying {@code Configuration} instance with the various
* properties of this builder, then return the raw session factory resulting from * properties of this builder. Customization may be performed through
* calling {@link Configuration#buildSessionFactory()}. Customization may be performed * {@code pre*} and {@code post*} methods.
* through {@code pre*} and {@code post*} methods.
* @see #preBuildSessionFactory() * @see #preBuildSessionFactory()
* @see #postProcessMappings() * @see #postProcessMappings()
* @see #postBuildSessionFactory() * @see #postBuildSessionFactory()
@ -555,9 +553,8 @@ public abstract class SessionFactoryBuilderSupport<This extends SessionFactoryBu
* <p>Subclasses may override this to implement transaction awareness through * <p>Subclasses may override this to implement transaction awareness through
* a {@code SessionFactory} proxy for example, or even to avoid creation of the * a {@code SessionFactory} proxy for example, or even to avoid creation of the
* {@code DisposableBean} proxy altogether. * {@code DisposableBean} proxy altogether.
* @param rawSf the raw {@code SessionFactory} as built by {@link #doBuildSessionFactory()} * @param rawSf the raw {@code SessionFactory} as built by {@link #buildSessionFactory()}
* @return a proxied {@code SessionFactory} if wrapping was necessary, otherwise the * @return the {@code SessionFactory} reference to expose
* original given 'raw' {@code SessionFactory} object.
* @see #buildSessionFactory() * @see #buildSessionFactory()
*/ */
protected SessionFactory wrapSessionFactoryIfNecessary(final SessionFactory rawSf) { protected SessionFactory wrapSessionFactoryIfNecessary(final SessionFactory rawSf) {
@ -565,7 +562,6 @@ public abstract class SessionFactoryBuilderSupport<This extends SessionFactoryBu
this.beanClassLoader, this.beanClassLoader,
new Class<?>[] { new Class<?>[] {
SessionFactory.class, SessionFactory.class,
SessionFactoryImplementor.class,
DisposableBean.class DisposableBean.class
}, },
new InvocationHandler() { new InvocationHandler() {