use of io.quarkus.deployment.annotations.Consume in project keycloak by keycloak.
the class KeycloakProcessor method configureProviders.
/**
* <p>Load the built-in provider factories during build time so we don't spend time looking up them at runtime. By loading
* providers at this stage we are also able to perform a more dynamic configuration based on the default providers.
*
* <p>User-defined providers are going to be loaded at startup</p>
*
* @param recorder
*/
@Consume(RuntimeConfigSetupCompleteBuildItem.class)
@Record(ExecutionTime.RUNTIME_INIT)
@BuildStep
KeycloakSessionFactoryPreInitBuildItem configureProviders(KeycloakRecorder recorder) {
Profile.setInstance(new QuarkusProfile());
Map<Spi, Map<Class<? extends Provider>, Map<String, Class<? extends ProviderFactory>>>> factories = new HashMap<>();
Map<Class<? extends Provider>, String> defaultProviders = new HashMap<>();
Map<String, ProviderFactory> preConfiguredProviders = new HashMap<>();
for (Entry<Spi, Map<Class<? extends Provider>, Map<String, ProviderFactory>>> entry : loadFactories(preConfiguredProviders).entrySet()) {
checkProviders(entry.getKey(), entry.getValue(), defaultProviders);
for (Entry<Class<? extends Provider>, Map<String, ProviderFactory>> value : entry.getValue().entrySet()) {
for (ProviderFactory factory : value.getValue().values()) {
factories.computeIfAbsent(entry.getKey(), key -> new HashMap<>()).computeIfAbsent(entry.getKey().getProviderClass(), aClass -> new HashMap<>()).put(factory.getId(), factory.getClass());
}
}
}
recorder.configSessionFactory(factories, defaultProviders, preConfiguredProviders, Environment.isRebuild());
return new KeycloakSessionFactoryPreInitBuildItem();
}
use of io.quarkus.deployment.annotations.Consume in project keycloak by keycloak.
the class CLusteringBuildSteps method configureInfinispan.
@Consume(KeycloakSessionFactoryPreInitBuildItem.class)
@Record(ExecutionTime.RUNTIME_INIT)
@BuildStep
void configureInfinispan(KeycloakRecorder recorder, BuildProducer<SyntheticBeanBuildItem> syntheticBeanBuildItems, ShutdownContextBuildItem shutdownContext) {
String configFile = getConfigValue("kc.spi-connections-infinispan-quarkus-config-file").getValue();
if (configFile != null) {
Path configPath = Paths.get(configFile);
String path;
if (configPath.toFile().exists()) {
path = configPath.toFile().getAbsolutePath();
} else {
path = configPath.getFileName().toString();
}
InputStream url = FileLookupFactory.newInstance().lookupFile(path, KeycloakProcessor.class.getClassLoader());
if (url == null) {
throw new IllegalArgumentException("Could not load cluster configuration file at [" + configPath + "]");
}
try (BufferedReader reader = new BufferedReader(new InputStreamReader(url))) {
String config = reader.lines().collect(Collectors.joining("\n"));
syntheticBeanBuildItems.produce(SyntheticBeanBuildItem.configure(CacheManagerFactory.class).scope(ApplicationScoped.class).unremovable().setRuntimeInit().runtimeValue(recorder.createCacheInitializer(config, shutdownContext)).done());
} catch (Exception cause) {
throw new RuntimeException("Failed to read clustering configuration from [" + url + "]", cause);
}
} else {
throw new IllegalArgumentException("Option 'configFile' needs to be specified");
}
}
Aggregations