Quick thought about XML vs annotations for Spring wiring

Daniel Lutz daniel.lutz at switch.ch
Thu Sep 24 04:04:42 EDT 2015


Brent Putman schrieb am 23.09.15 um 22:39:
> I may have implied differently on the last call, but for a
> product/project like Shib, intended to be deployed by many people with
> many use cases and config needs, I also think explicit, override-able
> config is desirable and necessary.  Hardcoded paths (e.g. in
> annotations) are in general probably not a good idea for that use, I think.

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.)

(Is it intended that a deployer should be able to re-configure any mapping,
including e.g. the mapping to all of the system flows defined in
system/conf/webflow-config.xml?)

>> I'm not taking a position on it so long as there's no bleed-over. I
>> didn't know the scanning was package-specific. 
> 
> It is, like this if configuring the scanning via XML wiring (see below
> for other way):
> 
> <context:component-scan base-package="org.example.foo, edu.somewhere.bar" />

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.

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".

-- Daniel



More information about the dev mailing list