org.infinispan.configuration.parsing.ParserRegistry Java Examples

The following examples show how to use org.infinispan.configuration.parsing.ParserRegistry. 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: CachingModule.java    From EDDI with Apache License 2.0 6 votes vote down vote up
@Provides
@Singleton
private EmbeddedCacheManager provideEmbeddedCacheManager(@Named("mongodb.hosts") String hosts,
                                                         @Named("mongodb.port") Integer port,
                                                         @Named("mongodb.source") String source,
                                                         @Named("mongodb.database") String database,
                                                         @Named("mongodb.username") String username,
                                                         @Named("mongodb.password") String password) {

    var builder = new ParserRegistry().parse(cacheConfig);
    var configurationBuilder = builder.getNamedConfigurationBuilders().get("differ.ackAwaitingCommands");

    configurationBuilder.persistence().
            addStore(MongoDBStoreConfigurationBuilder.class).
            connectionURI(createConnectionString(hosts, port, database, username, password, source)).
            collection("infinispan_cachestore_ackAwaitingCommands");

    return new DefaultCacheManager(builder, true);
}
 
Example #4
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 #5
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);
    }
}