org.infinispan.configuration.parsing.ConfigurationBuilderHolder Java Examples

The following examples show how to use org.infinispan.configuration.parsing.ConfigurationBuilderHolder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InfinispanEmbeddedProducer.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@Singleton
@Produces
EmbeddedCacheManager manager() {
    if (config.xmlConfig.isPresent()) {
        String configurationFile = config.xmlConfig.get();
        try {
            InputStream configurationStream = FileLookupFactory.newInstance().lookupFileStrict(configurationFile,
                    Thread.currentThread().getContextClassLoader());
            ConfigurationBuilderHolder configHolder = new ParserRegistry().parse(configurationStream, null);
            verifyTransactionConfiguration(configHolder.getDefaultConfigurationBuilder(), "default");
            for (Map.Entry<String, ConfigurationBuilder> entry : configHolder.getNamedConfigurationBuilders().entrySet()) {
                verifyTransactionConfiguration(entry.getValue(), entry.getKey());
            }
            return new DefaultCacheManager(configHolder, true);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    return new DefaultCacheManager();
}
 
Example #2
Source File: EmbeddedCacheConfig.java    From hono with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Create a new configuration, either from a configured file, or with some reasonable defaults.
 *
 * @param cacheConfig Common cache configuration options.
 * @return A new configuration.
 * @throws IllegalStateException in case a configuration file is configured and cannot be loaded/parsed.
 */
@Bean
public ConfigurationBuilderHolder configuration(final CommonCacheConfig cacheConfig) {
    if (this.configuration != null) {
        try {
            final ConfigurationBuilderHolder holder = new ParserRegistry().parseFile(configuration.toFile());
            LOG.info("successfully configured embedded cache from file [{}]", configuration);
            return holder;
        } catch (final IOException e) {
            LOG.error("failed to read configuration file [{}], falling back to default configuration", configuration, e);
            throw new IllegalStateException("failed to configure embedded cache", e);
        }
    } else {
        final var builderHolder = new ConfigurationBuilderHolder();
        builderHolder.newConfigurationBuilder(cacheConfig.getCacheName());
        return builderHolder;
    }
}
 
Example #3
Source File: EmbeddedKeycloakConfig.java    From spring-boot-keycloak-server-example with Apache License 2.0 5 votes vote down vote up
@Bean
DefaultCacheManager keycloakInfinispanCacheManager() throws Exception {

    KeycloakCustomProperties.Infinispan infinispan = customProperties.getInfinispan();
    try (InputStream inputStream = infinispan.getConfigLocation().getInputStream()) {
        ConfigurationBuilderHolder builder = new ParserRegistry().parse(inputStream);
        return new DefaultCacheManager(builder, true);
    }
}
 
Example #4
Source File: QuarkusCacheManagerProvider.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
public <C> C getCacheManager(Config.Scope config) {
    try {
        InputStream configurationStream = loadConfiguration(config);
        ConfigurationBuilderHolder builder = new ParserRegistry().parse(configurationStream);

        if (builder.getNamedConfigurationBuilders().get("sessions").clustering().cacheMode().isClustered()) {
            configureTransportStack(config, builder);
        }

        return (C) new DefaultCacheManager(builder, false);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #5
Source File: QuarkusCacheManagerProvider.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private void configureTransportStack(Config.Scope config, ConfigurationBuilderHolder builder) {
    String transportStack = config.get("stack");
    
    if (transportStack != null) {
        builder.getGlobalConfigurationBuilder().transport().defaultTransport()
                .addProperty("configurationFile", "default-configs/default-jgroups-" + transportStack + ".xml");
    }
}
 
Example #6
Source File: SubstituteDefaultCacheManager.java    From camel-quarkus with Apache License 2.0 4 votes vote down vote up
@Substitute
public SubstituteDefaultCacheManager(ConfigurationBuilderHolder holder, boolean start) {
    throw new RuntimeException("DefaultCacheManager not supported in native image mode");
}
 
Example #7
Source File: FixJMXClasses.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Substitute
private void parseJmx(XMLExtendedStreamReader reader, ConfigurationBuilderHolder holder) {
    // Ignore JMX configuration - but we need to skip to next element
    parseProperties(reader);
}