org.infinispan.spring.ConfigurationPropertiesOverrides Maven / Gradle / Ivy
Go to download
The Infinispan Spring Integration project provides Spring
integration for Infinispan, a high performance distributed cache.
Its primary features are
* An implementation of org.springframework.cache.CacheManager,
Spring's central caching abstraction, backed by Infinispan's
EmbeddedCacheManager. To be used if your Spring-powered
application and Infinispan are colocated, i.e. running within
the same VM.
* An implementation of org.springframework.cache.CacheManager
backed by Infinispan's RemoteCacheManager. To bes used if your
Spring-powered application accesses Infinispan remotely, i.e.
over the network.
* An implementation of org.springframework.cache.CacheManager
backed by a CacheContainer reference. To be used if your Spring-
powered application needs access to a CacheContainer defined
outside the application (e.g. retrieved from JNDI)
* Spring namespace support allowing shortcut definitions for all the
components above
In addition, Infinispan Spring Integration offers various FactoryBeans
for facilitating creation of Infinispan core classes - Cache, CacheManager,
... - within a Spring context.
The newest version!
package org.infinispan.spring;
import java.net.InetSocketAddress;
import java.util.Collection;
import java.util.Map;
import java.util.Properties;
import static org.infinispan.client.hotrod.impl.ConfigurationProperties.*;
/**
*
* Provides a mechanism to override selected configuration properties using explicit setters for
* each configuration setting.
*
*
* @author Olaf Bergner
*
*/
public class ConfigurationPropertiesOverrides {
private final Properties overridingProperties = new Properties();
/**
* @return
* @see java.util.Hashtable#isEmpty()
*/
public boolean isEmpty() {
return this.overridingProperties.isEmpty();
}
/**
* @param TransportFactory
*/
public void setTransportFactory(final String TransportFactory) {
this.overridingProperties.setProperty(TRANSPORT_FACTORY, TransportFactory);
}
/**
* @param serverList
*/
public void setServerList(final Collection serverList) {
final StringBuilder serverListStr = new StringBuilder();
for (final InetSocketAddress server : serverList) {
serverListStr.append(server.getHostName()).append(":").append(server.getPort())
.append(";");
}
serverListStr.deleteCharAt(serverListStr.length() - 1);
this.overridingProperties.setProperty(SERVER_LIST, serverListStr.toString());
}
/**
* @param marshaller
*/
public void setMarshaller(final String marshaller) {
this.overridingProperties.setProperty(MARSHALLER, marshaller);
}
/**
* @param asyncExecutorFactory
*/
public void setAsyncExecutorFactory(final String asyncExecutorFactory) {
this.overridingProperties.setProperty(ASYNC_EXECUTOR_FACTORY, asyncExecutorFactory);
}
/**
* @param tcpNoDelay
*/
public void setTcpNoDelay(final boolean tcpNoDelay) {
this.overridingProperties.setProperty(TCP_NO_DELAY, Boolean.toString(tcpNoDelay));
}
public void setTcpKeepAlive(final boolean tcpKeepAlive) {
this.overridingProperties.setProperty(TCP_KEEP_ALIVE, Boolean.toString(tcpKeepAlive));
}
/**
* @param pingOnStartup
*/
public void setPingOnStartup(final boolean pingOnStartup) {
this.overridingProperties.setProperty(PING_ON_STARTUP, Boolean.toString(pingOnStartup));
}
/**
* @param requestBalancingStrategy
*/
public void setRequestBalancingStrategy(final String requestBalancingStrategy) {
this.overridingProperties.setProperty(REQUEST_BALANCING_STRATEGY, requestBalancingStrategy);
}
/**
* @param keySizeEstimate
*/
public void setKeySizeEstimate(final int keySizeEstimate) {
this.overridingProperties.setProperty(KEY_SIZE_ESTIMATE, Integer.toString(keySizeEstimate));
}
/**
* @param valueSizeEstimate
*/
public void setValueSizeEstimate(final int valueSizeEstimate) {
this.overridingProperties.setProperty(VALUE_SIZE_ESTIMATE,
Integer.toString(valueSizeEstimate));
}
/**
* @param forceReturnValues
*/
public void setForceReturnValues(final boolean forceReturnValues) {
this.overridingProperties.setProperty(FORCE_RETURN_VALUES,
Boolean.toString(forceReturnValues));
}
/**
* @param configurationPropertiesToOverride
* @return
*/
public Properties override(final Properties configurationPropertiesToOverride) {
final Properties answer = Properties.class.cast(configurationPropertiesToOverride.clone());
for (final Map.Entry