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?
Every Spring namespace has an associated
NamespaceHandlerimplementation. The namespace schemas are mapped to schema files inside Spring JARs in variousspring.schemasfiles (see also Spring DI applicationContext.xml how exactly is xsi:schemaLocation used?).The XML schema namespaces are also mapped to handler classes in
spring.handlersfiles (several as each Spring JAR might introduce different namespaces). For your convenience here is a list of most common namespaces:Spring core
aop–AopNamespaceHandlerc–SimpleConstructorNamespaceHandlercache–CacheNamespaceHandlercontext–ContextNamespaceHandlerjdbc–JdbcNamespaceHandlerjee–JeeNamespaceHandlerjms–JmsNamespaceHandlerlang–LangNamespaceHandlermvc–MvcNamespaceHandleroxm–OxmNamespaceHandlerp–SimplePropertyNamespaceHandlertask–TaskNamespaceHandlertx–TxNamespaceHandlerutil–UtilNamespaceHandlerSpring Security
security–SecurityNamespaceHandleroauth–OAuthSecurityNamespaceHandlerSpring integration
int–IntegrationNamespaceHandleramqp–AmqpNamespaceHandlerevent–EventNamespaceHandlerfeed–FeedNamespaceHandlerfile–FileNamespaceHandlerftp–FtpNamespaceHandlergemfire–GemfireIntegrationNamespaceHandlergroovy–GroovyNamespaceHandlerhttp–HttpNamespaceHandlerip–IpNamespaceHandlerjdbc–JdbcNamespaceHandlerjms–JmsNamespaceHandlerjmx–JmxNamespaceHandlermail–MailNamespaceHandlerredis–RedisNamespaceHandlerrmi–RmiNamespaceHandlerscript–ScriptNamespaceHandlersecurity–IntegrationSecurityNamespaceHandlersftp–SftpNamespaceHandlerstream–StreamNamespaceHandlertwitter–TwitterNamespaceHandlerws–WsNamespaceHandlerxml–IntegrationXmlNamespaceHandlerxmpp–XmppNamespaceHandlerIf you browse to the source of each of these classes you will quickly discover various
BeanDefinitionParserimplementations responsible for parsing actual XML definitions.