Hi folks, now i have the following scenario:
Basically i have an ear that contains a sar (Jboss service archive) with the hibernateServiceMbean. This ear basically calls a Mbean that creates the Hibernate SessionFactory and makes this SessionFactory available for all applications that i have (it loads all hibernate mappings build the session factory and makes this session factory available for all applications horizontally). After deploy this ear i can deploy my war´s and all web applications can access the session factory. It works fine but the problem is the sar is JBoss specific. If i want to deploy this MBean in Weblogic the approach is other. What is my idea, use the spring applicationContext to do this. I create en applicationContext.xml that looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="jmxAdapter"
class="org.springframework.jmx.export.MBeanExporte r">
<property name="beans">
<map>
<entry key="curso:service=HibernateService">
<ref local="HibernateService" />
</entry>
</map>
</property>
</bean>
<bean id="HibernateService" lazy-init="false" class="net.sf.hibernate.jmx.HibernateService" init-method="start">
<property name="mapResources">
<value>
br/com/netservicos/core/bean/bb/BbEstqInstaladoraBean.hbm.xml,
br/com/netservicos/core/bean/cp/CpAtividadeBean.hbm.xml,
</value>
</property>
<property name="datasource" value="java:/BCV_SOC" />
<property name="dialect"
value="org.hibernate.dialect.Oracle9Dialect" />
<property name="jndiName" value="java:/HibernateFactory_SOC" />
</bean>
<bean id="sessionFactory"
class="org.springframework.jndi.JndiObjectFactoryB ean">
<property name="jndiName" value="java:/HibernateFactory_SOC" />
</bean>
<!-- Transaction manager that delegates to JTA (for a transactional JNDI DataSource) -->
<bean id="transactionManager"
class="org.springframework.transaction.jta.JtaTran sactionManager" />
</beans>
Using spring to start my Mbeans, i can start my MBeans in a single way in all j2ee containers. I understand that this mbean need to be deployed before my web application because it servers to all web applications that i developed. The problem is that i cant figure out a way to load this application context in the J2EE container without use the ContextLoaderListener web application based. is there some way to load an spring context in a j2ee container instead of use a web application ? If i use a web application to load the spring application context the web applcation classpath (WEB-INF/classes) must have the hibernate hbm.xml files and so on. I think that it´s not a good idea.


Reply With Quote