Quick thought about XML vs annotations for Spring wiring
Brent Putman
putmanb at georgetown.edu
Thu Sep 24 13:05:48 EDT 2015
On 9/24/15 4:04 AM, Daniel Lutz wrote:
> I think that this depends on the component: If it's a system component,
> like our SPNEGO controller, the deployer shouldn't change the mapping.
> Else, he would risk that it doesn't work anymore, because this may
> break the interface between the flow and the controller. (This interface
> is fixed, in our case.)
That's true. Although if the path is configurable, then I'd expect the
flow bean(s) to also allow configuration of the path/URL to the
controller so that they could be made to match.
> BTW, to add an annotations based controller, it's sufficient to
> declare it as a bean, e.g. in system/conf/mvc-bean.xml, like this:
>
> <bean id="shibboleth.SPNEGOAuthnController"
> class="net.shibboleth.idp.authn.impl.spnego.SPNEGOAuthnController" />
>
> No <context:component-scan> element is required.
I thought that was the case, but hadn't tested. I think the controller
class still has to have the @Controller annotation, right (or a
class-level @RequestMapping)? I believe that's how MVC identifies that
it is a controller bean (via an annotation-based HandlerMapping impl). [1]
> The "org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"
> will still find the controller (by scanning the known beans, I assume).
>
> An alternative to the annotations based request mapping would be
> an explicitly configured request mapping via
> "org.springframework.web.servlet.handler.SimpleUrlHandlerMapping".
I think with that you still need the method-level @RequestMapping, right?
[1] Btw, I noticed that they still default in their own
DispatcherServlet.properties the DefaultAnnotationHandlerMapping,
despite the Javadocs noting that it's been deprecated since Spring 3.2
in favor of RequestMappingHandlerMapping. If we're going to continue
supporting this mechanism, we should consider switching to the newer
class in our mvc-beans.xml.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shibboleth.net/pipermail/dev/attachments/20150924/cf55a809/attachment.html>
More information about the dev
mailing list