In my Spring 3.1 application, I sometime need to change the default behavior of some of the Spring namespaces in my context files. To do that, I create custom classes that implement some interfaces or that extend the default classes Spring uses.
But I find it hard to know exactly what are those classes that Spring uses behind its namespaces! What is the steps required to find them?
For example, the security namespace :
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:sec="http://www.springframework.org/schema/security" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> and something like :
<sec:http> ... <sec:logout /> </sec:http> How do I find what classes are used by the "<sec:logout />" namespace? I don't find the information by looking at http://www.springframework.org/schema/security/spring-security-3.1.xsd !
Where should I look?
XML Namespaces - The xmlns Attribute When using prefixes in XML, a namespace for the prefix must be defined. The namespace can be defined by an xmlns attribute in the start tag of an element. The namespace declaration has the following syntax. xmlns:prefix="URI".
So, the spring tx namespace is merely a way of identifying things which "belong to" Spring Transactions in an XML configuration document. Visiting the URL of the Spring TX namespace leads you to XML Schemas (rules for what elements, attributes, and values you can have) for the various versions of Spring Transactions.
An XML namespace is a collection of names that can be used as element or attribute names in an XML document. The namespace qualifies element names uniquely on the Web in order to avoid conflicts between elements with the same name.
A Namespace is a set of unique names. Namespace is a mechanisms by which element and attribute name can be assigned to a group. The Namespace is identified by URI(Uniform Resource Identifiers).
Every Spring namespace has an associated NamespaceHandler implementation. The namespace schemas are mapped to schema files inside Spring JARs in various spring.schemas files (see also Spring DI applicationContext.xml how exactly is xsi:schemaLocation used?).
The XML schema namespaces are also mapped to handler classes in spring.handlers files (several as each Spring JAR might introduce different namespaces). For your convenience here is a list of most common namespaces:
aop - AopNamespaceHandler c - SimpleConstructorNamespaceHandler cache - CacheNamespaceHandler context - ContextNamespaceHandler jdbc - JdbcNamespaceHandler jee - JeeNamespaceHandler jms - JmsNamespaceHandler lang - LangNamespaceHandler mvc - MvcNamespaceHandler oxm - OxmNamespaceHandler p - SimplePropertyNamespaceHandler task - TaskNamespaceHandler tx - TxNamespaceHandler util - UtilNamespaceHandler security - SecurityNamespaceHandler oauth - OAuthSecurityNamespaceHandler int - IntegrationNamespaceHandler amqp - AmqpNamespaceHandler event - EventNamespaceHandler feed - FeedNamespaceHandler file - FileNamespaceHandler ftp - FtpNamespaceHandler gemfire - GemfireIntegrationNamespaceHandler groovy - GroovyNamespaceHandler http - HttpNamespaceHandler ip - IpNamespaceHandler jdbc - JdbcNamespaceHandler jms - JmsNamespaceHandler jmx - JmxNamespaceHandler mail - MailNamespaceHandler redis - RedisNamespaceHandler rmi - RmiNamespaceHandler script - ScriptNamespaceHandler security - IntegrationSecurityNamespaceHandler sftp - SftpNamespaceHandler stream - StreamNamespaceHandler twitter - TwitterNamespaceHandler ws - WsNamespaceHandler xml - IntegrationXmlNamespaceHandler xmpp - XmppNamespaceHandler If you browse to the source of each of these classes you will quickly discover various BeanDefinitionParser implementations responsible for parsing actual XML definitions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With