Java Code Examples for org.infinispan.client.hotrod.configuration.ConfigurationBuilder#withProperties()

The following examples show how to use org.infinispan.client.hotrod.configuration.ConfigurationBuilder#withProperties() . 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: InfinispanHotRodImpl.java    From khan-session with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 초기화 함수, 설정파일을 읽어서 캐시를 초기화한다.
 *
 * @param configFile
 * @param cacheName
 * @param loginCacheName
 * @throws IOException
 */
@Override
public void initialize(String configFile, String cacheName, String loginCacheName)
        throws IOException {
    StringUtils.isNotNull("configFile", configFile);

    Configuration configuration = null;
    ConfigurationBuilder builder = new ConfigurationBuilder();
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    builder.classLoader(cl);

    InputStream stream = cl.getResourceAsStream(configFile);

    if (stream == null) {
        logger.error("Can't Found configFile=" + configFile);
    } else {
        try {
            builder.withProperties(loadFromStream(stream));
        } finally {
            Util.close(stream);
        }
    }
    configuration = builder.build();


    cacheManager = new RemoteCacheManager(configuration);

    cache = cacheManager.getCache(cacheName);
    loginCache = cacheManager.getCache(loginCacheName);

    waitForConnectionReady();
}
 
Example 2
Source File: InfinispanClientProducer.java    From quarkus with Apache License 2.0 4 votes vote down vote up
/**
 * The mirror side of {@link #replaceProperties(Properties)} so that we can take out any objects that were
 * instantiated during static init time and inject them properly
 *
 * @param properties the properties that was static constructed
 * @return the configuration builder based on the provided properties
 */
private ConfigurationBuilder builderFromProperties(Properties properties) {
    // If you are changing this method, you will most likely have to change replaceProperties as well
    ConfigurationBuilder builder = new ConfigurationBuilder();
    Object marshallerInstance = properties.remove(ConfigurationProperties.MARSHALLER);
    if (marshallerInstance != null) {
        if (marshallerInstance instanceof ProtoStreamMarshaller) {
            handleProtoStreamMarshaller((ProtoStreamMarshaller) marshallerInstance, properties, beanManager);
        }
        builder.marshaller((Marshaller) marshallerInstance);
    }
    InfinispanClientRuntimeConfig infinispanClientRuntimeConfig = this.infinispanClientRuntimeConfig.get();

    infinispanClientRuntimeConfig.serverList
            .ifPresent(v -> properties.put(ConfigurationProperties.SERVER_LIST, v));

    infinispanClientRuntimeConfig.clientIntelligence
            .ifPresent(v -> properties.put(ConfigurationProperties.CLIENT_INTELLIGENCE, v));

    infinispanClientRuntimeConfig.useAuth
            .ifPresent(v -> properties.put(ConfigurationProperties.USE_AUTH, v));
    infinispanClientRuntimeConfig.authUsername
            .ifPresent(v -> properties.put(ConfigurationProperties.AUTH_USERNAME, v));
    infinispanClientRuntimeConfig.authPassword
            .ifPresent(v -> properties.put(ConfigurationProperties.AUTH_PASSWORD, v));
    infinispanClientRuntimeConfig.authRealm
            .ifPresent(v -> properties.put(ConfigurationProperties.AUTH_REALM, v));
    infinispanClientRuntimeConfig.authServerName
            .ifPresent(v -> properties.put(ConfigurationProperties.AUTH_SERVER_NAME, v));
    infinispanClientRuntimeConfig.authClientSubject
            .ifPresent(v -> properties.put(ConfigurationProperties.AUTH_CLIENT_SUBJECT, v));
    infinispanClientRuntimeConfig.authCallbackHandler
            .ifPresent(v -> properties.put(ConfigurationProperties.AUTH_CALLBACK_HANDLER, v));

    infinispanClientRuntimeConfig.saslMechanism
            .ifPresent(v -> properties.put(ConfigurationProperties.SASL_MECHANISM, v));

    builder.withProperties(properties);

    return builder;
}
 
Example 3
Source File: InfinispanRemoteConfigurationProperties.java    From infinispan-spring-boot with Apache License 2.0 4 votes vote down vote up
public ConfigurationBuilder getConfigurationBuilder() {
   ConfigurationBuilder builder = new ConfigurationBuilder();
   Properties properties = this.getProperties();
   builder.withProperties(properties);
   return builder;
}