use of org.keycloak.provider.KeycloakDeploymentInfo in project keycloak by keycloak.
the class FeatureDeployerUtil method createDeploymentInfo.
private static KeycloakDeploymentInfo createDeploymentInfo(Map<ProviderFactory, Spi> factories) {
KeycloakDeploymentInfo di = KeycloakDeploymentInfo.create();
for (Map.Entry<ProviderFactory, Spi> factory : factories.entrySet()) {
ProviderFactory pf = factory.getKey();
Class<? extends Spi> spiClass = factory.getValue().getClass();
di.addProvider(spiClass, pf);
}
return di;
}
use of org.keycloak.provider.KeycloakDeploymentInfo in project keycloak by keycloak.
the class FeatureDeployerUtil method loadFactories.
private static void loadFactories(ProviderManager pm) {
KeycloakDeploymentInfo di = KeycloakDeploymentInfo.create().services();
ClassLoader classLoader = DefaultKeycloakSession.class.getClassLoader();
DefaultProviderLoader loader = new DefaultProviderLoader(di, classLoader);
loader.loadSpis().forEach(pm::load);
}
use of org.keycloak.provider.KeycloakDeploymentInfo in project keycloak by keycloak.
the class FeatureDeployerUtil method deployFactoriesAfterFeatureEnabled.
public static void deployFactoriesAfterFeatureEnabled(Profile.Feature feature) {
ProviderManager manager = deployersCache.get(feature);
if (manager == null) {
// 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> factoriesBeforeEnable = initializer.remove(feature);
Map<ProviderFactory, Spi> factoriesAfterEnable = loadEnabledEnvironmentFactories();
Map<ProviderFactory, Spi> factories = getFactoriesDependentOnFeature(factoriesBeforeEnable, factoriesAfterEnable);
logger.infof("New factories when enabling feature '%s': %s", feature, factories.keySet());
KeycloakDeploymentInfo di = createDeploymentInfo(factories);
manager = new ProviderManager(di, FeatureDeployerUtil.class.getClassLoader());
deployersCache.put(feature, manager);
}
ProviderManagerRegistry.SINGLETON.deploy(manager);
}
use of org.keycloak.provider.KeycloakDeploymentInfo in project keycloak by keycloak.
the class KeycloakProviderDependencyProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
KeycloakAdapterConfigService config = KeycloakAdapterConfigService.INSTANCE;
String deploymentName = deploymentUnit.getName();
if (config.isKeycloakServerDeployment(deploymentName)) {
return;
}
KeycloakDeploymentInfo info = getKeycloakProviderDeploymentInfo(deploymentUnit);
if (info.hasServices()) {
final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
final ModuleLoader moduleLoader = Module.getBootModuleLoader();
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_COMMON, false, false, false, false));
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_CORE, false, false, false, false));
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_SERVER_SPI, false, false, false, false));
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_SERVER_SPI_PRIVATE, false, false, false, false));
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, JAXRS, false, false, false, false));
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, RESTEASY, false, false, false, false));
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, APACHE, false, false, false, false));
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_JPA, false, false, false, false));
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_MAP, false, false, false, false));
}
}
use of org.keycloak.provider.KeycloakDeploymentInfo in project keycloak by keycloak.
the class KeycloakProviderDeploymentProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
KeycloakAdapterConfigService config = KeycloakAdapterConfigService.INSTANCE;
String deploymentName = deploymentUnit.getName();
if (config.isKeycloakServerDeployment(deploymentName)) {
return;
}
KeycloakDeploymentInfo info = KeycloakProviderDependencyProcessor.getKeycloakProviderDeploymentInfo(deploymentUnit);
ScriptProviderDeploymentProcessor.deploy(deploymentUnit, info);
if (info.isProvider()) {
logger.infov("Deploying Keycloak provider: {0}", deploymentUnit.getName());
final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
ProviderManager pm = new ProviderManager(info, module.getClassLoader());
ProviderManagerRegistry.SINGLETON.deploy(pm);
deploymentUnit.putAttachment(ATTACHMENT_KEY, pm);
}
}
Aggregations