I’m using custom namespaces with Spring sometimes. Like the CXF one or the ActiveMQ one.
Here’s an exemple of how i declare my embedded ActiveMQ broker server:
<amq:broker useJmx="false" persistent="true">
<amq:transportConnectors>
<amq:transportConnector uri="${mobilepush.activemq.broker.transport.connector.uri}" />
</amq:transportConnectors>
<amq:persistenceAdapter>
<amq:kahaPersistenceAdapter directory="${mobilepush.activemq.broker.queue.persistence.directory}" maxDataFileLength="33554432"/>
</amq:persistenceAdapter>
</amq:broker>
I don’t know so much about custom namespaces with Spring, but in my opinion these namespaces are just providing a “shortcut” for a more verbose Spring bean declaration.
Some libraries like Xebia Management Extras provide in their documentation the equivalence between the custom namespace and the raw spring implementation:
<management:jms-connection-factory-wrapper
id="connectionFactory"
connection-factory="rawConnectionFactory" />
Is equals to:
<bean id="connectionFactory" class="fr.xebia.management.jms.SpringManagedConnectionFactory">
<property name="connectionFactory" ref="rawConnectionFactory" />
</bean>
http://code.google.com/p/xebia-france/wiki/ManagedJmsConnectionFactory
But sometimes the custom namespace documentation is not precise enough and i’d like to understand what’s going under the hood in term of Java classes…
So what i’d like to know is how can i get the raw Spring bean declaration equivalence of a custom namespace usage?
Is there any “automatic translation tool” included in any IDE?
As far as i know, it seems there are different tools to create custom Spring namespaces, like XBean… Is there an automatic or manual way to understand how work the namespace under the hood without knowing all these tools?
Thanks
This is a good reference to how Spring handles Custom namespaces – http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/extensible-xml.html#extensible-xml-schema
Every custom namespace has an associated NamespaceHandler which is registered using a spring.handler file in
META-INF/spring.handlersin different jar files.For eg. the context namespace, if you look into the
META-INF/spring.handlersin spring-context*.jar fileyou would see the namespacehandler for the context namespace:which internally registers the different parsers for the tags under context namespace.
each of these parsers register the different bean definitions that you have mentioned –
So unfortunately there is no simple tool to find out which bean definitions are registered for a specific custom namespace, you will have to go through the code for the specific BeanDefinition parsers.
XBean which is used by ActiveMQ simplifies this process of registering a custom Namespacehandler a little, by handling some of the boiler plate