use of org.infinispan.commons.util.TypedProperties in project infinispan by infinispan.
the class ConfigurationBuilder method withProperties.
@Override
public ConfigurationBuilder withProperties(Properties properties) {
TypedProperties typed = TypedProperties.toTypedProperties(properties);
if (typed.containsKey(ConfigurationProperties.URI)) {
HotRodURI uri = HotRodURI.create(typed.getProperty(ConfigurationProperties.URI));
this.read(uri.toConfigurationBuilder().build());
}
if (typed.containsKey(ConfigurationProperties.ASYNC_EXECUTOR_FACTORY)) {
this.asyncExecutorFactory().factoryClass(typed.getProperty(ConfigurationProperties.ASYNC_EXECUTOR_FACTORY, null, true));
}
this.asyncExecutorFactory().withExecutorProperties(typed);
String balancingStrategyClass = typed.getProperty(ConfigurationProperties.REQUEST_BALANCING_STRATEGY, null, true);
if (balancingStrategyClass != null) {
this.balancingStrategy(balancingStrategyClass);
}
if (typed.containsKey(ConfigurationProperties.CLIENT_INTELLIGENCE)) {
this.clientIntelligence(typed.getEnumProperty(ConfigurationProperties.CLIENT_INTELLIGENCE, ClientIntelligence.class, ClientIntelligence.getDefault(), true));
}
this.connectionPool.withPoolProperties(typed);
if (typed.containsKey(ConfigurationProperties.CONNECT_TIMEOUT)) {
this.connectionTimeout(typed.getIntProperty(ConfigurationProperties.CONNECT_TIMEOUT, connectionTimeout, true));
}
if (typed.containsKey(ConfigurationProperties.HASH_FUNCTION_PREFIX + ".1")) {
log.warn("Hash function version 1 is no longer supported");
}
for (int i = 0; i < consistentHashImpl.length; i++) {
if (consistentHashImpl[i] != null) {
int version = i + 1;
String hashClassName = typed.getProperty(ConfigurationProperties.HASH_FUNCTION_PREFIX + "." + version, null, true);
if (hashClassName != null) {
this.consistentHashImpl(version, hashClassName);
}
}
}
if (typed.containsKey(ConfigurationProperties.FORCE_RETURN_VALUES)) {
this.forceReturnValues(typed.getBooleanProperty(ConfigurationProperties.FORCE_RETURN_VALUES, forceReturnValues, true));
}
if (typed.containsKey(ConfigurationProperties.KEY_SIZE_ESTIMATE)) {
this.keySizeEstimate(typed.getIntProperty(ConfigurationProperties.KEY_SIZE_ESTIMATE, keySizeEstimate, true));
}
if (typed.containsKey(ConfigurationProperties.MARSHALLER)) {
this.marshaller(typed.getProperty(ConfigurationProperties.MARSHALLER, null, true));
}
if (typed.containsKey(ConfigurationProperties.CONTEXT_INITIALIZERS)) {
String initializers = typed.getProperty(ConfigurationProperties.CONTEXT_INITIALIZERS);
for (String sci : initializers.split(",")) this.addContextInitializer(sci);
}
if (typed.containsKey(ConfigurationProperties.PROTOCOL_VERSION)) {
this.version(ProtocolVersion.parseVersion(typed.getProperty(ConfigurationProperties.PROTOCOL_VERSION, protocolVersion.toString(), true)));
}
String serverList = typed.getProperty(ConfigurationProperties.SERVER_LIST, null, true);
if (serverList != null) {
this.servers.clear();
this.addServers(serverList);
}
if (typed.containsKey(ConfigurationProperties.SO_TIMEOUT)) {
this.socketTimeout(typed.getIntProperty(ConfigurationProperties.SO_TIMEOUT, socketTimeout, true));
}
if (typed.containsKey(ConfigurationProperties.TCP_NO_DELAY)) {
this.tcpNoDelay(typed.getBooleanProperty(ConfigurationProperties.TCP_NO_DELAY, tcpNoDelay, true));
}
if (typed.containsKey(ConfigurationProperties.TCP_KEEP_ALIVE)) {
this.tcpKeepAlive(typed.getBooleanProperty(ConfigurationProperties.TCP_KEEP_ALIVE, tcpKeepAlive, true));
}
if (typed.containsKey(ConfigurationProperties.VALUE_SIZE_ESTIMATE)) {
this.valueSizeEstimate(typed.getIntProperty(ConfigurationProperties.VALUE_SIZE_ESTIMATE, valueSizeEstimate, true));
}
if (typed.containsKey(ConfigurationProperties.MAX_RETRIES)) {
this.maxRetries(typed.getIntProperty(ConfigurationProperties.MAX_RETRIES, maxRetries, true));
}
this.security.ssl().withProperties(properties);
this.security.authentication().withProperties(properties);
String serialAllowList = typed.getProperty(ConfigurationProperties.JAVA_SERIAL_WHITELIST);
if (serialAllowList != null && !serialAllowList.isEmpty()) {
org.infinispan.commons.logging.Log.CONFIG.deprecatedProperty(ConfigurationProperties.JAVA_SERIAL_WHITELIST, ConfigurationProperties.JAVA_SERIAL_ALLOWLIST);
String[] classes = serialAllowList.split(",");
Collections.addAll(this.allowListRegExs, classes);
}
serialAllowList = typed.getProperty(ConfigurationProperties.JAVA_SERIAL_ALLOWLIST);
if (serialAllowList != null && !serialAllowList.isEmpty()) {
String[] classes = serialAllowList.split(",");
Collections.addAll(this.allowListRegExs, classes);
}
if (typed.containsKey(ConfigurationProperties.BATCH_SIZE)) {
this.batchSize(typed.getIntProperty(ConfigurationProperties.BATCH_SIZE, batchSize, true));
}
// TODO read TRANSACTION_TIMEOUT property after TransactionConfigurationBuilder is removed.
transaction.withTransactionProperties(typed);
nearCache.withProperties(properties);
Map<String, String> xsiteProperties = typed.entrySet().stream().filter(e -> ((String) e.getKey()).startsWith(ConfigurationProperties.CLUSTER_PROPERTIES_PREFIX)).collect(Collectors.toMap(e -> ConfigurationProperties.CLUSTER_PROPERTIES_PREFIX_REGEX.matcher((String) e.getKey()).replaceFirst(""), e -> StringPropertyReplacer.replaceProperties((String) e.getValue())));
xsiteProperties.forEach((key, value) -> {
ClusterConfigurationBuilder cluster = this.addCluster(key);
parseServers(value, cluster::addClusterNode);
});
Set<String> cachesNames = typed.keySet().stream().map(k -> (String) k).filter(k -> k.startsWith(ConfigurationProperties.CACHE_PREFIX)).map(k -> k.charAt(CACHE_PREFIX_LENGTH) == '[' ? k.substring(CACHE_PREFIX_LENGTH + 1, k.indexOf(']', CACHE_PREFIX_LENGTH)) : k.substring(CACHE_PREFIX_LENGTH, k.indexOf('.', CACHE_PREFIX_LENGTH + 1))).collect(Collectors.toSet());
for (String cacheName : cachesNames) {
this.remoteCache(cacheName).withProperties(typed);
}
statistics.withProperties(properties);
if (typed.containsKey(ConfigurationProperties.TRANSPORT_FACTORY)) {
this.transportFactory = Util.getInstance(typed.getProperty(ConfigurationProperties.TRANSPORT_FACTORY), classLoader.get());
}
return this;
}
use of org.infinispan.commons.util.TypedProperties in project infinispan by infinispan.
the class AuthenticationConfigurationBuilder method withProperties.
@Override
public ConfigurationBuilder withProperties(Properties properties) {
TypedProperties typed = TypedProperties.toTypedProperties(properties);
if (typed.containsKey(ConfigurationProperties.SASL_MECHANISM))
saslMechanism(typed.getProperty(ConfigurationProperties.SASL_MECHANISM, saslMechanism, true));
Object prop = typed.get(ConfigurationProperties.AUTH_CALLBACK_HANDLER);
if (prop instanceof String) {
String cbhClassName = StringPropertyReplacer.replaceProperties((String) prop);
CallbackHandler handler = Util.getInstance(cbhClassName, builder.getBuilder().classLoader());
this.callbackHandler(handler);
} else if (prop instanceof CallbackHandler) {
this.callbackHandler((CallbackHandler) prop);
}
if (typed.containsKey(ConfigurationProperties.AUTH_USERNAME))
username(typed.getProperty(ConfigurationProperties.AUTH_USERNAME, username, true));
if (typed.containsKey(ConfigurationProperties.AUTH_PASSWORD))
password(typed.getProperty(ConfigurationProperties.AUTH_PASSWORD, null, true));
if (typed.containsKey(ConfigurationProperties.AUTH_TOKEN))
token(typed.getProperty(ConfigurationProperties.AUTH_TOKEN, token, true));
if (typed.containsKey(ConfigurationProperties.AUTH_REALM))
realm(typed.getProperty(ConfigurationProperties.AUTH_REALM, realm, true));
if (typed.containsKey(ConfigurationProperties.AUTH_SERVER_NAME))
serverName(typed.getProperty(ConfigurationProperties.AUTH_SERVER_NAME, serverName, true));
if (typed.containsKey(ConfigurationProperties.AUTH_CLIENT_SUBJECT))
this.clientSubject((Subject) typed.get(ConfigurationProperties.AUTH_CLIENT_SUBJECT));
Map<String, String> saslProperties = typed.entrySet().stream().filter(e -> ((String) e.getKey()).startsWith(ConfigurationProperties.SASL_PROPERTIES_PREFIX)).collect(Collectors.toMap(e -> ConfigurationProperties.SASL_PROPERTIES_PREFIX_REGEX.matcher((String) e.getKey()).replaceFirst(""), e -> StringPropertyReplacer.replaceProperties((String) e.getValue())));
if (!saslProperties.isEmpty())
this.saslProperties(saslProperties);
if (typed.containsKey(ConfigurationProperties.USE_AUTH))
this.enabled(typed.getBooleanProperty(ConfigurationProperties.USE_AUTH, enabled, true));
return builder.getBuilder();
}
use of org.infinispan.commons.util.TypedProperties in project infinispan by infinispan.
the class TransactionConfigurationBuilder method withTransactionProperties.
void withTransactionProperties(Properties properties) {
TypedProperties typed = TypedProperties.toTypedProperties(properties);
transactionMode(typed.getEnumProperty(TRANSACTION_MODE, TransactionMode.class, transactionMode, true));
transactionManagerLookup(tlmFromString(typed.getProperty(TRANSACTION_MANAGER_LOOKUP, tlmClass(), true)));
setTimeoutMillis(typed.getLongProperty(TRANSACTION_TIMEOUT, timeout, true));
}
use of org.infinispan.commons.util.TypedProperties in project infinispan by infinispan.
the class RestClientConfiguration method properties.
public Properties properties() {
TypedProperties properties = new TypedProperties();
properties.setProperty(RestClientConfigurationProperties.PROTOCOL, protocol().name());
properties.setProperty(RestClientConfigurationProperties.CONNECT_TIMEOUT, Long.toString(connectionTimeout()));
properties.setProperty(RestClientConfigurationProperties.SO_TIMEOUT, socketTimeout());
properties.setProperty(RestClientConfigurationProperties.TCP_NO_DELAY, tcpNoDelay());
properties.setProperty(RestClientConfigurationProperties.TCP_KEEP_ALIVE, tcpKeepAlive());
properties.setProperty(RestClientConfigurationProperties.CONTEXT_PATH, tcpKeepAlive());
StringBuilder servers = new StringBuilder();
for (ServerConfiguration server : servers()) {
if (servers.length() > 0) {
servers.append(";");
}
servers.append(server.host()).append(":").append(server.port());
}
properties.setProperty(RestClientConfigurationProperties.SERVER_LIST, servers.toString());
properties.setProperty(RestClientConfigurationProperties.USE_SSL, Boolean.toString(security.ssl().enabled()));
if (security.ssl().keyStoreFileName() != null)
properties.setProperty(RestClientConfigurationProperties.KEY_STORE_FILE_NAME, security.ssl().keyStoreFileName());
if (security.ssl().keyStorePassword() != null)
properties.setProperty(RestClientConfigurationProperties.KEY_STORE_PASSWORD, new String(security.ssl().keyStorePassword()));
if (security.ssl().keyStoreCertificatePassword() != null)
properties.setProperty(RestClientConfigurationProperties.KEY_STORE_CERTIFICATE_PASSWORD, new String(security.ssl().keyStoreCertificatePassword()));
if (security.ssl().trustStoreFileName() != null)
properties.setProperty(RestClientConfigurationProperties.TRUST_STORE_FILE_NAME, security.ssl().trustStoreFileName());
if (security.ssl().trustStorePassword() != null)
properties.setProperty(RestClientConfigurationProperties.TRUST_STORE_PASSWORD, new String(security.ssl().trustStorePassword()));
if (security.ssl().sniHostName() != null)
properties.setProperty(RestClientConfigurationProperties.SNI_HOST_NAME, security.ssl().sniHostName());
if (security.ssl().protocol() != null)
properties.setProperty(RestClientConfigurationProperties.SSL_PROTOCOL, security.ssl().protocol());
if (security.ssl().sslContext() != null)
properties.put(RestClientConfigurationProperties.SSL_CONTEXT, security.ssl().sslContext());
if (security.ssl().trustManagers() != null)
properties.put(RestClientConfigurationProperties.TRUST_MANAGERS, security.ssl().trustManagers());
properties.setProperty(RestClientConfigurationProperties.USE_AUTH, Boolean.toString(security.authentication().enabled()));
if (security.authentication().mechanism() != null)
properties.setProperty(RestClientConfigurationProperties.AUTH_MECHANISM, security.authentication().mechanism());
return properties;
}
use of org.infinispan.commons.util.TypedProperties in project infinispan by infinispan.
the class IndexingConfigurationBuilder method ensureSingleIndexingConfig.
private void ensureSingleIndexingConfig() {
TypedProperties typedProperties = attributes.attribute(PROPERTIES).get();
boolean hasMultiIndexConfig = typedProperties.keySet().stream().map(Object::toString).filter(k -> k.contains(".")).map(k -> k.substring(k.lastIndexOf('.'))).anyMatch(s -> typedProperties.keySet().stream().filter(k -> k.toString().endsWith(s)).count() > 1);
if (hasMultiIndexConfig) {
throw CONFIG.foundDifferentIndexConfigPerType();
}
}
Aggregations