Search in sources :

Example 6 with ProviderManager

use of org.keycloak.provider.ProviderManager in project keycloak by keycloak.

the class FeatureDeployerUtil method undeployFactoriesAfterFeatureDisabled.

public static void undeployFactoriesAfterFeatureDisabled(Profile.Feature feature) {
    ProviderManager manager = deployersCache.get(feature);
    if (manager == null) {
        // This is used if some feature is enabled by default and then disabled
        // Need to figure which provider factories were enabled after feature was enabled. Create deployer based on it and save it to the cache
        Map<ProviderFactory, Spi> factoriesBeforeDisable = initializer.remove(feature);
        Map<ProviderFactory, Spi> factoriesAfterDisable = loadEnabledEnvironmentFactories();
        Map<ProviderFactory, Spi> factories = getFactoriesDependentOnFeature(factoriesAfterDisable, factoriesBeforeDisable);
        KeycloakDeploymentInfo di = createDeploymentInfo(factories);
        manager = new ProviderManager(di, FeatureDeployerUtil.class.getClassLoader());
        loadFactories(manager);
        deployersCache.put(feature, manager);
    }
    ProviderManagerRegistry.SINGLETON.undeploy(manager);
}
Also used : KeycloakDeploymentInfo(org.keycloak.provider.KeycloakDeploymentInfo) ProviderManager(org.keycloak.provider.ProviderManager) EnvironmentDependentProviderFactory(org.keycloak.provider.EnvironmentDependentProviderFactory) ProviderFactory(org.keycloak.provider.ProviderFactory) Spi(org.keycloak.provider.Spi)

Example 7 with ProviderManager

use of org.keycloak.provider.ProviderManager in project keycloak by keycloak.

the class DefaultKeycloakSessionFactory method init.

public void init() {
    serverStartupTimestamp = System.currentTimeMillis();
    ProviderManager pm = new ProviderManager(KeycloakDeploymentInfo.create().services(), getClass().getClassLoader(), Config.scope().getArray("providers"));
    for (Spi spi : pm.loadSpis()) {
        if (spi.isEnabled()) {
            spis.add(spi);
        }
    }
    factoriesMap = loadFactories(pm);
    synchronized (ProviderManagerRegistry.SINGLETON) {
        for (ProviderManager manager : ProviderManagerRegistry.SINGLETON.getPreBoot()) {
            Map<Class<? extends Provider>, Map<String, ProviderFactory>> factoryMap = loadFactories(manager);
            for (Map.Entry<Class<? extends Provider>, Map<String, ProviderFactory>> entry : factoryMap.entrySet()) {
                Map<String, ProviderFactory> factories = factoriesMap.get(entry.getKey());
                if (factories == null) {
                    factoriesMap.put(entry.getKey(), entry.getValue());
                } else {
                    factories.putAll(entry.getValue());
                }
            }
        }
        checkProvider();
        // Component factory must be initialized first, so that postInit in other factories can use component factories
        updateComponentFactoryProviderFactory();
        if (componentFactoryPF != null) {
            componentFactoryPF.postInit(this);
        }
        for (Map<String, ProviderFactory> factories : factoriesMap.values()) {
            for (ProviderFactory factory : factories.values()) {
                if (factory != componentFactoryPF) {
                    factory.postInit(this);
                }
            }
        }
        // make the session factory ready for hot deployment
        ProviderManagerRegistry.SINGLETON.setDeployer(this);
    }
    AdminPermissions.registerListener(this);
}
Also used : ProviderManager(org.keycloak.provider.ProviderManager) EnvironmentDependentProviderFactory(org.keycloak.provider.EnvironmentDependentProviderFactory) ComponentFactoryProviderFactory(org.keycloak.component.ComponentFactoryProviderFactory) ProviderFactory(org.keycloak.provider.ProviderFactory) Spi(org.keycloak.provider.Spi) HashMap(java.util.HashMap) Map(java.util.Map) MultivaluedHashMap(org.keycloak.common.util.MultivaluedHashMap) ComponentFactoryProvider(org.keycloak.component.ComponentFactoryProvider) Provider(org.keycloak.provider.Provider)

Aggregations

ProviderManager (org.keycloak.provider.ProviderManager)7 ProviderFactory (org.keycloak.provider.ProviderFactory)5 Spi (org.keycloak.provider.Spi)5 EnvironmentDependentProviderFactory (org.keycloak.provider.EnvironmentDependentProviderFactory)4 KeycloakDeploymentInfo (org.keycloak.provider.KeycloakDeploymentInfo)4 Map (java.util.Map)3 Provider (org.keycloak.provider.Provider)3 HashMap (java.util.HashMap)2 JdbcDataSourceBuildItem (io.quarkus.agroal.spi.JdbcDataSourceBuildItem)1 DevServicesDatasourceResultBuildItem (io.quarkus.datasource.deployment.spi.DevServicesDatasourceResultBuildItem)1 IsDevelopment (io.quarkus.deployment.IsDevelopment)1 BuildProducer (io.quarkus.deployment.annotations.BuildProducer)1 BuildStep (io.quarkus.deployment.annotations.BuildStep)1 Consume (io.quarkus.deployment.annotations.Consume)1 ExecutionTime (io.quarkus.deployment.annotations.ExecutionTime)1 Record (io.quarkus.deployment.annotations.Record)1 CombinedIndexBuildItem (io.quarkus.deployment.builditem.CombinedIndexBuildItem)1 FeatureBuildItem (io.quarkus.deployment.builditem.FeatureBuildItem)1 GeneratedResourceBuildItem (io.quarkus.deployment.builditem.GeneratedResourceBuildItem)1 HotDeploymentWatchedFileBuildItem (io.quarkus.deployment.builditem.HotDeploymentWatchedFileBuildItem)1