4.2. The JBoss Custom Namespace
Snowdrop includes snowdrop-namespace.jar which adds Spring namespace support for Red Hat JBoss Enterprise Application Platform. The goal of this custom namespace is to simplify the development of Spring applications that run on JBoss, by reducing the amount of proprietary code and improving portability.
The amount of proprietary code is reduced by replacing bean definitions that include references to specific JBoss classes with namespace-based constructs. All the knowledge about the proprietary classes is encapsulated in the namespace handlers.
The applications are more portable because certain proprietary classes may change when upgrading to a different version of the application server. In such cases, the runtime will be detected automatically by Snowdrop which will set up beans using the classes that are appropriate for that specific runtime.
Set up the custom namespace as follows:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:jboss="http://www.jboss.org/schema/snowdrop" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.jboss.org/schema/snowdrop http://www.jboss.org/schema/snowdrop/snowdrop.xsd"> </beans>
4.2.1. Accessing the Default JBoss MBean Server
Access the default MBean server of JBoss Enterprise Application Platform as follows:
<jboss:mbean-server/>The bean will be installed with the default id 'mbeanServer'. If necessary, developers can specify a different bean name:
<jboss:mbean-server id="customName"/>
Important
The location of the MBean server has changed between versions of JBoss Enterprise Application Platform, so using the following configuration fails with deployment errors:
<bean id="mBeanServer" class="org.jboss.jmx.util.MBeanServerLocator" factory-method="locateJBoss" />
The workaround for this issue is to use this configuration instead:
<bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean"> <property name="locateExistingServerIfPossible" value="true" /> </bean>
4.2.2. JCA/JMS Support Beans
Spring JMS message listeners (including message-driven POJOs) can use a JCA-based MessageListenerContainer. The configuration of a JCA-based listener container in Spring requires the setup of a number of beans based on application-server specific classes. Using the JBoss custom namespace, set up the ResourceAdapter and ActivationSpec configuration as follows:
<jboss:activation-spec-factory id="activationSpecFactory"/> <jboss:resource-adapter id="resourceAdapter"/>
This can be further used in a JCA message listener configuration:
<jms:jca-listener-container resource-adapter="resourceAdapter" acknowledge="auto" activation-spec-factory="activationSpecFactory"> <jms:listener destination="/someDestination" ref="messageDrivenPojo" method="pojoHandlerMethod"/> </jms:jca-listener-container>