|
From: Tim C. <tc...@ta...> - 2004-06-24 20:05:07
|
I recently had a discussion about this with a friend as I ran into the
same exact need.
I think the idea of having a separate Interceptor mapping would be a
good idea but at the same time it would mean alot more duplication.
From what it sounds like it would be similar to using a
PropertiesMethodNameResolver.
From the PetClinic example you see:
<!--
- This bean is a MethodNameResolver definition for a
MultiActionController.
- It maps URLs to methods for the "clinicController" bean.
-->
<bean id="clinicControllerResolver"
class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
<property name="mappings">
<props>
<prop key="/welcome.htm">welcomeHandler</prop>
<prop key="/vets.htm">vetsHandler</prop>
<prop key="/owner.htm">ownerHandler</prop>
</props>
</property>
</bean>
But yet those same urls are now duplicated in the UrlHandlerMapping:
<!--
- This bean is an explicit URL mapper that is used by the
"petclinic" DispatcherServlet
- It is used instead of the default BeanNameUrlHandlerMapping.
-->
<bean id="urlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/welcome.htm">clinicController</prop>
<prop key="/vets.htm">clinicController</prop>
<prop key="/owner.htm">clinicController</prop>
<prop key="/findOwners.htm">findOwnersForm</prop>
<prop key="/editOwner.htm">editOwnerForm</prop>
<prop key="/addOwner.htm">addOwnerForm</prop>
<prop key="/addVisit.htm">addVisitForm</prop>
<prop key="/addPet.htm">addPetForm</prop>
<prop key="/editPet.htm">editPetForm</prop>
</props>
</property>
</bean>
In the example of a complex application that might have many
URLs/Interceptor combinations you are not really going to make things
any less complicated as you will end up having a huge amout of these. I
wonder if an alternative approach would be to be able to attach
interceptors directly to controllers:
<bean id="clinicControllerResolver"
class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
<property name="interceptors">
<list>
<ref bean="signonInterceptor"/>
</list>
</property>
<property name="mappings">
<props>
<prop key="/welcome.htm">welcomeHandler</prop>
<prop key="/vets.htm">vetsHandler</prop>
<prop key="/owner.htm">ownerHandler</prop>
</props>
</property>
</bean>
In this way it would be very similar to the SpringAOP concept and
removes having to find/replace all on a changed/removed URL.
It is also very easy for a maintainer to then come in and see.. oh this
Controller has to pass thru these interceptors.
-Tim
Rod Johnson wrote:
>>The more I think about this, the more I think it will be useful. For
>>instance, I'd like to have the OpenSessionInViewInterceptor to apply to
>>everything (/*) where other Interceptors apply to certain Controllers.
>>I'm starting to get a proliferation of UrlHandlerMapping objects just to
>>map different combinations of Interceptors.
>>
>>Jurgen, any more thoughts on this? I might even implement this one soon
>>because it will greatly simplify things.
>>
>>
>
>I think the proposal sounds good. I think the point about 2 types of
>interceptors is valid.
>
>
>
>
>-------------------------------------------------------
>This SF.Net email sponsored by Black Hat Briefings & Training.
>Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
>digital self defense, top technical experts, no vendor pitches,
>unmatched networking opportunities. Visit www.blackhat.com
>_______________________________________________
>Springframework-developer mailing list
>Spr...@li...
>https://lists.sourceforge.net/lists/listinfo/springframework-developer
>
>
>
|