shibboleth.InterceptFlow - share DB Connection Pooling with Shibboleth via 'global.xml'

Etienne Dysli Metref etienne.dysli-metref at switch.ch
Tue Sep 11 05:15:34 EDT 2018


On 11/09/18 03:05, Lionel Samuel wrote:
> I have it working -- but with a DB connection in XML file local to
> the JAR. Trying for last few days -- I can't figure out how to get
> the global context and piggyback the Db connection/pooling in
> 'global.xml' --- could anyone point me perhaps to an example?

Why don't you let Spring know you want the DataSource bean (defined in
global.xml) injected into your JdbcTemplate?

> public ResetPasswordCounter() {
>             super();
>            
> ResetPasswordCounterLog.info("ResetPasswordCounter.constructor()",
> "loading db-connection.xml ", null);
>             this.context = new
> ClassPathXmlApplicationContext("db-connection.xml");
>             this.ResetPasswordCounterModel =
> (ResetPasswordCounterJDBCTemplate)
> context.getBean("resetPasswordCounterJDBCTemplate");
>         }

Then just have your code declare that it needs a
ResetPasswordCounterJDBCTemplate instance and let Spring inject it.
Calling context.getBean() is the wrong way to use the Spring Framework.
Your constructor then becomes:

    public ResetPasswordCounter(ResetPasswordCounterJDBCTemplate
jdbcTemplate) {
      super();
      this.ResetPasswordCounterModel = jdbcTemplate;
    }

You'll also have to make sure Spring loads beans from your
db-connection.xml (import from global.xml, for example), or just define
them in global.xml (that's easier to start with). I'm not sure which of
Spring package/annotation scanning is disabled in the IdP, but this is a
bit more involved here than with Spring's full automation...

  Etienne

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://shibboleth.net/pipermail/users/attachments/20180911/5282985f/attachment.sig>


More information about the users mailing list