1
14
15 package com.liferay.portal.spring.hibernate;
16
17 import java.lang.reflect.Proxy;
18
19 import org.hibernate.SessionFactory;
20 import org.hibernate.engine.SessionFactoryImplementor;
21
22 import org.springframework.orm.hibernate3.LocalSessionFactoryBean;
23
24
30 public class TransactionAwareConfiguration extends LocalSessionFactoryBean {
31
32 protected SessionFactory wrapSessionFactoryIfNecessary(
33 SessionFactory sessionFactory) {
34
35
37 Class<?> sessionFactoryInterface = SessionFactory.class;
38
39 if (sessionFactory instanceof SessionFactoryImplementor) {
40 sessionFactoryInterface = SessionFactoryImplementor.class;
41 }
42
43 return (SessionFactory)Proxy.newProxyInstance(
44 sessionFactoryInterface.getClassLoader(),
45 new Class[] {sessionFactoryInterface},
46 new SessionFactoryInvocationHandler(sessionFactory));
47 }
48
49 }