Search in sources :

Example 1 with RealmUpdatedEvent

use of org.keycloak.models.cache.infinispan.events.RealmUpdatedEvent in project keycloak by keycloak.

the class DefaultInfinispanConnectionProviderFactory method registerSystemWideListeners.

private void registerSystemWideListeners(KeycloakSession session) {
    KeycloakSessionFactory sessionFactory = session.getKeycloakSessionFactory();
    ClusterProvider cluster = session.getProvider(ClusterProvider.class);
    cluster.registerListener(REALM_CLEAR_CACHE_EVENTS, (ClusterEvent event) -> {
        if (event instanceof ClearCacheEvent) {
            sessionFactory.invalidate(ObjectType._ALL_);
        }
    });
    cluster.registerListener(REALM_INVALIDATION_EVENTS, (ClusterEvent event) -> {
        if (event instanceof RealmUpdatedEvent) {
            RealmUpdatedEvent rr = (RealmUpdatedEvent) event;
            sessionFactory.invalidate(ObjectType.REALM, rr.getId());
        } else if (event instanceof RealmRemovedEvent) {
            RealmRemovedEvent rr = (RealmRemovedEvent) event;
            sessionFactory.invalidate(ObjectType.REALM, rr.getId());
        }
    });
}
Also used : ClusterEvent(org.keycloak.cluster.ClusterEvent) ClearCacheEvent(org.keycloak.models.cache.infinispan.ClearCacheEvent) ClusterProvider(org.keycloak.cluster.ClusterProvider) RealmRemovedEvent(org.keycloak.models.cache.infinispan.events.RealmRemovedEvent) KeycloakSessionFactory(org.keycloak.models.KeycloakSessionFactory) RealmUpdatedEvent(org.keycloak.models.cache.infinispan.events.RealmUpdatedEvent)

Aggregations

ClusterEvent (org.keycloak.cluster.ClusterEvent)1 ClusterProvider (org.keycloak.cluster.ClusterProvider)1 KeycloakSessionFactory (org.keycloak.models.KeycloakSessionFactory)1 ClearCacheEvent (org.keycloak.models.cache.infinispan.ClearCacheEvent)1 RealmRemovedEvent (org.keycloak.models.cache.infinispan.events.RealmRemovedEvent)1 RealmUpdatedEvent (org.keycloak.models.cache.infinispan.events.RealmUpdatedEvent)1