Hi Costin,
Thanks for your answer!!
I configure my session factory as a bean in my data access bundle and use it directly to configure my transaction manager bean:
Code:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
lazy-init="false">
(...)
<property name="dataSource">
<osgi:reference interface="javax.sql.DataSource" timeout="5000"/>
</property>
</bean>
<osgi:service ref="sessionFactory" context-class-loader="service-provider">
<osgi:interfaces>
<value>org.hibernate.SessionFactory</value>
</osgi:interfaces>
</osgi:service>
(...)
<bean id="hibernateTransactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager"
lazy-init="false">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
On the other side, I configure my open session in view interceptor using the OSGi service related to the session factory in my web bundle:
Code:
<bean id="urlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
(...)
</props>
</property>
<property name="interceptors">
<list>
<ref local="openSessionInViewInterceptor"/>
</list>
</property>
</bean>
<bean id="openSessionInViewInterceptor"
class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<osgi:reference id="sessionFactory"
interface="org.hibernate.SessionFactory"
timeout="5000"/>
Do you believe that Spring can make match the session factory because the first is the classic bean and the other the OSGi service?
Thanks,
Thierry