[keycloak-user] User SPI and connection management
Marko Strukelj
mstrukel at redhat.com
Tue Feb 21 10:25:12 EST 2017
See
http://www.keycloak.org/docs/2.5/server_development_guide/topics/providers.html
Specifically, there is a 'Note' in there that gives you the answer.
Maybe we should add some more explanation in the doc.
Let me try here ...
ProviderFactories are instantiated lazily on first use, and exist within a
context of KeycloakSessionFactory object - there is one instance of this
per Keycloak server - i.e. ProviderFactories behave as singleton services.
Provider instances are also instantiated lazily on first use, but exist
within a context of a KeycloakSession, and there are multiple
KeycloakSessions created even during server startup. But once Keycloak is
up, one KeycloakSession is typically created per HTTP request.
For example, when KeycloakSession.getProvider(JpaConnectionProvider.class)
is used multiple times on the same session, the first time it will trigger
creation of the new JpaConnectionProvider instance by using the
JpaConnectionProviderFactory.create() method, and all subsequent times the
same instance will be returned.
And if another KeycloakSession is started - by
using KeycloakSessionFactory.create() - and method
getProvider(JpaConnectionProvider.class) is called on it, that will use
existing JpaConnectionProviderFactory instance from the same
KeycloakSessionFactory object to create a new JpaConnectionProvider
instance. On subsequent calls the same JpaConnectionProvider instance will
be returned.
On Tue, Feb 21, 2017 at 2:47 PM, Istvan Orban <istvan.orban at gmail.com>
wrote:
> Hi Guys,
>
> I managed to implement User SPI for legacy user migration.
> Can someone shed some light how User SPIs are called in the system?
>
> Are they reused among threads or is it threadsafe ?
>
> The reason I am asking is that I used RestEasy to migrate user from the
> legacy platform and resteasy by default uses SingleClientConnManager.
>
> I am wondering if I need to implement connection management in the SPI or
> it is thrown awat between requests so there is no need for connection
> management.
>
> Thanks a lot
>
> --
> Kind Regards,
>
> *-----------------------------------------------------------
> -----------------------------------------------------*
> *Istvan Orban* *I *Skype: istvan_o *I *Mobile: +44 (0) 7956 122 144 *I *
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user
>
More information about the keycloak-user
mailing list