[keycloak-dev] Add your custom Spi to the Keycloak session?

Stian Thorgersen sthorger at redhat.com
Tue Nov 24 03:03:08 EST 2015


ProviderLoader is responsible to load providers of an SPI. There's only one
implementations of it, this is DefaultProviderLoader. There's 3 different
factories that use, which loads it differently, but you shouldn't need to
worry about those.

Add "List<SPI> loadSPI" to ProviderLoader and implement it in
DefaultProviderLoader. Implementation should be simple, use ServiceLoader
and the attached classloader to find instances of SPI.

Next add same method to ProviderManager. This should loop through all
registered ProviderLoaders and retrieve SPIs.

Final step in DefaultKeycloakSessionFactory.init use
ProviderManager#loadSPI instead of ServiceLoader to list SPIs.

You also need to document it under the provider section in the
documentation. One comment should be that SPIs have to be deployed as
modules, not just dropped into providers directory.

On 23 November 2015 at 22:13, Erik Mulder <erik.mulder at docdatapayments.com>
wrote:

> I'll be happy to create a PR for this if you can provide me some info &
> tips on how to get this working.
>
> ________________________________________
> Van: Stian Thorgersen [sthorger at redhat.com]
> Verzonden: maandag 23 november 2015 20:04
> Aan: Erik Mulder
> CC: keycloak-dev
> Onderwerp: Re: [keycloak-dev] Add your custom Spi to the Keycloak session?
>
> No specific reason it can't. Feel free to create a JIRA to request.
>
> It's not something we can prioritize right now though. If you're willing
> to do a PR I can give you some pointers on how to implement it.
>
> On 23 November 2015 at 16:54, Erik Mulder <erik.mulder at docdatapayments.com
> <mailto:erik.mulder at docdatapayments.com>> wrote:
> We are extending KeyCloak with some custom functionality and we like to
> add an extra org.keycloak.provider.Spi and 'piggy-back' on the
> KeycloakSession.getProvider mechanism at various places. So we added a
> org.keycloak.provider.Spi file in the META-INF/services of our provider
> jar with the Spi implementation we made. But unfortunately, it's not
> picked up by the DefaultKeycloakSessionFactory, since the classloader
> that is used in ServiceLoader.load (DefaultKeycloakSessionFactory:56)
> doesn't have the custom provider jars in scope. Is this intentional?
>
> I can understand if you don't want some external Spi 'entering' the
> KeyCloak system. On the other hand, that's the 'own risk' of the
> developer creating it. We would like this constraint lifted if possible.
> If not, is there another way we can get our own Spi's added to the
> keycloak session without changing any KeyCloak sources? Like using a
> module instead of a 'plain' provider jar? Are these added modules in
> scope of the DefaultKeycloakSessionFactory classloader?
>
>
> _______________________________________________
> keycloak-dev mailing list
> keycloak-dev at lists.jboss.org<mailto:keycloak-dev at lists.jboss.org>
> https://lists.jboss.org/mailman/listinfo/keycloak-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-dev/attachments/20151124/a2e1a7d1/attachment.html 


More information about the keycloak-dev mailing list