|
From: neuro <ne...@ka...> - 2004-05-11 13:50:34
|
Hello spring developers,
Before spring I'm used WebWork2 in few projects. Spring can do everything
what WW2 can but Spring's generic config files seem little verbose and
lack some nice features what one can find in more focused framework.
I've developed some helper objects to make my configuration cleaner.
If anyone interested I've continue to share my expirience, and
of course I'll be happy to see some of my work will be so useful that
it will be integrated into Spring codebase.
I've do my best to keep stuff as much simple as useful. 8)
One of that is HierarchicalListFactoryBean (extends Spring ListFactoryBean).
It will prepend contents of parentList to its factored List.
IMHO this is is useful addition wich fits perfectly.
It is very nice for HandlerInterceptors (almost like nice ww2 Interceptor
stacks).
Example usage with HandlerInterceptors:
We define "defaultInterceptorList" to reuse and extend it in many
HandlerMappings... neat!
--------- snip servlet-context.xml { ---------
<bean id="defaultInterceptorList" class="org.springframework.beans.factory.config.ListFactoryBean">
<property name="sourceList">
<list>
<ref local="webContentInterceptor"/>
<ref local="themeChangeInterceptor"/>
<ref local="localeChangeInterceptor"/>
</list>
</property>
</bean>
<bean id="freeUrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="interceptors">
<ref local="defaultInterceptorList"/>
</property>
.... urlMap, etc
</bean>
<bean id="protectedUrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="interceptors">
<bean id="protectedInterceptorList" class="neuro.util.spring.HierarchicalListFactoryBean">
<property name="parentList"><ref local="defaultInterceptorList"/></property>
<property name="sourceList">
<list>
<ref local="protectionHandlerInterceptor"/>
</list>
</property>
</bean>
</property>
.... urlMap, etc
</bean>
--------- } snip servlet-context.xml ---------
HierarchicalListFactoryBean source is in the attach.
Obiviously, there can be HierarchicalMapFactoryBean and
HierarchicalSetFactoryBean with same behaviour.
//regards, neuro |