org.infinispan.configuration.cache.ConfigurationBuilder Maven / Gradle / Ivy
package org.infinispan.configuration.cache;
import static java.util.Arrays.asList;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import org.infinispan.commons.CacheConfigurationException;
import org.infinispan.commons.configuration.Builder;
import org.infinispan.commons.configuration.ConfigurationUtils;
import org.infinispan.configuration.global.GlobalConfiguration;
public class ConfigurationBuilder implements ConfigurationChildBuilder {
private final ClusteringConfigurationBuilder clustering;
private final CustomInterceptorsConfigurationBuilder customInterceptors;
private final DataContainerConfigurationBuilder dataContainer;
private final DeadlockDetectionConfigurationBuilder deadlockDetection;
private final EvictionConfigurationBuilder eviction;
private final ExpirationConfigurationBuilder expiration;
private final IndexingConfigurationBuilder indexing;
private final InvocationBatchingConfigurationBuilder invocationBatching;
private final JMXStatisticsConfigurationBuilder jmxStatistics;
private final PersistenceConfigurationBuilder persistence;
private final LockingConfigurationBuilder locking;
private final SecurityConfigurationBuilder security;
private final StoreAsBinaryConfigurationBuilder storeAsBinary;
private final TransactionConfigurationBuilder transaction;
private final VersioningConfigurationBuilder versioning;
private final UnsafeConfigurationBuilder unsafe;
private final List> modules = new ArrayList>();
private final SitesConfigurationBuilder sites;
private final CompatibilityModeConfigurationBuilder compatibility;
public ConfigurationBuilder() {
this.clustering = new ClusteringConfigurationBuilder(this);
this.customInterceptors = new CustomInterceptorsConfigurationBuilder(this);
this.dataContainer = new DataContainerConfigurationBuilder(this);
this.deadlockDetection = new DeadlockDetectionConfigurationBuilder(this);
this.eviction = new EvictionConfigurationBuilder(this);
this.expiration = new ExpirationConfigurationBuilder(this);
this.indexing = new IndexingConfigurationBuilder(this);
this.invocationBatching = new InvocationBatchingConfigurationBuilder(this);
this.jmxStatistics = new JMXStatisticsConfigurationBuilder(this);
this.persistence = new PersistenceConfigurationBuilder(this);
this.locking = new LockingConfigurationBuilder(this);
this.security = new SecurityConfigurationBuilder(this);
this.storeAsBinary = new StoreAsBinaryConfigurationBuilder(this);
this.transaction = new TransactionConfigurationBuilder(this);
this.versioning = new VersioningConfigurationBuilder(this);
this.unsafe = new UnsafeConfigurationBuilder(this);
this.sites = new SitesConfigurationBuilder(this);
this.compatibility = new CompatibilityModeConfigurationBuilder(this);
}
@Override
public ClusteringConfigurationBuilder clustering() {
return clustering;
}
@Override
public CustomInterceptorsConfigurationBuilder customInterceptors() {
return customInterceptors;
}
@Override
public DataContainerConfigurationBuilder dataContainer() {
return dataContainer;
}
@Override
public DeadlockDetectionConfigurationBuilder deadlockDetection() {
return deadlockDetection;
}
@Override
public EvictionConfigurationBuilder eviction() {
return eviction;
}
@Override
public ExpirationConfigurationBuilder expiration() {
return expiration;
}
@Override
public IndexingConfigurationBuilder indexing() {
return indexing;
}
@Override
public InvocationBatchingConfigurationBuilder invocationBatching() {
return invocationBatching;
}
@Override
public JMXStatisticsConfigurationBuilder jmxStatistics() {
return jmxStatistics;
}
@Override
public StoreAsBinaryConfigurationBuilder storeAsBinary() {
return storeAsBinary;
}
@Override
public PersistenceConfigurationBuilder persistence() {
return persistence;
}
@Override
public LockingConfigurationBuilder locking() {
return locking;
}
@Override
public SecurityConfigurationBuilder security() {
return security;
}
@Override
public TransactionConfigurationBuilder transaction() {
return transaction;
}
@Override
public VersioningConfigurationBuilder versioning() {
return versioning;
}
@Override
public UnsafeConfigurationBuilder unsafe() {
return unsafe;
}
@Override
public SitesConfigurationBuilder sites() {
return sites;
}
@Override
public CompatibilityModeConfigurationBuilder compatibility() {
return compatibility;
}
public List> modules() {
return modules;
}
public ConfigurationBuilder clearModules() {
modules.clear();
return this;
}
public > T addModule(Class klass) {
try {
Constructor constructor = klass.getDeclaredConstructor(ConfigurationBuilder.class);
T builder = constructor.newInstance(this);
this.modules.add(builder);
return builder;
} catch (Exception e) {
throw new CacheConfigurationException("Could not instantiate module configuration builder '" + klass.getName() + "'", e);
}
}
@SuppressWarnings("unchecked")
public void validate() {
for (Builder> validatable:
asList(clustering, customInterceptors, dataContainer, deadlockDetection, eviction, expiration, indexing,
invocationBatching, jmxStatistics, persistence, locking, storeAsBinary, transaction,
versioning, unsafe, sites, compatibility)) {
validatable.validate();
}
for (Builder> m : modules) {
m.validate();
}
}
@Override
public void validate(GlobalConfiguration globalConfig) {
for (ConfigurationChildBuilder validatable:
asList(clustering, customInterceptors, dataContainer, deadlockDetection, eviction, expiration, indexing,
invocationBatching, jmxStatistics, persistence, locking, storeAsBinary, transaction,
versioning, unsafe, sites, compatibility)) {
validatable.validate(globalConfig);
}
// Modules cannot be checked with GlobalConfiguration
}
@Override
public Configuration build() {
return build(true);
}
public Configuration build(GlobalConfiguration globalConfiguration) {
validate(globalConfiguration);
return build(true);
}
public Configuration build(boolean validate) {
if (validate) {
validate();
}
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy