Index: core/src/main/java/org/infinispan/config/Configuration.java =================================================================== --- core/src/main/java/org/infinispan/config/Configuration.java (revision a120cd344fc2f3938ef2a8b6035a405df171feb0) +++ core/src/main/java/org/infinispan/config/Configuration.java (revision ) @@ -21,6 +21,7 @@ */ package org.infinispan.config; +import org.infinispan.CacheException; import org.infinispan.container.DataContainer; import org.infinispan.container.DefaultDataContainer; import org.infinispan.distribution.ch.DefaultConsistentHash; @@ -29,8 +30,8 @@ import org.infinispan.eviction.EvictionThreadPolicy; import org.infinispan.factories.ComponentRegistry; import org.infinispan.factories.annotations.Inject; -import org.infinispan.factories.annotations.SurvivesRestarts; import org.infinispan.factories.annotations.Start; +import org.infinispan.factories.annotations.SurvivesRestarts; import org.infinispan.loaders.CacheLoaderConfig; import org.infinispan.remoting.ReplicationQueueImpl; import org.infinispan.transaction.lookup.GenericTransactionManagerLookup; @@ -38,18 +39,13 @@ import org.infinispan.util.TypedProperties; import org.infinispan.util.Util; import org.infinispan.util.concurrent.IsolationLevel; -import org.infinispan.CacheException; import org.infinispan.util.hash.MurmurHash3; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlTransient; -import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.Marshaller; +import javax.xml.bind.annotation.*; import javax.xml.bind.annotation.adapters.XmlAdapter; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - +import java.io.StringWriter; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -73,21 +69,22 @@ @SurvivesRestarts @XmlAccessorType(XmlAccessType.FIELD) @XmlType(propOrder = {}) +@XmlRootElement(name = "namedCacheConfiguration") @ConfigurationDoc(name = "default") public class Configuration extends AbstractNamedCacheConfigurationBean { private static final long serialVersionUID = 5553791890144997466L; - + /** * Defines the local, in-VM locking and concurrency characteristics of the cache. - * + * * @author Vladimir Blagojevic * @since 5.0 */ public interface LockingConfig { /** * Maximum time to attempt a particular lock acquisition - * + * * @param lockAcquisitionTimeout */ LockingConfig lockAcquisitionTimeout(Long lockAcquisitionTimeout); @@ -97,7 +94,7 @@ * levels. See http://en.wikipedia.org/wiki/Isolation_level * for a discussion on isolation levels. - * + * * @param isolationLevel */ LockingConfig isolationLevel(IsolationLevel isolationLevel); @@ -107,7 +104,7 @@ * set to false, if the writer at commit time discovers that the working entry and the * underlying entry have different versions, the working entry will overwrite the underlying * entry. If true, such version conflict - known as a write-skew - will throw an Exception. - * + * * @param writeSkewCheck */ LockingConfig writeSkewCheck(Boolean writeSkewCheck); @@ -116,7 +113,7 @@ * If true, a pool of shared locks is maintained for all entries that need to be locked. * Otherwise, a lock is created per entry in the cache. Lock striping helps control memory * footprint but may reduce concurrency in the system. - * + * * @param useLockStriping */ LockingConfig useLockStriping(Boolean useLockStriping); @@ -125,7 +122,7 @@ * Concurrency level for lock containers. Adjust this value according to the number of * concurrent threads interating with Infinispan. Similar to the concurrencyLevel tuning * parameter seen in the JDK's ConcurrentHashMap. - * + * * @param concurrencyLevel */ LockingConfig concurrencyLevel(Integer concurrencyLevel); @@ -133,7 +130,7 @@ /** * Holds the configuration for cache loaders and stores. - * + * * @author Vladimir Blagojevic * @since 5.0 */ @@ -144,9 +141,9 @@ * startup and you want to avoid cache operations being delayed as a result of loading this data * lazily. Can be used to provide a 'warm-cache' on startup, however there is a performance * penalty as startup time is affected by this process. - * + * * @param preload - */ + */ LoadersConfig preload(Boolean preload); /** @@ -157,9 +154,9 @@ *
* If false, the cache store contains a copy of the contents in memory, so writes to cache result * in cache store writes. This essentially gives you a 'write-through' configuration. - * + * * @param passivation - */ + */ LoadersConfig passivation(Boolean passivation); /** @@ -172,9 +169,9 @@ * If disabled, each individual cache reacts to a potential remote update by storing the data to * the cache store. Note that this could be useful if each individual node has its own cache * store - perhaps local on-disk. - * + * * @param shared - */ + */ LoadersConfig shared(Boolean shared); LoadersConfig addCacheLoaderConfig(CacheLoaderConfig clc); @@ -184,7 +181,7 @@ /** * Defines transactional (JTA) characteristics of the cache. - * + * * @author Vladimir Blagojevic * @since 5.0 */ @@ -193,7 +190,7 @@ * Fully qualified class name of a class that looks up a reference to a * {@link javax.transaction.TransactionManager}. The default provided is capable of locating * the default TransactionManager in most popular Java EE systems, using a JNDI lookup. - * + * * @param transactionManagerLookupClass */ TransactionConfig transactionManagerLookupClass(Class transactionManagerLookupClass); @@ -204,7 +201,7 @@ * sent. Otherwise, the commit phase will be asynchronous. Keeping it as false improves * performance of 2PC transactions, since any remote failures are trapped during the prepare * phase anyway and appropriate rollbacks are issued. - * + * * @param syncCommitPhase */ TransactionConfig syncCommitPhase(Boolean syncCommitPhase); @@ -214,7 +211,7 @@ * synchronous, so Infinispan will wait for responses from all nodes to which the rollback was * sent. Otherwise, the rollback phase will be asynchronous. Keeping it as false improves * performance of 2PC transactions. - * + * * @param syncRollbackPhase */ TransactionConfig syncRollbackPhase(Boolean syncRollbackPhase); @@ -226,14 +223,14 @@ * performed. The node that gets locked is the main data owner, i.e. the node where data would * reside if numOwners==1. If the node where the lock resides crashes, then the transaction is * marked for rollback - data is in a consistent state, no fault tolerance. - * + * * @param useEagerLocking */ TransactionConfig useEagerLocking(Boolean useEagerLocking); /** * Configure Transaction manager lookup directly using an instance of TransactionManagerLookup - * + * * @param transactionManagerLookup instance to use as lookup * @return this TransactionConfig */ @@ -246,7 +243,7 @@ * performed. The node that gets locked is the main data owner, i.e. the node where data would * reside if numOwners==1. If the node where the lock resides crashes, then the transaction is * marked for rollback - data is in a consistent state, no fault tolerance. - * + * * @param eagerLockSingleNode */ TransactionConfig eagerLockSingleNode(Boolean eagerLockSingleNode); @@ -263,14 +260,14 @@ /** * Configures deadlock detection. - * + * * @author Vladimir Blagojevic * @since 5.0 */ public interface DeadlockDetectionConfig { /** * Toggle to enable/disable deadlock detection - * + * * @param useEagerDeadlockDetection */ DeadlockDetectionConfig enabled(Boolean enabled); @@ -278,7 +275,7 @@ /** * Time period that determines how often is lock acquisition attempted within maximum time * allowed to acquire a particular lock - * + * * @param eagerDeadlockSpinDuration */ DeadlockDetectionConfig spinDuration(Long duration); @@ -286,7 +283,7 @@ /** * Configures custom interceptors to be added to the cache. - * + * * @author Vladimir Blagojevic * @since 5.0 */ @@ -298,7 +295,7 @@ /** * Controls the eviction settings for the cache. - * + * * @author Vladimir Blagojevic * @since 5.0 */ @@ -306,7 +303,7 @@ /** * Interval between subsequent eviction runs, in milliseconds. If you wish to disable the * periodic eviction process altogether, set wakeupInterval to -1. - * + * * @param evictionWakeUpInterval */ EvictionConfig wakeUpInterval(Long wakeUpInterval); @@ -314,14 +311,14 @@ /** * Eviction strategy. Available options are 'UNORDERED', 'FIFO', 'LRU' and 'NONE' (to disable * eviction). - * + * * @param evictionStrategy */ EvictionConfig strategy(EvictionStrategy strategy); /** * Threading policy for eviction. - * + * * @param policy */ EvictionConfig threadPolicy(EvictionThreadPolicy threadPolicy); @@ -330,7 +327,7 @@ * Maximum number of entries in a cache instance. If selected value is not a power of two the * actual value will default to the least power of two larger than selected value. -1 means no * limit. - * + * * @param evictionMaxEntries */ EvictionConfig maxEntries(Integer maxEntries); @@ -338,7 +335,7 @@ /** * Controls the default expiration settings for entries in the cache. - * + * * @author Vladimir Blagojevic * @since 5.0 */ @@ -348,7 +345,7 @@ * milliseconds. -1 means the entries never expire.
*
* Note that this can be overriden on a per-entry bassi by using the Cache API. - * + * * @param expirationLifespan */ ExpirationConfig lifespan(Long lifespan); @@ -359,7 +356,7 @@ * expire.
*
* Note that this can be overriden on a per-entry bassi by using the Cache API. - * + * * @param expirationMaxIdle */ ExpirationConfig maxIdle(Long maxIdle); @@ -367,7 +364,7 @@ /** * Defines clustered characteristics of the cache. - * + * * @author Vladimir Blagojevic * @since 5.0 */ @@ -383,46 +380,46 @@ /** * Configure async sub element. Once this method is invoked users cannot subsequently invoke * configureSync() as two are mutually exclusive - * + * * @return AsyncConfig element */ AsyncConfig configureAsync(); - + /** * Configure sync sub element. Once this method is invoked users cannot subsequently invoke * configureAsync() as two are mutually exclusive - * + * * @return AsyncConfig element */ SyncConfig configureSync(); /** * Configure stateRetrieval sub element - * + * * @return StateRetrievalConfig element */ StateRetrievalConfig configureStateRetrieval(); /** * Configure l1 sub element - * + * * @return L1Config element */ L1Config configureL1(); /** * * Configure hash sub element - * + * * @return HashConfig element */ HashConfig configureHash(); } - + /** * If configured all communications are synchronous, in that whenever a thread sends a message * sent over the wire, it blocks until it receives an acknowledgment from the recipient. * SyncConfig is mutually exclusive with the AsyncConfig. - * + * * @author Vladimir Blagojevic * @since 5.0 */ @@ -430,7 +427,7 @@ /** * This is the timeout used to wait for an acknowledgment when making a remote call, after * which the call is aborted and an exception is thrown. - * + * * @param syncReplTimeout * @param timeUnit */ @@ -441,7 +438,7 @@ * If configured all communications are asynchronous, in that whenever a thread sends a message * sent over the wire, it does not wait for an acknowledgment before returning. AsyncConfig is * mutually exclusive with the SyncConfig - * + * * @author Vladimir Blagojevic * @since 5.0 */ @@ -449,7 +446,7 @@ /** * If true, this forces all async communications to be queued up and sent out periodically as * a batch. - * + * * @param useReplQueue */ AsyncConfig useReplQueue(Boolean useReplQueue); @@ -457,7 +454,7 @@ /** * If useReplQueue is set to true, this attribute can be used to trigger flushing of the queue * when it reaches a specific threshold. - * + * * @param replQueueMaxElements */ AsyncConfig replQueueMaxElements(Integer replQueueMaxElements); @@ -466,7 +463,7 @@ * If useReplQueue is set to true, this attribute controls how often the asynchronous thread * used to flush the replication queue runs. This should be a positive integer which * represents thread wakeup time in milliseconds. - * + * * @param replQueueInterval */ AsyncConfig replQueueInterval(Long replQueueInterval); @@ -475,7 +472,7 @@ * If true, asynchronous marshalling is enabled which means that caller can return even * quicker, but it can suffer from reordering of operations. You can find more information here - * + * * @param useAsyncMarshalling */ AsyncConfig asyncMarshalling(Boolean asyncMarshalling); @@ -483,7 +480,7 @@ /** * This overrides the replication queue implementation class. Overriding the default allows * you to add behavior to the queue, typically by subclassing the default implementation. - * + * * @param classname */ AsyncConfig replQueueClass(String replQueueClass); @@ -492,7 +489,7 @@ /** * Configures how state is retrieved when a new cache joins the cluster. Used with invalidation * and replication clustered modes. - * + * * @author Vladimir Blagojevic * @since 5.0 */ @@ -500,7 +497,7 @@ /** * If true, this will cause the cache to ask neighboring caches for state when it starts up, * so the cache starts 'warm', although it will impact startup time. - * + * * @param fetchInMemoryState */ StateRetrievalConfig fetchInMemoryState(Boolean fetchInMemoryState); @@ -508,28 +505,28 @@ /** * If true, this will allow the cache to provide in-memory state to a neighbor, even if the * cache is not configured to fetch state from its neighbors (fetchInMemoryState is false) - * + * * @param alwaysProvideInMemoryState */ StateRetrievalConfig alwaysProvideInMemoryState(Boolean alwaysProvideInMemoryState); /** * Initial wait time when backing off before retrying state transfer retrieval - * + * * @param initialRetryWaitTime */ StateRetrievalConfig initialRetryWaitTime(Long initialRetryWaitTime); /** * Wait time increase factor over successive state retrieval backoffs - * + * * @param retryWaitTimeIncreaseFactor */ StateRetrievalConfig retryWaitTimeIncreaseFactor(Integer retryWaitTimeIncreaseFactor); /** * Number of state retrieval retries before giving up and aborting startup. - * + * * @param numRetries */ StateRetrievalConfig numRetries(Integer numRetries); @@ -537,7 +534,7 @@ /** * This is the maximum amount of time - in milliseconds - to wait for state from neighboring * caches, before throwing an exception and aborting startup. - * + * * @param stateRetrievalTimeout */ StateRetrievalConfig timeout(Long timeout); @@ -545,7 +542,7 @@ /** * This is the maximum amount of time to run a cluster-wide flush, to allow for syncing of * transaction logs. - * + * * @param logFlushTimeout */ StateRetrievalConfig logFlushTimeout(Long logFlushTimeout); @@ -553,7 +550,7 @@ /** * This is the maximum number of non-progressing transaction log writes after which a * brute-force flush approach is resorted to, to synchronize transaction logs. - * + * * @param maxNonProgressingLogWrites */ StateRetrievalConfig maxNonProgressingLogWrites(Integer maxNonProgressingLogWrites); @@ -562,21 +559,21 @@ /** * Configures the L1 cache behavior in 'distributed' caches instances. In any other cache modes, * this element is ignored. - * + * * @author Vladimir Blagojevic * @since 5.0 */ public interface L1Config { /** * Toggle to enable/disable L1 cache. - * + * * @param l1CacheEnabled */ L1Config enabled(Boolean enabled); /** * Maximum lifespan of an entry placed in the L1 cache. - * + * * @param l1Lifespan */ L1Config lifespan(Long lifespan); @@ -584,7 +581,7 @@ /** * If true, entries removed due to a rehash will be moved to L1 rather than being removed * altogether. - * + * * @param l1OnRehash */ L1Config onRehash(Boolean onRehash); @@ -592,14 +589,14 @@ /** * Allows fine-tuning of rehashing characteristics. Only used with 'distributed' cache mode, and otherwise ignored. - * + * * @author Vladimir Blagojevic * @since 5.0 */ public interface HashConfig { /** * Fully qualified name of class providing consistent hash algorithm - * + * * @param consistentHashClass */ HashConfig consistentHashClass(String consistentHashClass); @@ -608,14 +605,14 @@ * A fully qualified name of the class providing a hash function, used as a bit spreader and a * general hash code generator. Typically used in conjunction with the many default * {@link org.infinispan.distribution.ch.ConsistentHash} implementations shipped. - * + * * @param hashFunctionClass */ HashConfig hashFunctionClass(String hashFunctionClass); /** * Number of cluster-wide replicas for each cache entry. - * + * * @param numOwners */ HashConfig numOwners(Integer numOwners); @@ -624,7 +621,7 @@ /** * Rehashing timeout - * + * * @param rehashRpcTimeout */ HashConfig rehashRpcTimeout(Long rehashRpcTimeout); @@ -632,7 +629,7 @@ /** * If false, no rebalancing or rehashing will take place when a new node joins the cluster or * a node leaves - * + * * @param rehashEnabled */ HashConfig rehashEnabled(Boolean rehashEnabled); @@ -640,7 +637,7 @@ /** * Configures indexing of entries in the cache for searching. - * + * * @author Vladimir Blagojevic * @since 5.0 */ @@ -648,7 +645,7 @@ /** * If enabled, entries will be indexed when they are added to the cache. Indexes will be * updated as entries change or are removed. - * + * * @param enabled */ IndexingConfig enabled(Boolean enabled); @@ -656,7 +653,7 @@ /** * If true, only index changes made locally, ignoring remote changes. This is useful if * indexes are shared across a cluster to prevent redundant indexing of updates. - * + * * @param indexLocalOnly */ IndexingConfig indexLocalOnly(Boolean indexlocalOnly); @@ -686,7 +683,7 @@ @XmlElement private CustomInterceptorsType customInterceptors = new CustomInterceptorsType(); - + @XmlElement private DataContainerType dataContainer = new DataContainerType(); @@ -716,40 +713,40 @@ @XmlElement private QueryConfigurationBean indexing = new QueryConfigurationBean(); - + - public LockingConfig configureLocking(){ + public LockingConfig configureLocking() { - return locking; + return locking; } - + - public LoadersConfig configureLoaders(){ + public LoadersConfig configureLoaders() { return loaders; } - + - public TransactionConfig configureTransaction(){ + public TransactionConfig configureTransaction() { return transaction; } - + - public CustomInterceptorsConfig configureInterceptors(){ + public CustomInterceptorsConfig configureInterceptors() { return customInterceptors; } - + - public EvictionConfig configureEviction(){ + public EvictionConfig configureEviction() { return eviction; } - + - public ExpirationConfig configureExpiration(){ + public ExpirationConfig configureExpiration() { return expiration; } - + - public ClusteringConfig configureClustering(){ + public ClusteringConfig configureClustering() { return clustering; - } - + } + - public DeadlockDetectionConfig configureDeadlockDetection(){ + public DeadlockDetectionConfig configureDeadlockDetection() { return deadlockDetection; } - + - public IndexingConfig configureIndexing(){ + public IndexingConfig configureIndexing() { return indexing; } @@ -950,7 +947,7 @@ this.clustering.async.setReplQueueClass(classname); } - + @Deprecated public void setExposeJmxStatistics(boolean useMbean) { jmxStatistics.setEnabled(useMbean); @@ -962,7 +959,6 @@ * end of batches. * * @param enabled if true, batching is enabled. - * * @since 4.0 */ public void setInvocationBatchingEnabled(boolean enabled) { @@ -1018,7 +1014,7 @@ * aborted and an exception is thrown. * * @param syncReplTimeout - */ + */ @Deprecated public void setSyncReplTimeout(long syncReplTimeout) { this.clustering.sync.setReplTimeout(syncReplTimeout); @@ -1069,40 +1065,39 @@ public void setCacheModeString(String cacheMode) { setCacheMode(cacheMode); } - + @Deprecated public void setDataContainerClass(Class dataContainerClass) { this.dataContainer.setClass(dataContainerClass.getName()); } - + @Deprecated public void setDataContainerClass(String dataContainerClass) { this.dataContainer.setClass(dataContainerClass); } - + public String getDataContainerClass() { return dataContainer.dataContainerClass; } - + @Deprecated public void setDataContainer(DataContainer dataContainer) { this.dataContainer.setDataContainer(dataContainer); } - + public DataContainer getDataContainer() { return dataContainer.dataContainer; } @Deprecated public void setDataContainerProperties(TypedProperties properties) { - this.dataContainer.setProperties(properties); + this.dataContainer.setProperties(properties); } - + - public TypedProperties getDataContainerProperties() - { + public TypedProperties getDataContainerProperties() { - return dataContainer.properties; + return dataContainer.properties; } - + /** * Eviction thread wake up interval, in milliseconds. */ @@ -1479,6 +1474,7 @@ * A fully qualified name of the class providing a hash function, used as a bit spreader and a general hash code * generator. Typically used in conjunction with the many default {@link org.infinispan.distribution.ch.ConsistentHash} * implementations shipped. + * * @param hashFunctionClass */ @Deprecated @@ -1574,7 +1570,6 @@ /** * @return true if invocation batching is enabled. - * * @since 4.0 */ public boolean isInvocationBatchingEnabled() { @@ -1812,6 +1807,15 @@ } } + /** + * Converts this configuration instance to an XML representation containing the current settings. + * + * @return a string containing the formatted XML representation of this configuration instance. + */ + public String toXmlString() { + return InfinispanConfiguration.toXmlString(this); + } + public boolean isUsingCacheLoaders() { return getCacheLoaderManagerConfig() != null && !getCacheLoaderManagerConfig().getCacheLoaderConfigs().isEmpty(); } @@ -1841,7 +1845,7 @@ throw new ConfigurationException("Cache cannot use DISTRIBUTION mode and have fetchInMemoryState set to true. Perhaps you meant to enable rehashing?"); if (clustering.mode.isClustered() && (globalConfiguration != null - && (globalConfiguration.getTransportClass() == null || globalConfiguration.getTransportClass().length() == 0))) + && (globalConfiguration.getTransportClass() == null || globalConfiguration.getTransportClass().length() == 0))) throw new ConfigurationException("Cache cannot use a clustered mode (" + clustering.mode + ") mode and not define a transport!"); } @@ -1856,29 +1860,29 @@ */ @XmlAccessorType(XmlAccessType.PROPERTY) @ConfigurationDoc(name = "transaction") - public static class TransactionType extends AbstractNamedCacheConfigurationBean implements TransactionConfig{ + public static class TransactionType extends AbstractNamedCacheConfigurationBean implements TransactionConfig { /** * The serialVersionUID */ private static final long serialVersionUID = -3867090839830874603L; - @ConfigurationDocRef(bean = Configuration.class, targetElement = "setTransactionManagerLookupClass") + @ConfigurationDocRef(bean = Configuration.class, targetElement = "setTransactionManagerLookupClass") protected String transactionManagerLookupClass; @XmlTransient protected TransactionManagerLookup transactionManagerLookup; @Dynamic - @ConfigurationDocRef(bean = Configuration.class, targetElement = "setSyncCommitPhase") + @ConfigurationDocRef(bean = Configuration.class, targetElement = "setSyncCommitPhase") protected Boolean syncCommitPhase = false; @ConfigurationDocRef(bean = Configuration.class, targetElement = "setSyncRollbackPhase") - @Dynamic + @Dynamic protected Boolean syncRollbackPhase = false; @Dynamic - @ConfigurationDocRef(bean = Configuration.class, targetElement = "setUseEagerLocking") + @ConfigurationDocRef(bean = Configuration.class, targetElement = "setUseEagerLocking") protected Boolean useEagerLocking = false; @Dynamic @@ -1886,7 +1890,7 @@ protected Boolean eagerLockSingleNode = false; @Dynamic - @ConfigurationDocRef(bean = Configuration.class, targetElement = "setCacheStopTimeout") + @ConfigurationDocRef(bean = Configuration.class, targetElement = "setCacheStopTimeout") protected Integer cacheStopTimeout = 30000; public TransactionType(String transactionManagerLookupClass) { @@ -1901,59 +1905,75 @@ this.transactionManagerLookupClass = GenericTransactionManagerLookup.class.getName(); } + @XmlAttribute + public String getTransactionManagerLookupClass() { + return transactionManagerLookupClass; + } + public void setTransactionManagerLookupClass(String transactionManagerLookupClass) { testImmutability("transactionManagerLookupClass"); this.transactionManagerLookupClass = transactionManagerLookupClass; } - + - @Override public TransactionConfig transactionManagerLookupClass(Class transactionManagerLookupClass) { - testImmutability("transactionManagerLookupClass"); - this.transactionManagerLookupClass = transactionManagerLookupClass.getName(); + setTransactionManagerLookupClass(transactionManagerLookupClass == null ? null : transactionManagerLookupClass.getName()); return this; } + @XmlAttribute + public Boolean isSyncCommitPhase() { + return syncCommitPhase; + } + public void setSyncCommitPhase(Boolean syncCommitPhase) { testImmutability("syncCommitPhase"); this.syncCommitPhase = syncCommitPhase; } - + @Override public TransactionConfig syncCommitPhase(Boolean syncCommitPhase) { - testImmutability("syncCommitPhase"); - this.syncCommitPhase = syncCommitPhase; + setSyncCommitPhase(syncCommitPhase); return this; } + @XmlAttribute + public Boolean isSyncRollbackPhase() { + return syncRollbackPhase; + } + public void setSyncRollbackPhase(Boolean syncRollbackPhase) { testImmutability("syncRollbackPhase"); - this.syncRollbackPhase = syncRollbackPhase; + this.syncRollbackPhase = syncRollbackPhase; } - + @Override public TransactionConfig syncRollbackPhase(Boolean syncRollbackPhase) { - testImmutability("syncRollbackPhase"); - this.syncRollbackPhase = syncRollbackPhase; + setSyncRollbackPhase(syncRollbackPhase); return this; } + @XmlAttribute + public Boolean isUseEagerLocking() { + return useEagerLocking; + } + public void setUseEagerLocking(Boolean useEagerLocking) { testImmutability("useEagerLocking"); this.useEagerLocking = useEagerLocking; } - + @Override public TransactionConfig useEagerLocking(Boolean useEagerLocking) { - testImmutability("useEagerLocking"); - this.useEagerLocking = useEagerLocking; + setUseEagerLocking(useEagerLocking); return this; } - + + @Override public TransactionConfig usingTransactionManagerLookup(TransactionManagerLookup transactionManagerLookup) { testImmutability("transactionManagerLookup"); @@ -1961,33 +1981,42 @@ return this; } + @XmlAttribute + public Boolean isEagerLockSingleNode() { + return eagerLockSingleNode; + } + public TransactionConfig setEagerLockSingleNode(Boolean eagerLockSingleNode) { testImmutability("eagerLockSingleNode"); this.eagerLockSingleNode = eagerLockSingleNode; return this; } - + @Override public TransactionConfig eagerLockSingleNode(Boolean eagerLockSingleNode) { - testImmutability("eagerLockSingleNode"); - this.eagerLockSingleNode = eagerLockSingleNode; + setEagerLockSingleNode(eagerLockSingleNode); return this; } + @XmlAttribute + public Integer getCacheStopTimeout() { + return cacheStopTimeout; + } + public void setCacheStopTimeout(Integer cacheStopTimeout) { testImmutability("cacheStopTimeout"); - this.cacheStopTimeout = cacheStopTimeout; + this.cacheStopTimeout = cacheStopTimeout; } - + @Override public TransactionConfig cacheStopTimeout(Integer cacheStopTimeout) { - testImmutability("cacheStopTimeout"); - this.cacheStopTimeout = cacheStopTimeout; + setCacheStopTimeout(cacheStopTimeout); return this; } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -2037,7 +2066,7 @@ */ @XmlAccessorType(XmlAccessType.PROPERTY) @ConfigurationDoc(name = "locking") - public static class LockingType extends AbstractNamedCacheConfigurationBean implements LockingConfig{ + public static class LockingType extends AbstractNamedCacheConfigurationBean implements LockingConfig { /** * The serialVersionUID @@ -2051,86 +2080,106 @@ @ConfigurationDocRef(bean = Configuration.class, targetElement = "setIsolationLevel") protected IsolationLevel isolationLevel = IsolationLevel.READ_COMMITTED; - @ConfigurationDocRef(bean = Configuration.class, targetElement = "setWriteSkewCheck") + @ConfigurationDocRef(bean = Configuration.class, targetElement = "setWriteSkewCheck") protected Boolean writeSkewCheck = false; @ConfigurationDocRef(bean = Configuration.class, targetElement = "setUseLockStriping") protected Boolean useLockStriping = true; - @ConfigurationDocRef(bean = Configuration.class, targetElement = "setConcurrencyLevel") + @ConfigurationDocRef(bean = Configuration.class, targetElement = "setConcurrencyLevel") protected Integer concurrencyLevel = 32; - @Override - public LockingConfig lockAcquisitionTimeout(Long lockAcquisitionTimeout) { - testImmutability("lockAcquisitionTimeout"); - this.lockAcquisitionTimeout = lockAcquisitionTimeout; - return this; + public void accept(ConfigurationBeanVisitor v) { + v.visitLockingType(this); } - + + @XmlAttribute + public Long getLockAcquisitionTimeout() { + return lockAcquisitionTimeout; + } + public void setLockAcquisitionTimeout(Long lockAcquisitionTimeout) { testImmutability("lockAcquisitionTimeout"); this.lockAcquisitionTimeout = lockAcquisitionTimeout; } - + - public void accept(ConfigurationBeanVisitor v) { - v.visitLockingType(this); - } - @Override - public LockingConfig isolationLevel(IsolationLevel isolationLevel) { - testImmutability("isolationLevel"); - this.isolationLevel = isolationLevel; + public LockingConfig lockAcquisitionTimeout(Long lockAcquisitionTimeout) { + setLockAcquisitionTimeout(lockAcquisitionTimeout); return this; } - + + @XmlAttribute + public IsolationLevel getIsolationLevel() { + return isolationLevel; + } + public void setIsolationLevel(IsolationLevel isolationLevel) { testImmutability("isolationLevel"); this.isolationLevel = isolationLevel; } @Override - public LockingConfig writeSkewCheck(Boolean writeSkewCheck) { - testImmutability("writeSkewCheck"); - this.writeSkewCheck = writeSkewCheck; + public LockingConfig isolationLevel(IsolationLevel isolationLevel) { + setIsolationLevel(isolationLevel); return this; } - + + @XmlAttribute + public Boolean isWriteSkewCheck() { + return writeSkewCheck; + } + public void setWriteSkewCheck(Boolean writeSkewCheck) { testImmutability("writeSkewCheck"); - this.writeSkewCheck = writeSkewCheck; + this.writeSkewCheck = writeSkewCheck; } - @Override - public LockingConfig useLockStriping(Boolean useLockStriping) { - testImmutability("useLockStriping"); - this.useLockStriping = useLockStriping; + public LockingConfig writeSkewCheck(Boolean writeSkewCheck) { + setWriteSkewCheck(writeSkewCheck); return this; } - + + @XmlAttribute + public Boolean isUseLockStriping() { + return useLockStriping; + } + public void setUseLockStriping(Boolean useLockStriping) { testImmutability("useLockStriping"); this.useLockStriping = useLockStriping; } @Override - public LockingConfig concurrencyLevel(Integer concurrencyLevel) { - testImmutability("concurrencyLevel"); - this.concurrencyLevel = concurrencyLevel; + public LockingConfig useLockStriping(Boolean useLockStriping) { + setUseLockStriping(useLockStriping); return this; } - + + @XmlAttribute + public Integer getConcurrencyLevel() { + return concurrencyLevel; + } + public void setConcurrencyLevel(Integer concurrencyLevel) { testImmutability("concurrencyLevel"); - this.concurrencyLevel = concurrencyLevel; + this.concurrencyLevel = concurrencyLevel; } @Override + public LockingConfig concurrencyLevel(Integer concurrencyLevel) { + setConcurrencyLevel(concurrencyLevel); + return this; + } + + + @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof LockingType)) return false; @@ -2179,10 +2228,10 @@ @XmlAttribute(name = "mode") protected String stringMode; - + @XmlTransient protected boolean configuredAsync = false; - + @XmlTransient protected boolean configuredSync = false; @@ -2212,7 +2261,7 @@ public ClusteringType() { this.mode = DIST_SYNC; } - + @Override public AsyncConfig configureAsync() { if (configuredSync) @@ -2228,12 +2277,12 @@ configuredSync = true; return sync; } - + @Override public StateRetrievalConfig configureStateRetrieval() { return stateRetrieval; } - + @Override public L1Config configureL1() { return l1; @@ -2248,8 +2297,8 @@ testImmutability("mode"); this.mode = mode; } - - + + @Override public ClusteringConfig mode(CacheMode mode) { testImmutability("mode"); @@ -2347,8 +2396,7 @@ ct.setMode(DIST_ASYNC); } else if (mode.startsWith("l")) { ct.setMode(LOCAL); - } else - { + } else { throw new ConfigurationException("Invalid clustering mode " + ct.stringMode); } } @@ -2440,72 +2488,92 @@ this(true); } - @Override - public AsyncConfig useReplQueue(Boolean useReplQueue) { + @XmlAttribute + public Boolean isUseReplQueue() { + return useReplQueue; + } + + public void setUseReplQueue(Boolean useReplQueue) { testImmutability("useReplQueue"); this.useReplQueue = useReplQueue; - return this; } @Override - public AsyncConfig replQueueMaxElements(Integer replQueueMaxElements) { - testImmutability("replQueueMaxElements"); - this.replQueueMaxElements = replQueueMaxElements; + public AsyncConfig useReplQueue(Boolean useReplQueue) { + setUseReplQueue(useReplQueue); return this; } - @Override - public AsyncConfig replQueueInterval(Long replQueueInterval) { - testImmutability("replQueueInterval"); - this.replQueueInterval = replQueueInterval; - return this; + + @XmlAttribute + public Integer getReplQueueMaxElements() { + return replQueueMaxElements; } - @Override - public AsyncConfig asyncMarshalling(Boolean asyncMarshalling) { - testImmutability("asyncMarshalling"); - this.asyncMarshalling = asyncMarshalling; - return this; + public void setReplQueueMaxElements(Integer replQueueMaxElements) { + testImmutability("replQueueMaxElements"); + this.replQueueMaxElements = replQueueMaxElements; } @Override - public AsyncConfig replQueueClass(String replQueueClass) { - testImmutability("replQueueClass"); - this.replQueueClass = replQueueClass; + public AsyncConfig replQueueMaxElements(Integer replQueueMaxElements) { + setReplQueueMaxElements(replQueueMaxElements); return this; } - + - @XmlAttribute - public void setUseReplQueue(Boolean useReplQueue) { - testImmutability("useReplQueue"); - this.useReplQueue = useReplQueue; - } @XmlAttribute - public void setReplQueueMaxElements(Integer replQueueMaxElements) { - testImmutability("replQueueMaxElements"); - this.replQueueMaxElements = replQueueMaxElements; + public Long getReplQueueInterval() { + return replQueueInterval; } - @XmlAttribute public void setReplQueueInterval(Long replQueueInterval) { testImmutability("replQueueInterval"); this.replQueueInterval = replQueueInterval; } + @Override + public AsyncConfig replQueueInterval(Long replQueueInterval) { + setReplQueueInterval(replQueueInterval); + return this; + } + + @XmlAttribute + public Boolean isAsyncMarshalling() { + return asyncMarshalling; + } + public void setAsyncMarshalling(Boolean asyncMarshalling) { testImmutability("asyncMarshalling"); this.asyncMarshalling = asyncMarshalling; } + @Override + public AsyncConfig asyncMarshalling(Boolean asyncMarshalling) { + setAsyncMarshalling(asyncMarshalling); + return this; + } + + @XmlAttribute + public String getReplQueueClass() { + return replQueueClass; + } + public void setReplQueueClass(String replQueueClass) { testImmutability("replQueueClass"); this.replQueueClass = replQueueClass; } @Override + public AsyncConfig replQueueClass(String replQueueClass) { + setReplQueueClass(replQueueClass); + return this; + } + + + @Override public void willUnmarshall(Object parent) { ClusteringType clustering = (ClusteringType) parent; if (clustering.sync.unmarshalledFromXml) @@ -2527,43 +2595,51 @@ * The serialVersionUID */ private static final long serialVersionUID = 5757161438110848530L; - + @ConfigurationDocRef(bean = Configuration.class, targetElement = "setExpirationLifespan") protected Long lifespan = -1L; @ConfigurationDocRef(bean = Configuration.class, targetElement = "setExpirationMaxIdle") protected Long maxIdle = -1L; - @Override - public ExpirationConfig lifespan(Long lifespan) { - testImmutability("lifespan"); - this.lifespan = lifespan; - return this; + public void accept(ConfigurationBeanVisitor v) { + v.visitExpirationType(this); } - + @XmlAttribute + public Long getLifespan() { + return lifespan; + } + public void setLifespan(Long lifespan) { testImmutability("lifespan"); - this.lifespan = lifespan; + this.lifespan = lifespan; } - public void accept(ConfigurationBeanVisitor v) { - v.visitExpirationType(this); + @Override + public ExpirationConfig lifespan(Long lifespan) { + setLifespan(lifespan); + return this; } + @XmlAttribute + public Long getMaxIdle() { + return maxIdle; + } + public void setMaxIdle(Long maxIdle) { testImmutability("maxIdle"); - this.maxIdle = maxIdle; + this.maxIdle = maxIdle; } - + @Override public ExpirationConfig maxIdle(Long maxIdle) { - testImmutability("maxIdle"); - this.maxIdle = maxIdle; + setMaxIdle(maxIdle); return this; } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -2599,7 +2675,7 @@ */ private static final long serialVersionUID = -1248563712058858791L; - @ConfigurationDocRef(bean = Configuration.class, targetElement = "setEvictionWakeUpInterval") + @ConfigurationDocRef(bean = Configuration.class, targetElement = "setEvictionWakeUpInterval") protected Long wakeUpInterval = 5000L; @ConfigurationDocRef(bean = Configuration.class, targetElement = "setEvictionStrategy") @@ -2611,63 +2687,80 @@ @ConfigurationDocRef(bean = Configuration.class, targetElement = "setEvictionThreadPolicy") protected EvictionThreadPolicy threadPolicy = EvictionThreadPolicy.DEFAULT; - @Override - public EvictionConfig wakeUpInterval(Long wakeUpInterval) { - testImmutability("wakeUpInterval"); - this.wakeUpInterval = wakeUpInterval; - return this; + public void accept(ConfigurationBeanVisitor v) { + v.visitEvictionType(this); } - + + @XmlAttribute + public Long getWakeUpInterval() { + return wakeUpInterval; + } + public void setWakeUpInterval(Long wakeUpInterval) { testImmutability("wakeUpInterval"); this.wakeUpInterval = wakeUpInterval; } - public void accept(ConfigurationBeanVisitor v) { - v.visitEvictionType(this); - } - @Override - public EvictionConfig strategy(EvictionStrategy strategy) { - testImmutability("strategy"); - this.strategy = strategy; + public EvictionConfig wakeUpInterval(Long wakeUpInterval) { + setWakeUpInterval(wakeUpInterval); return this; } - + + @XmlAttribute + public EvictionStrategy getStrategy() { + return strategy; + } + public void setStrategy(EvictionStrategy strategy) { testImmutability("strategy"); this.strategy = strategy; } @Override - public EvictionConfig threadPolicy(EvictionThreadPolicy threadPolicy) { - testImmutability("threadPolicy"); - this.threadPolicy = threadPolicy; + public EvictionConfig strategy(EvictionStrategy strategy) { + setStrategy(strategy); return this; } - + + @XmlAttribute + public EvictionThreadPolicy getThreadPolicy() { + return threadPolicy; + } + public void setThreadPolicy(EvictionThreadPolicy threadPolicy) { testImmutability("threadPolicy"); this.threadPolicy = threadPolicy; } @Override - public EvictionConfig maxEntries(Integer maxEntries) { - testImmutability("maxEntries"); - this.maxEntries = maxEntries; + public EvictionConfig threadPolicy(EvictionThreadPolicy threadPolicy) { + setThreadPolicy(threadPolicy); return this; } - + + @XmlAttribute + public Integer getMaxEntries() { + return maxEntries; + } + public void setMaxEntries(Integer maxEntries) { testImmutability("maxEntries"); this.maxEntries = maxEntries; } @Override + public EvictionConfig maxEntries(Integer maxEntries) { + setMaxEntries(maxEntries); + return this; + } + + + @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof EvictionType)) return false; @@ -2692,7 +2785,7 @@ return result; } } - + /** * This element controls the data container for the cache. * @@ -2709,31 +2802,45 @@ @ConfigurationDocRef(bean = Configuration.class, targetElement = "setDataContainerClass") protected String dataContainerClass = DefaultDataContainer.class.getName(); - + @XmlElement(name = "properties") protected TypedProperties properties = EMPTY_PROPERTIES; - + protected DataContainer dataContainer; - @XmlAttribute - public void setClass(String dataContainerClass) { - testImmutability("dataContainerClass"); - this.dataContainerClass = dataContainerClass; + public void accept(ConfigurationBeanVisitor v) { + v.visitDataContainerType(this); } - + - public void setDataContainer(DataContainer dataContainer) { - this.dataContainer = dataContainer; + @XmlAttribute(name = "class") + public String getDataContainerClass() { + return dataContainerClass; } - + + public void setDataContainerClass(String dataContainerClass) { + testImmutability("dataContainerClass"); + this.dataContainerClass = dataContainerClass; + } + + @XmlTransient public void setProperties(TypedProperties properties) { - testImmutability("properties"); - this.properties = properties; + testImmutability("properties"); + this.properties = properties; } - public void accept(ConfigurationBeanVisitor v) { - v.visitDataContainerType(this); + /** + * @deprecated Do not use this setter as it's corresponding getter clashes with {@link #getClass()}. + * Use {@link #setDataContainerClass(String)} instead. + */ + @Deprecated + public void setClass(String dataContainerClass) { + setDataContainerClass(dataContainerClass); } + public void setDataContainer(DataContainer dataContainer) { + this.dataContainer = dataContainer; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -2741,16 +2848,18 @@ DataContainerType that = (DataContainerType) o; - if (dataContainerClass != null ? !dataContainerClass.equals(that.dataContainerClass) : that.dataContainerClass != null) return false; - if (dataContainer != null ? !dataContainer.equals(that.dataContainer) : that.dataContainer != null) return false; + if (dataContainerClass != null ? !dataContainerClass.equals(that.dataContainerClass) : that.dataContainerClass != null) + return false; + if (dataContainer != null ? !dataContainer.equals(that.dataContainer) : that.dataContainer != null) + return false; - + return true; } @Override public int hashCode() { int result = dataContainerClass != null ? dataContainerClass.hashCode() : 0; - result = 31 * result + ( dataContainer != null ? dataContainer.hashCode() : 0 ); + result = 31 * result + (dataContainer != null ? dataContainer.hashCode() : 0); return result; } } @@ -2763,7 +2872,7 @@ */ @XmlAccessorType(XmlAccessType.PROPERTY) @ConfigurationDoc(name = "stateRetrieval") - public static class StateRetrievalType extends AbstractNamedCacheConfigurationBean implements StateRetrievalConfig{ + public static class StateRetrievalType extends AbstractNamedCacheConfigurationBean implements StateRetrievalConfig { /** * The serialVersionUID @@ -2797,114 +2906,145 @@ @ConfigurationDocRef(bean = Configuration.class, targetElement = "setStateRetrievalMaxNonProgressingLogWrites") protected Integer maxNonProgressingLogWrites = 100; + public void accept(ConfigurationBeanVisitor v) { + v.visitStateRetrievalType(this); + } + @XmlAttribute + public Boolean isFetchInMemoryState() { + return fetchInMemoryState; + } + public void setFetchInMemoryState(Boolean fetchInMemoryState) { testImmutability("fetchInMemoryState"); this.fetchInMemoryState = fetchInMemoryState; } + @Override + public StateRetrievalConfig fetchInMemoryState(Boolean fetchInMemoryState) { + setFetchInMemoryState(fetchInMemoryState); + return this; + } + + @XmlAttribute + public Boolean isAlwaysProvideInMemoryState() { + return alwaysProvideInMemoryState; + } + public void setAlwaysProvideInMemoryState(Boolean alwaysProvideInMemoryState) { testImmutability("alwaysProvideInMemoryState"); this.alwaysProvideInMemoryState = alwaysProvideInMemoryState; } + @Override + public StateRetrievalConfig alwaysProvideInMemoryState(Boolean alwaysProvideInMemoryState) { + setAlwaysProvideInMemoryState(alwaysProvideInMemoryState); + return this; + } + + @XmlAttribute + public Long getInitialRetryWaitTime() { + return initialRetryWaitTime; + } + public void setInitialRetryWaitTime(Long initialRetryWaitTime) { testImmutability("initialWaitTime"); this.initialRetryWaitTime = initialRetryWaitTime; } + @Override + public StateRetrievalConfig initialRetryWaitTime(Long initialRetryWaitTime) { + setInitialRetryWaitTime(initialRetryWaitTime); + return this; + } + + @XmlAttribute + public Integer getRetryWaitTimeIncreaseFactor() { + return retryWaitTimeIncreaseFactor; + } + public void setRetryWaitTimeIncreaseFactor(Integer retryWaitTimeIncreaseFactor) { testImmutability("retryWaitTimeIncreaseFactor"); this.retryWaitTimeIncreaseFactor = retryWaitTimeIncreaseFactor; } + @Override + public StateRetrievalConfig retryWaitTimeIncreaseFactor(Integer retryWaitTimeIncreaseFactor) { + setRetryWaitTimeIncreaseFactor(retryWaitTimeIncreaseFactor); + return this; + } + + @XmlAttribute + public Integer getNumRetries() { + return numRetries; + } + public void setNumRetries(Integer numRetries) { testImmutability("numRetries"); this.numRetries = numRetries; } - @XmlAttribute - public void setTimeout(Long timeout) { - testImmutability("timeout"); - this.timeout = timeout; + @Override + public StateRetrievalConfig numRetries(Integer numRetries) { + setNumRetries(numRetries); + return this; } - @XmlAttribute - public void setLogFlushTimeout(Long logFlushTimeout) { - testImmutability("logFlushTimeout"); - this.logFlushTimeout = logFlushTimeout; - } @XmlAttribute - public void setMaxNonProgressingLogWrites(Integer maxNonProgressingLogWrites) { - testImmutability("maxNonProgressingLogWrites"); - this.maxNonProgressingLogWrites = maxNonProgressingLogWrites; + public Long getTimeout() { + return timeout; } - @Override - public StateRetrievalConfig fetchInMemoryState(Boolean fetchInMemoryState) { - testImmutability("fetchInMemoryState"); - this.fetchInMemoryState = fetchInMemoryState; - return this; + public void setTimeout(Long timeout) { + testImmutability("timeout"); + this.timeout = timeout; } @Override - public StateRetrievalConfig alwaysProvideInMemoryState(Boolean alwaysProvideInMemoryState) { - testImmutability("alwaysProvideInMemoryState"); - this.alwaysProvideInMemoryState = alwaysProvideInMemoryState; + public StateRetrievalConfig timeout(Long timeout) { + setTimeout(timeout); return this; } - @Override - public StateRetrievalConfig initialRetryWaitTime(Long initialRetryWaitTime) { - testImmutability("initialWaitTime"); - this.initialRetryWaitTime = initialRetryWaitTime; - return this; + + @XmlAttribute + public Long getLogFlushTimeout() { + return logFlushTimeout; } - @Override - public StateRetrievalConfig retryWaitTimeIncreaseFactor(Integer retryWaitTimeIncreaseFactor) { - testImmutability("retryWaitTimeIncreaseFactor"); - this.retryWaitTimeIncreaseFactor = retryWaitTimeIncreaseFactor; - return this; + public void setLogFlushTimeout(Long logFlushTimeout) { + testImmutability("logFlushTimeout"); + this.logFlushTimeout = logFlushTimeout; } @Override - public StateRetrievalConfig numRetries(Integer numRetries) { - testImmutability("numRetries"); - this.numRetries = numRetries; + public StateRetrievalConfig logFlushTimeout(Long logFlushTimeout) { + setLogFlushTimeout(logFlushTimeout); return this; } - @Override - public StateRetrievalConfig timeout(Long timeout) { - testImmutability("timeout"); - this.timeout = timeout; - return this; + + @XmlAttribute + public Integer getMaxNonProgressingLogWrites() { + return maxNonProgressingLogWrites; } - @Override - public StateRetrievalConfig logFlushTimeout(Long logFlushTimeout) { - testImmutability("logFlushTimeout"); - this.logFlushTimeout = logFlushTimeout; - return this; + public void setMaxNonProgressingLogWrites(Integer maxNonProgressingLogWrites) { + testImmutability("maxNonProgressingLogWrites"); + this.maxNonProgressingLogWrites = maxNonProgressingLogWrites; } @Override public StateRetrievalConfig maxNonProgressingLogWrites(Integer maxNonProgressingLogWrites) { - testImmutability("maxNonProgressingLogWrites"); - this.maxNonProgressingLogWrites = maxNonProgressingLogWrites; + setMaxNonProgressingLogWrites(maxNonProgressingLogWrites); return this; } - public void accept(ConfigurationBeanVisitor v) { - v.visitStateRetrievalType(this); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -2958,22 +3098,25 @@ @XmlTransient private boolean unmarshalledFromXml = false; + public void accept(ConfigurationBeanVisitor v) { + v.visitSyncType(this); + } + @XmlAttribute + public Long getReplTimeout() { + return replTimeout; + } + public void setReplTimeout(Long replTimeout) { testImmutability("replTimeout"); this.replTimeout = replTimeout; } - + public SyncConfig replTimeout(Long replTimeout) { - testImmutability("replTimeout"); - this.replTimeout = replTimeout; + setReplTimeout(replTimeout); return this; } - public void accept(ConfigurationBeanVisitor v) { - v.visitSyncType(this); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -3008,7 +3151,7 @@ */ @XmlAccessorType(XmlAccessType.PROPERTY) @ConfigurationDoc(name = "hash") - public static class HashType extends AbstractNamedCacheConfigurationBean implements HashConfig{ + public static class HashType extends AbstractNamedCacheConfigurationBean implements HashConfig { /** * The serialVersionUID @@ -3033,85 +3176,108 @@ @ConfigurationDocRef(bean = Configuration.class, targetElement = "setRehashEnabled") protected Boolean rehashEnabled = true; + public void accept(ConfigurationBeanVisitor v) { + v.visitHashType(this); + } + @XmlAttribute(name = "class") + public String getConsistentHashClass() { + return consistentHashClass; + } + public void setConsistentHashClass(String consistentHashClass) { testImmutability("consistentHashClass"); - this.consistentHashClass = consistentHashClass; + this.consistentHashClass = consistentHashClass; } + @Override + public HashConfig consistentHashClass(String consistentHashClass) { + setConsistentHashClass(consistentHashClass); + return this; + } + + @XmlAttribute + public String getHashFunctionClass() { + return hashFunctionClass; + } + public void setHashFunctionClass(String hashFunctionClass) { testImmutability("hashFunctionClass"); this.hashFunctionClass = hashFunctionClass; } - + @Override - public HashConfig consistentHashClass(String consistentHashClass) { - testImmutability("consistentHashClass"); - this.consistentHashClass = consistentHashClass; - return this; - } - - @Override public HashConfig hashFunctionClass(String hashFunctionClass) { - testImmutability("hashFunctionClass"); - this.hashFunctionClass = hashFunctionClass; + setHashFunctionClass(hashFunctionClass); return this; } - public void accept(ConfigurationBeanVisitor v) { - v.visitHashType(this); - } @XmlAttribute + public Integer getNumOwners() { + return numOwners; + } + public void setNumOwners(Integer numOwners) { testImmutability("numOwners"); this.numOwners = numOwners; } + @Override + public HashConfig numOwners(Integer numOwners) { + setNumOwners(numOwners); + return this; + } + + @XmlAttribute + public Long getRehashWait() { + return rehashWait; + } + public void setRehashWait(Long rehashWaitTime) { testImmutability("rehashWait"); this.rehashWait = rehashWaitTime; } + @Override + public HashConfig rehashWait(Long rehashWaitTime) { + setRehashWait(rehashWaitTime); + return this; + } + + @XmlAttribute + public Long getRehashRpcTimeout() { + return rehashRpcTimeout; + } + public void setRehashRpcTimeout(Long rehashRpcTimeout) { testImmutability("rehashRpcTimeout"); this.rehashRpcTimeout = rehashRpcTimeout; } - @XmlAttribute - public void setRehashEnabled(Boolean rehashEnabled) { - testImmutability("rehashEnabled"); - this.rehashEnabled = rehashEnabled; - } - @Override - public HashConfig numOwners(Integer numOwners) { - testImmutability("numOwners"); - this.numOwners = numOwners; + public HashConfig rehashRpcTimeout(Long rehashRpcTimeout) { + setRehashRpcTimeout(rehashRpcTimeout); return this; } - @Override - public HashConfig rehashWait(Long rehashWaitTime) { - testImmutability("rehashWait"); - this.rehashWait = rehashWaitTime; - return this; + + @XmlAttribute + public Boolean isRehashEnabled() { + return rehashEnabled; } - @Override - public HashConfig rehashRpcTimeout(Long rehashRpcTimeout) { - testImmutability("rehashRpcTimeout"); - this.rehashRpcTimeout = rehashRpcTimeout; - return this; + public void setRehashEnabled(Boolean rehashEnabled) { + testImmutability("rehashEnabled"); + this.rehashEnabled = rehashEnabled; } @Override public HashConfig rehashEnabled(Boolean rehashEnabled) { - testImmutability("rehashEnabled"); - this.rehashEnabled = rehashEnabled; + setRehashEnabled(rehashEnabled); return this; } @@ -3171,49 +3337,61 @@ @ConfigurationDocRef(bean = Configuration.class, targetElement = "setL1OnRehash") protected Boolean onRehash = true; + public void accept(ConfigurationBeanVisitor v) { + v.visitL1Type(this); + } + + @XmlAttribute + public Boolean isEnabled() { + return enabled; + } + public L1Config setEnabled(Boolean enabled) { testImmutability("enabled"); this.enabled = enabled; return this; } - + @Override public L1Config enabled(Boolean enabled) { - testImmutability("enabled"); - this.enabled = enabled; + setEnabled(enabled); return this; } - public void accept(ConfigurationBeanVisitor v) { - v.visitL1Type(this); - } @XmlAttribute + public Long getLifespan() { + return lifespan; + } + public L1Config setLifespan(Long lifespan) { testImmutability("lifespan"); this.lifespan = lifespan; return this; } + @Override + public L1Config lifespan(Long lifespan) { + setLifespan(lifespan); + return this; + } + + @XmlAttribute + public Boolean isOnRehash() { + return onRehash; + } + public L1Config setOnRehash(Boolean onRehash) { testImmutability("onRehash"); this.onRehash = onRehash; return this; } - + @Override - public L1Config lifespan(Long lifespan) { - testImmutability("lifespan"); - this.lifespan = lifespan; - return this; - } - - @Override public L1Config onRehash(Boolean onRehash) { - testImmutability("onRehash"); - this.onRehash = onRehash; + setOnRehash(onRehash); return this; } @@ -3262,20 +3440,24 @@ this.fieldName = fieldName; } + public void accept(ConfigurationBeanVisitor v) { + v.visitBooleanAttributeType(this); + } + public String getFieldName() { return fieldName; } @XmlAttribute + public Boolean isEnabled() { + return enabled; + } + public void setEnabled(Boolean enabled) { testImmutability("enabled"); this.enabled = enabled; } - public void accept(ConfigurationBeanVisitor v) { - v.visitBooleanAttributeType(this); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -3368,33 +3550,41 @@ @ConfigurationDocRef(bean = Configuration.class, targetElement = "setDeadlockDetectionSpinDuration") protected Long spinDuration = 100L; + public void accept(ConfigurationBeanVisitor v) { + v.visitDeadlockDetectionType(this); + } + + @XmlAttribute + public Boolean isEnabled() { + return enabled; + } + public void setEnabled(Boolean enabled) { testImmutability("enabled"); this.enabled = enabled; } - + @Override public DeadlockDetectionConfig enabled(Boolean enabled) { - testImmutability("enabled"); - this.enabled = enabled; + setEnabled(enabled); return this; } - public void accept(ConfigurationBeanVisitor v) { - v.visitDeadlockDetectionType(this); - } @XmlAttribute + public Long getSpinDuration() { + return spinDuration; + } + public void setSpinDuration(Long spinDuration) { testImmutability("spinDuration"); this.spinDuration = spinDuration; } - + @Override public DeadlockDetectionConfig spinDuration(Long spinDuration) { - testImmutability("spinDuration"); - this.spinDuration = spinDuration; + setSpinDuration(spinDuration); return this; } @@ -3439,16 +3629,21 @@ @ConfigurationDocRef(bean = Configuration.class, targetElement = "setUnsafeUnreliableReturnValues") protected Boolean unreliableReturnValues = false; + public void accept(ConfigurationBeanVisitor v) { + v.visitUnsafeType(this); + } + + @XmlAttribute + public Boolean isUnreliableReturnValues() { + return unreliableReturnValues; + } + public void setUnreliableReturnValues(Boolean unreliableReturnValues) { testImmutability("unreliableReturnValues"); this.unreliableReturnValues = unreliableReturnValues; } - public void accept(ConfigurationBeanVisitor v) { - v.visitUnsafeType(this); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -3562,42 +3757,41 @@ @ConfigurationDocRef(bean = Configuration.class, targetElement = "setIndexLocalOnly") protected Boolean indexLocalOnly = false; + public void accept(ConfigurationBeanVisitor v) { + v.visitQueryConfigurationBean(this); + } + + @XmlAttribute public Boolean isEnabled() { return enabled; } - @XmlAttribute public void setEnabled(Boolean enabled) { testImmutability("enabled"); this.enabled = enabled; } public IndexingConfig enabled(Boolean enabled) { - testImmutability("enabled"); - this.enabled = enabled; + setEnabled(enabled); return this; } - + + + @XmlAttribute public Boolean isIndexLocalOnly() { return indexLocalOnly; } - @XmlAttribute public void setIndexLocalOnly(Boolean indexLocalOnly) { testImmutability("indexLocalOnly"); this.indexLocalOnly = indexLocalOnly; } - + public IndexingConfig indexLocalOnly(Boolean indexLocalOnly) { - testImmutability("indexLocalOnly"); - this.indexLocalOnly = indexLocalOnly; + setIndexLocalOnly(indexLocalOnly); return this; } - public void accept(ConfigurationBeanVisitor v) { - v.visitQueryConfigurationBean(this); - } - @Override public boolean equals(Object o) { if (this == o) Index: core/src/main/java/org/infinispan/config/GlobalConfiguration.java =================================================================== --- core/src/main/java/org/infinispan/config/GlobalConfiguration.java (revision a120cd344fc2f3938ef2a8b6035a405df171feb0) +++ core/src/main/java/org/infinispan/config/GlobalConfiguration.java (revision ) @@ -22,12 +22,7 @@ import org.infinispan.util.TypedProperties; import org.infinispan.util.Util; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlTransient; -import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.*; import java.util.ArrayList; import java.util.List; @@ -36,7 +31,7 @@ /** * Configuration component that encapsulates the global configuration. *

- * + * * A default instance of this bean takes default values for each attribute. Please see the individual setters for * details of what these defaults are. *

@@ -46,27 +41,28 @@ * @author Mircea.Markus@jboss.com * @author Galder Zamarreņo * @since 4.0 - * + * * @see Configuration reference - * + * */ @SurvivesRestarts @Scope(Scopes.GLOBAL) @XmlAccessorType(XmlAccessType.FIELD) @XmlType(propOrder = {}) +@XmlRootElement @ConfigurationDoc(name="global",desc="Defines global settings shared among all cache instances created by a single CacheManager.") public class GlobalConfiguration extends AbstractConfigurationBean { - + /** * Configures executor factory. - * + * * @author Vladimir Blagojevic * @since 5.0 */ public interface ExecutorFactoryConfig { /** * Specify factory class for executor - * + * * @param factory * clazz * @return this ExecutorFactoryConfig @@ -75,7 +71,7 @@ /** * Add key/value property pair to this executor factory configuration - * + * * @param key * property key * @param value @@ -86,7 +82,7 @@ /** * Set key/value properties to this executor factory configuration - * + * * @param props * Prpperties * @return this ExecutorFactoryConfig @@ -96,21 +92,21 @@ /** * Configures whether global statistics are gathered and reported via JMX for all caches under this cache manager. - * + * * @author Vladimir Blagojevic * @since 5.0 */ public interface GlobalJmxStatisticsConfig { /** * Toggle to enable/disable global statistics being exported via JMX - * + * * @param exposeGlobalJmxStatistics */ GlobalJmxStatisticsConfig enabled(Boolean enabled); /** * Sets properties which are then passed to the MBean Server Lookup implementation specified. - * + * * @param properties * properties to pass to the MBean Server Lookup */ @@ -119,14 +115,14 @@ /** * If JMX statistics are enabled then all 'published' JMX objects will appear under this name. * This is optional, if not specified an object name will be created for you by default. - * + * * @param jmxObjectName */ GlobalJmxStatisticsConfig jmxDomain(String jmxDomain); /** * Instance of class that will attempt to locate a JMX MBean server to bind to - * + * * @param mBeanServerLookupClass * MBean Server Lookup class implementation */ @@ -136,7 +132,7 @@ * If true, multiple cache manager instances could be configured under the same configured JMX * domain. Each cache manager will in practice use a different JMX domain that has been * calculated based on the configured one by adding an incrementing index to it. - * + * * @param allowDuplicateDomains */ GlobalJmxStatisticsConfig allowDuplicateDomains(Boolean allowDuplicateDomains); @@ -146,14 +142,14 @@ * offers the possibility for clients to provide a user-defined name to the cache manager * which later can be used to identify the cache manager within a JMX based management tool * amongst other cache managers that might be running under the same JVM. - * + * * @param cacheManagerName */ GlobalJmxStatisticsConfig cacheManagerName(String cacheManagerName); /** * Sets the instance of the {@link MBeanServerLookup} class to be used to bound JMX MBeans to. - * + * * @param mBeanServerLookupInstance * An instance of {@link MBeanServerLookup} */ @@ -162,14 +158,14 @@ /** * Configures the transport used for network communications across the cluster. - * + * * @author Vladimir Blagojevic * @since 5.0 */ public interface TransportConfig { /** * Defines the name of the cluster. Nodes only connect to clusters sharing the same name. - * + * * @param clusterName */ TransportConfig clusterName(String clusterName); @@ -197,7 +193,7 @@ /** * Class that represents a network transport. Must implement * org.infinispan.remoting.transport.Transport - * + * * @param transportClass */ TransportConfig transportClass(Class transportClass); @@ -206,15 +202,15 @@ * Name of the current node. This is a friendly name to make logs, etc. make more sense. * Defaults to a combination of host name and a random number (to differentiate multiple nodes * on the same host) - * + * * @param nodeName */ TransportConfig nodeName(String nodeName); - + /** * Sets transport properties - * + * * @param properties * @return this TransportConfig */ @@ -225,7 +221,7 @@ * with a NamedCacheNotFoundException. Otherwise, operations will succeed but it will be * logged on the caller that the RPC did not succeed on certain nodes due to the named cache * not being available. - * + * * @param strictPeerToPeer * flag controlling this behavior */ @@ -236,7 +232,7 @@ /** * Configures serialization and marshalling settings. - * + * * @author Vladimir Blagojevic * @since 5.0 */ @@ -244,7 +240,7 @@ /** * Fully qualified name of the marshaller to use. It must implement * org.infinispan.marshall.StreamingMarshaller - * + * * @param marshallerClass */ SerializationConfig marshallerClass(Class c); @@ -254,14 +250,14 @@ * version cache instance in your cluster to ensure compatibility of communications. However, * setting this too low will mean you lose out on the benefit of improvements in newer * versions of the marshaller. - * + * * @param marshallVersion */ SerializationConfig version(String s); /** * Returns externalizers sub element - * + * * @return ExternalizersConfig element */ ExternalizersConfig configureExternalizers(); @@ -269,22 +265,22 @@ /** * ExternalizersConfig. - * + * * @author Vladimir Blagojevic * @since 5.0 */ public interface ExternalizersConfig { - + /** - * Adds externalizer config to the list of configured externalizers - * @param ec + * Adds externalizer config to the list of configured externalizers + * @param ec * @return this ExternalizersConfig */ ExternalizersConfig addExtrenalizer(ExternalizerConfig ec); /** - * Adds externalizer config as a class and id to the list of configured externalizers - * + * Adds externalizer config as a class and id to the list of configured externalizers + * * @param * @param clazz externalizer class * @param id id of externlizer @@ -333,32 +329,32 @@ @XmlTransient GlobalComponentRegistry gcr; - - + + public ExecutorFactoryConfig configureAsyncListenerExecutor(){ return asyncListenerExecutor; } - + public ExecutorFactoryConfig configureAsyncTransportExecutor(){ return asyncTransportExecutor; } - + public ExecutorFactoryConfig configureEvictionScheduledExecutor(){ return evictionScheduledExecutor; } - + public ExecutorFactoryConfig configureReplicationQueueScheduledExecutor(){ return replicationQueueScheduledExecutor; } - + public GlobalJmxStatisticsConfig configureGlobalJmxStatistics(){ return globalJmxStatistics; } - + public SerializationConfig configureSerialization(){ return serialization; } - + public TransportConfig configureTransport(){ return transport; } @@ -369,7 +365,7 @@ /** * Toggle to enable/disable global statistics being exported via JMX - * + * * @param exposeGlobalJmxStatistics */ @Deprecated @@ -381,7 +377,7 @@ /** * If JMX statistics are enabled then all 'published' JMX objects will appear under this name. * This is optional, if not specified an object name will be created for you by default. - * + * * @param jmxObjectName */ @Deprecated @@ -415,7 +411,7 @@ /** * Fully qualified name of class that will attempt to locate a JMX MBean server to bind to - * + * * @param mBeanServerLookupClass fully qualified class name of the MBean Server Lookup class implementation */ @Deprecated @@ -456,7 +452,7 @@ * If true, multiple cache manager instances could be configured under the same configured JMX * domain. Each cache manager will in practice use a different JMX domain that has been * calculated based on the configured one by adding an incrementing index to it. - * + * * @param allowDuplicateDomains */ @Deprecated @@ -490,7 +486,7 @@ * with a NamedCacheNotFoundException. Otherwise, operations will succeed but it will be * logged on the caller that the RPC did not succeed on certain nodes due to the named cache * not being available. - * + * * @param strictPeerToPeer flag controlling this behavior */ @Deprecated @@ -582,7 +578,7 @@ /** * Fully qualified name of the marshaller to use. It must implement * org.infinispan.marshall.StreamingMarshaller - * + * * @param marshallerClass */ @Deprecated @@ -598,7 +594,7 @@ * Name of the current node. This is a friendly name to make logs, etc. make more sense. Defaults * to a combination of host name and a random number (to differentiate multiple nodes on the same * host) - * + * * @param nodeName */ @Deprecated @@ -614,7 +610,7 @@ /** * Fully qualified name of a class that represents a network transport. Must implement * org.infinispan.remoting.transport.Transport - * + * * @param transportClass */ @Deprecated @@ -635,14 +631,14 @@ public void setTransportProperties(String transportPropertiesString) { transport.setProperties(toTypedProperties(transportPropertiesString)); } - + public String getClusterName() { return transport.clusterName; } /** * Defines the name of the cluster. Nodes only connect to clusters sharing the same name. - * + * * @param clusterName */ @Deprecated @@ -692,7 +688,7 @@ } /** - * @see #setSiteId(String) + * @see #setSiteId(String) */ public String getSiteId() { return transport.siteId; @@ -709,7 +705,7 @@ * detected. REGISTER - Forces the cache to register a shutdown hook even if an MBean server is * detected. DONT_REGISTER - Forces the cache NOT to register a shutdown hook, even if no MBean * server is detected. - * + * * @param shutdownHookBehavior */ public void setShutdownHookBehavior(ShutdownHookBehavior shutdownHookBehavior) { @@ -797,7 +793,7 @@ * version cache instance in your cluster to ensure compatibility of communications. However, * setting this too low will mean you lose out on the benefit of improvements in newer versions * of the marshaller. - * + * * @param marshallVersion */ @Deprecated @@ -811,7 +807,7 @@ * version cache instance in your cluster to ensure compatibility of communications. However, * setting this too low will mean you lose out on the benefit of improvements in newer versions * of the marshaller. - * + * * @param marshallVersion */ @Deprecated @@ -922,7 +918,7 @@ result = 31 * result + (replicationQueueScheduledExecutor.properties != null ? replicationQueueScheduledExecutor.properties.hashCode() : 0); result = 31 * result + (serialization.marshallerClass != null ? serialization.marshallerClass.hashCode() : 0); result = 31 * result + (transport.transportClass != null ? transport.transportClass.hashCode() : 0); - result = 31 * result + (transport.properties != null ? transport.properties.hashCode() : 0); + result = 31 * result + (transport.properties != null ? transport.properties.hashCode() : 0); result = 31 * result + (transport.clusterName != null ? transport.clusterName.hashCode() : 0); result = 31 * result + (shutdown.hookBehavior.hashCode()); result = 31 * result + serialization.version.hashCode(); @@ -952,6 +948,15 @@ } /** + * Converts this configuration instance to an XML representation containing the current settings. + * + * @return a string containing the formatted XML representation of this configuration instance. + */ + public String toXmlString() { + return InfinispanConfiguration.toXmlString(this); + } + + /** * Helper method that gets you a default constructed GlobalConfiguration, preconfigured to use the default clustering * stack. * @@ -985,11 +990,11 @@ * The serialVersionUID */ private static final long serialVersionUID = 7625606997888180254L; - + @ConfigurationDocs( { - @ConfigurationDoc(name = "maxThreads", + @ConfigurationDoc(name = "maxThreads", desc = "Maximum number of threads for this executor. Default values can be found here"), - @ConfigurationDoc(name = "threadNamePrefix", + @ConfigurationDoc(name = "threadNamePrefix", desc = "Thread name prefix for threads created by this executor. Default values can be found here") }) protected TypedProperties properties = EMPTY_PROPERTIES; @@ -1001,7 +1006,7 @@ testImmutability("properties"); this.properties = properties; } - + @XmlElement(name = "properties") public TypedProperties getProperties(){ return properties; @@ -1016,20 +1021,20 @@ } /** - * + * * @see Configuration reference - * + * */ @XmlAccessorType(XmlAccessType.PROPERTY) @ConfigurationDocs( { - @ConfigurationDoc(name = "asyncListenerExecutor", + @ConfigurationDoc(name = "asyncListenerExecutor", desc = "Configuration for the executor service used to emit notifications to asynchronous listeners"), @ConfigurationDoc(name = "asyncTransportExecutor", desc = "Configuration for the executor service used for asynchronous work on the Transport, including asynchronous marshalling and Cache 'async operations' such as Cache.putAsync().") }) public static class ExecutorFactoryType extends FactoryClassWithPropertiesType implements ExecutorFactoryConfig{ private static final long serialVersionUID = 6895901500645539386L; - + @ConfigurationDoc(name="factory", desc="Fully qualified class name of the ExecutorFactory to use. Must implement org.infinispan.executors.ExecutorFactory") protected String factory = DefaultExecutorFactory.class.getName(); @@ -1041,26 +1046,31 @@ } @XmlAttribute + public String getFactory() { + return factory; + } + public void setFactory(String factory) { testImmutability("factory"); this.factory = factory; } @Override - public ExecutorFactoryType clone() throws CloneNotSupportedException { - return (ExecutorFactoryType) super.clone(); + public ExecutorFactoryConfig factory(Class clazz) { + setFactory(clazz == null ? null : clazz.getName()); + return this; } + @Override - public ExecutorFactoryConfig factory(Class clazz) { - factory = clazz.getName(); - return this; + public ExecutorFactoryType clone() throws CloneNotSupportedException { + return (ExecutorFactoryType) super.clone(); } @Override public Object addProperty(String key, String value) { return getProperties().put(key, value); - } + } @Override public ExecutorFactoryConfig withProperties(Properties props) { @@ -1070,21 +1080,21 @@ } /** - * - * + * + * * @see Configuration reference - * + * */ @XmlAccessorType(XmlAccessType.PROPERTY) @ConfigurationDocs( { - @ConfigurationDoc(name = "evictionScheduledExecutor", + @ConfigurationDoc(name = "evictionScheduledExecutor", desc = "Configuration for the scheduled executor service used to periodically run eviction cleanup tasks."), - @ConfigurationDoc(name = "replicationQueueScheduledExecutor", + @ConfigurationDoc(name = "replicationQueueScheduledExecutor", desc = "Configuration for the scheduled executor service used to periodically flush replication queues, used if asynchronous clustering is enabled along with useReplQueue being set to true.") }) public static class ScheduledExecutorFactoryType extends FactoryClassWithPropertiesType implements ExecutorFactoryConfig{ private static final long serialVersionUID = 7806391452092647488L; - + @ConfigurationDoc(name="factory",desc="Fully qualified class name of the ScheduledExecutorFactory to use. Must implement org.infinispan.executors.ScheduledExecutorFactory") protected String factory = DefaultScheduledExecutorFactory.class.getName(); @@ -1095,22 +1105,27 @@ public ScheduledExecutorFactoryType() { } + @XmlAttribute + public String getFactory() { + return factory; + } + public void setFactory(String factory) { testImmutability("factory"); this.factory = factory; } @Override - public ScheduledExecutorFactoryType clone() throws CloneNotSupportedException { - return (ScheduledExecutorFactoryType) super.clone(); + public ExecutorFactoryConfig factory(Class clazz) { + setFactory(clazz == null ? null : clazz.getName()); + return this; } + @Override - public ExecutorFactoryConfig factory(Class clazz) { - testImmutability("factory"); - this.factory = clazz.getName(); - return this; + public ScheduledExecutorFactoryType clone() throws CloneNotSupportedException { + return (ScheduledExecutorFactoryType) super.clone(); } @Override @@ -1118,7 +1133,7 @@ return getProperties().put(key, value); } - @Override + @Override public ExecutorFactoryConfig withProperties(Properties props) { getProperties().putAll(props); return this; @@ -1127,7 +1142,7 @@ /** * This element configures the transport used for network communications across the cluster. - * + * * @see Configuration reference */ @XmlAccessorType(XmlAccessType.PROPERTY) @@ -1138,25 +1153,25 @@ * The serialVersionUID */ private static final long serialVersionUID = -4739815717370060368L; - - @ConfigurationDocRef(bean=GlobalConfiguration.class,targetElement="setClusterName") + + @ConfigurationDocRef(bean=GlobalConfiguration.class,targetElement="setClusterName") protected String clusterName = "Infinispan-Cluster"; @ConfigurationDocRef(bean=GlobalConfiguration.class,targetElement="setMachineId") protected String machineId; - @ConfigurationDocRef(bean=GlobalConfiguration.class,targetElement="setRackId") + @ConfigurationDocRef(bean=GlobalConfiguration.class,targetElement="setRackId") protected String rackId; - @ConfigurationDocRef(bean=GlobalConfiguration.class,targetElement="setSiteId") + @ConfigurationDocRef(bean=GlobalConfiguration.class,targetElement="setSiteId") protected String siteId; @ConfigurationDocRef(bean=GlobalConfiguration.class,targetElement="setStrictPeerToPeer") - protected Boolean strictPeerToPeer = true; - + protected Boolean strictPeerToPeer = true; + @ConfigurationDoc(name="distributedSyncTimeout",desc="Cluster-wide synchronization timeout for locks. Used to coordinate changes in cluster membership.") protected Long distributedSyncTimeout = 240000L; // default - + @ConfigurationDocRef(bean=GlobalConfiguration.class,targetElement="setTransportClass") protected String transportClass = null; // The default constructor sets default to JGroupsTransport @@ -1180,144 +1195,172 @@ this.transportClass = transportClass; } - + - @Override - public TransportConfig clusterName(String clusterName) { + @XmlAttribute + public String getClusterName() { + return clusterName; + } + + public void setClusterName(String clusterName) { testImmutability("clusterName"); this.clusterName = clusterName; - return this; } - @Override - public TransportConfig machineId(String machineId) { - testImmutability("machineId"); - this.machineId = machineId; + public TransportConfig clusterName(String clusterName) { + setClusterName(clusterName); return this; } - + - @Override - public TransportConfig rackId(String rackId) { - testImmutability("rackId"); - this.rackId = rackId; - return this; + @XmlAttribute + public String getMachineId() { + return machineId; } + public void setMachineId(String machineId) { + testImmutability("machineId"); + this.machineId = machineId; + } - + @Override - public TransportConfig siteId(String siteId) { - testImmutability("siteId"); - this.siteId = siteId; + public TransportConfig machineId(String machineId) { + setMachineId(machineId); return this; } - + - @XmlAttribute - public void setClusterName(String clusterName) { - testImmutability("clusterName"); - this.clusterName = clusterName; - } @XmlAttribute - public void setMachineId(String machineId) { - testImmutability("machineId"); - this.machineId = machineId; + public String getRackId() { + return rackId; } - @XmlAttribute public void setRackId(String rackId) { testImmutability("rackId"); this.rackId = rackId; } + @Override + public TransportConfig rackId(String rackId) { + setRackId(rackId); + return this; + } + + @XmlAttribute + public String getSiteId() { + return siteId; + } + public void setSiteId(String siteId) { testImmutability("siteId"); this.siteId = siteId; } @Override - public TransportConfig distributedSyncTimeout(Long distributedSyncTimeout) { - testImmutability("distributedSyncTimeout"); - this.distributedSyncTimeout = distributedSyncTimeout; + public TransportConfig siteId(String siteId) { + setSiteId(siteId); return this; } - + + - @XmlAttribute + @XmlAttribute + public Long getDistributedSyncTimeout() { + return distributedSyncTimeout; + } + public void setDistributedSyncTimeout(Long distributedSyncTimeout) { testImmutability("distributedSyncTimeout"); this.distributedSyncTimeout = distributedSyncTimeout; } + @Override + public TransportConfig distributedSyncTimeout(Long distributedSyncTimeout) { + setDistributedSyncTimeout(distributedSyncTimeout); + return this; + } + + - @XmlAttribute + @XmlAttribute + public String getTransportClass() { + return transportClass; + } + public void setTransportClass(String transportClass) { testImmutability("transportClass"); this.transportClass = transportClass; } - + @Override public TransportConfig transportClass(Class transportClass) { - testImmutability("transportClass"); - this.transportClass = transportClass.getName(); + setTransportClass(transportClass == null ? null : transportClass.getName()); - return this; + return this; } - + - @Override - public TransportConfig nodeName(String nodeName) { - testImmutability("nodeName"); - this.nodeName = nodeName; - return this; + @XmlAttribute + public String getNodeName() { + return nodeName; } - + - @XmlAttribute public void setNodeName(String nodeName) { testImmutability("nodeName"); this.nodeName = nodeName; } - + + @Override + public TransportConfig nodeName(String nodeName) { + setNodeName(nodeName); + return this; + } + + @XmlTransient public void setProperties(TypedProperties properties) { testImmutability("properties"); this.properties = properties; } - + @Override public TransportConfig withProperties(Properties properties) { - testImmutability("properties"); - this.properties = toTypedProperties(properties); + setProperties(toTypedProperties(properties)); return this; } - + @Override public Object addProperty(String key, String value){ return this.properties.put(key, value); } - + - @Override - public TransportConfig strictPeerToPeer(Boolean strictPeerToPeer) { - testImmutability("strictPeerToPeer"); - this.strictPeerToPeer = strictPeerToPeer; - return this; - } - - @XmlAttribute + + @XmlAttribute + public Boolean getStrictPeerToPeer() { + return strictPeerToPeer; + } + public void setStrictPeerToPeer(Boolean strictPeerToPeer) { testImmutability("strictPeerToPeer"); this.strictPeerToPeer = strictPeerToPeer; } @Override + public TransportConfig strictPeerToPeer(Boolean strictPeerToPeer) { + setStrictPeerToPeer(strictPeerToPeer); + return this; + } + + + @Override public TransportType clone() throws CloneNotSupportedException { TransportType dolly = (TransportType) super.clone(); dolly.properties = (TypedProperties) properties.clone(); return dolly; - } + } } /** * Serialization and marshalling settings. - * + * * @see Configuration reference */ @XmlAccessorType(XmlAccessType.PROPERTY) @@ -1329,10 +1372,10 @@ */ private static final long serialVersionUID = -925947118621507282L; - @ConfigurationDocRef(bean=GlobalConfiguration.class,targetElement="setMarshallerClass") + @ConfigurationDocRef(bean=GlobalConfiguration.class,targetElement="setMarshallerClass") protected String marshallerClass = VersionAwareMarshaller.class.getName(); // the default - - @ConfigurationDocRef(bean=GlobalConfiguration.class,targetElement="setMarshallVersion") + + @ConfigurationDocRef(bean=GlobalConfiguration.class,targetElement="setMarshallVersion") protected String version = Version.MAJOR_MINOR; @XmlElement(name = "externalizers") @@ -1345,38 +1388,45 @@ public void accept(ConfigurationBeanVisitor v) { v.visitSerializationType(this); } - + public void setExternalizerTypes(ExternalizersType externalizerTypes) { this.externalizerTypes = externalizerTypes; } - @Override - public SerializationConfig marshallerClass(Class marshallerClass) { + + @XmlAttribute + public String getMarshallerClass() { + return marshallerClass; + } + + public void setMarshallerClass(String marshallerClass) { testImmutability("marshallerClass"); - this.marshallerClass = marshallerClass.getName(); - return this; + this.marshallerClass = marshallerClass; } - @Override - public SerializationConfig version(String version) { - testImmutability("version"); - this.version = version; + public SerializationConfig marshallerClass(Class marshallerClass) { + setMarshallerClass(marshallerClass == null ? null : marshallerClass.getName()); return this; } - + + @XmlAttribute - public void setMarshallerClass(String marshallerClass) { - testImmutability("marshallerClass"); - this.marshallerClass = marshallerClass; + public String getVersion() { + return version; } - @XmlAttribute public void setVersion(String version) { testImmutability("version"); this.version = version; } - + + @Override + public SerializationConfig version(String version) { + setVersion(version); + return this; + } + // TODO implement equals and hashCode and update parent equals/hashcode @Override @@ -1392,11 +1442,11 @@ @XmlAccessorType(XmlAccessType.FIELD) @ConfigurationDoc(name = "externalizers") public static class ExternalizersType extends AbstractConfigurationBeanWithGCR implements ExternalizersConfig { - + /** The serialVersionUID */ private static final long serialVersionUID = -496116709223466807L; - + @XmlElement(name = "externalizer") private List externalizers = new ArrayList(); @@ -1449,7 +1499,7 @@ } @Override - public ExternalizersConfig addExtrenalizer(ExternalizerConfig e) { + public ExternalizersConfig addExtrenalizer(ExternalizerConfig e) { this.externalizers.add(e); return this; } @@ -1467,7 +1517,7 @@ /** * This element specifies whether global statistics are gathered and reported via JMX for all * caches under this cache manager. - * + * * @see Configuration reference */ @XmlAccessorType(XmlAccessType.PROPERTY) @@ -1498,24 +1548,28 @@ @XmlElement(name = "properties") @ConfigurationDocRef(bean = GlobalConfiguration.class, targetElement = "setMBeanServerProperties") protected TypedProperties properties = EMPTY_PROPERTIES; - + private MBeanServerLookup mBeanServerLookupInstance; - @Override - public GlobalJmxStatisticsConfig enabled(Boolean enabled) { - testImmutability("enabled"); - this.enabled = enabled; - return this; + public void accept(ConfigurationBeanVisitor v) { + v.visitGlobalJmxStatisticsType(this); } + @XmlAttribute + public Boolean getEnabled() { + return enabled; + } + public void setEnabled(Boolean enabled) { testImmutability("enabled"); this.enabled = enabled; } - public void accept(ConfigurationBeanVisitor v) { - v.visitGlobalJmxStatisticsType(this); + @Override + public GlobalJmxStatisticsConfig enabled(Boolean enabled) { + setEnabled(enabled); + return this; } @XmlTransient @@ -1523,58 +1577,75 @@ this.properties = p; } - @Override - public GlobalJmxStatisticsConfig jmxDomain(String jmxDomain) { - testImmutability("jmxDomain"); - this.jmxDomain = jmxDomain; - return this; - } @XmlAttribute + public String getJmxDomain() { + return jmxDomain; + } + public void setJmxDomain(String jmxDomain) { testImmutability("jmxDomain"); this.jmxDomain = jmxDomain; } @Override - public GlobalJmxStatisticsConfig mBeanServerLookup(Class beanServerLookupClass) { - testImmutability("mBeanServerLookup"); - mBeanServerLookup = beanServerLookupClass.getName(); + public GlobalJmxStatisticsConfig jmxDomain(String jmxDomain) { + setJmxDomain(jmxDomain); return this; } + @XmlAttribute + public String getmBeanServerLookup() { + return mBeanServerLookup; + } + public void setMBeanServerLookup(String beanServerLookup) { testImmutability("mBeanServerLookup"); mBeanServerLookup = beanServerLookup; } @Override - public GlobalJmxStatisticsConfig allowDuplicateDomains(Boolean allowDuplicateDomains) { - testImmutability("allowDuplicateDomains"); - this.allowDuplicateDomains = allowDuplicateDomains; + public GlobalJmxStatisticsConfig mBeanServerLookup(Class beanServerLookupClass) { + setMBeanServerLookup(beanServerLookupClass == null ? null : beanServerLookupClass.getName()); return this; } + @XmlAttribute + public Boolean getAllowDuplicateDomains() { + return allowDuplicateDomains; + } + public void setAllowDuplicateDomains(Boolean allowDuplicateDomains) { testImmutability("allowDuplicateDomains"); this.allowDuplicateDomains = allowDuplicateDomains; } @Override - public GlobalJmxStatisticsConfig cacheManagerName(String cacheManagerName) { - testImmutability("cacheManagerName"); - this.cacheManagerName = cacheManagerName; + public GlobalJmxStatisticsConfig allowDuplicateDomains(Boolean allowDuplicateDomains) { + setAllowDuplicateDomains(allowDuplicateDomains); return this; } + @XmlAttribute + public String getCacheManagerName() { + return cacheManagerName; + } + public void setCacheManagerName(String cacheManagerName) { testImmutability("cacheManagerName"); this.cacheManagerName = cacheManagerName; } + @Override + public GlobalJmxStatisticsConfig cacheManagerName(String cacheManagerName) { + setCacheManagerName(cacheManagerName); + return this; + } + + @XmlTransient public MBeanServerLookup getMBeanServerLookupInstance() { if (mBeanServerLookupInstance == null) mBeanServerLookupInstance = (MBeanServerLookup) Util.getInstance(mBeanServerLookup); @@ -1582,7 +1653,6 @@ return mBeanServerLookupInstance; } - @XmlTransient public void setMBeanServerLookupInstance(MBeanServerLookup MBeanServerLookupInstance) { this.mBeanServerLookupInstance = MBeanServerLookupInstance; } @@ -1602,7 +1672,7 @@ /** * This element specifies behavior when the JVM running the cache instance shuts down. - * + * * @see Configuration reference */ @XmlAccessorType(XmlAccessType.PROPERTY) @@ -1617,17 +1687,22 @@ @ConfigurationDocRef(bean=GlobalConfiguration.class,targetElement="setShutdownHookBehavior") protected ShutdownHookBehavior hookBehavior = ShutdownHookBehavior.DEFAULT; + public void accept(ConfigurationBeanVisitor v) { + v.visitShutdownType(this); + } + + @XmlAttribute + public ShutdownHookBehavior getHookBehavior() { + return hookBehavior; + } + public void setHookBehavior(ShutdownHookBehavior hookBehavior) { testImmutability("hookBehavior"); this.hookBehavior = hookBehavior; } - - public void accept(ConfigurationBeanVisitor v) { - v.visitShutdownType(this); - } - } + } +} -} abstract class AbstractConfigurationBeanWithGCR extends AbstractConfigurationBean { Index: core/src/main/java/org/infinispan/CacheDelegate.java =================================================================== --- core/src/main/java/org/infinispan/CacheDelegate.java (revision a120cd344fc2f3938ef2a8b6035a405df171feb0) +++ core/src/main/java/org/infinispan/CacheDelegate.java (revision ) @@ -430,6 +430,15 @@ return name + "(" + getConfiguration().getCacheModeString().toLowerCase() + ")"; } + /** + * Returns the cache configuration as XML string. + */ + @ManagedAttribute(description = "Returns the cache configuration as XML string") + @Metric(displayName = "Cache configuration XML", dataType = DataType.TRAIT, displayType = DisplayType.SUMMARY) + public String getConfigurationAsXmlString() { + return getConfiguration().toXmlString(); + } + public String getVersion() { return Version.VERSION; } Index: core/src/main/java/org/infinispan/config/InfinispanConfiguration.java =================================================================== --- core/src/main/java/org/infinispan/config/InfinispanConfiguration.java (revision a120cd344fc2f3938ef2a8b6035a405df171feb0) +++ core/src/main/java/org/infinispan/config/InfinispanConfiguration.java (revision ) @@ -25,18 +25,15 @@ import org.infinispan.config.parsing.NamespaceFilter; import org.infinispan.config.parsing.XmlConfigurationParser; import org.infinispan.util.FileLookup; +import org.infinispan.util.StringPropertyReplacer; import org.infinispan.util.logging.Log; import org.infinispan.util.logging.LogFactory; -import org.infinispan.util.StringPropertyReplacer; import org.xml.sax.InputSource; import org.xml.sax.XMLFilter; import org.xml.sax.XMLReader; import org.xml.sax.helpers.XMLReaderFactory; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Unmarshaller; -import javax.xml.bind.ValidationEvent; -import javax.xml.bind.ValidationEventHandler; +import javax.xml.bind.*; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; @@ -44,14 +41,8 @@ import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamSource; import javax.xml.validation.SchemaFactory; - -import java.io.BufferedReader; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.io.StringReader; +import java.io.*; +import java.lang.ref.SoftReference; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; @@ -62,13 +53,13 @@ * InfinispanConfiguration encapsulates root component of Infinispan XML configuration. Can be empty * for sensible defaults throughout, however that would only give you the most basic of local, * non-clustered caches. - * + * * @author Vladimir Blagojevic * @since 4.0 */ @XmlRootElement(name = "infinispan") @XmlAccessorType(XmlAccessType.FIELD) -@ConfigurationDoc(name="infinispan") +@ConfigurationDoc(name = "infinispan") public class InfinispanConfiguration implements XmlConfigurationParser, JAXBUnmarshallable { private static final Log log = LogFactory.getLog(InfinispanConfiguration.class); @@ -85,6 +76,8 @@ private static final String DEFAULT_SCHEMA_URL = String.format("http://www.infinispan.org/schemas/infinispan-config-%s.xsd", Version.MAJOR_MINOR); + private static SoftReference jaxbContextReference; + @XmlElement private final GlobalConfiguration global = new GlobalConfiguration(); @@ -149,7 +142,7 @@ * @throws IOException if there are any issues creating InfinispanConfiguration object */ public static InfinispanConfiguration newInfinispanConfiguration(String configFileName) - throws IOException { + throws IOException { return newInfinispanConfiguration(configFileName, null); } @@ -161,7 +154,7 @@ * @throws IOException if there are any issues creating InfinispanConfiguration object */ public static InfinispanConfiguration newInfinispanConfiguration(InputStream config) - throws IOException { + throws IOException { return newInfinispanConfiguration(config, null); } @@ -173,7 +166,7 @@ * @throws IOException if there are any issues creating InfinispanConfiguration object */ public static InfinispanConfiguration newInfinispanConfiguration(Reader config) - throws IOException { + throws IOException { return newInfinispanConfiguration(config, null); } @@ -218,8 +211,7 @@ public static InfinispanConfiguration newInfinispanConfiguration(Reader config, InputStream schema, ConfigurationBeanVisitor cbv) throws IOException { try { - JAXBContext jc = JAXBContext.newInstance(InfinispanConfiguration.class); - Unmarshaller u = jc.createUnmarshaller(); + Unmarshaller u = getJAXBContext().createUnmarshaller(); NamespaceFilter nf = new NamespaceFilter(); XMLReader reader = XMLReaderFactory.createXMLReader(); nf.setParent(reader); @@ -282,6 +274,46 @@ return newInfinispanConfiguration(new InputStreamReader(config), schema, cbv); } + /** + * Returns the JAXB context that may be used to read and write Infinispan configurations. + * + * @return the JAXB context that may be used to read and write Infinispan configurations. + * @throws JAXBException In case of the creation of the context failed. + */ + protected static synchronized JAXBContext getJAXBContext() throws JAXBException { + JAXBContext context = jaxbContextReference != null ? jaxbContextReference.get() : null; + if (context == null) { + context = JAXBContext.newInstance(InfinispanConfiguration.class); + jaxbContextReference = new SoftReference(context); + } + + return context; + } + + /** + * Converts an instance of GlobalConfiguration, Configuration or InfinispanConfiguration to + * its XML representation. + * + * @param compatibleConfigurationInstance + * a configuration instance that support XML marshaling. + * @return a string containing the formatted XML representation of the given instance. + */ + protected static String toXmlString(Object compatibleConfigurationInstance) { + try { + StringWriter writer = new StringWriter(1024); + try { + Marshaller m = getJAXBContext().createMarshaller(); + m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + m.marshal(compatibleConfigurationInstance, writer); + return writer.toString(); + } finally { + writer.close(); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + private static SAXSource replaceProperties(Reader config, XMLFilter filter) throws Exception { BufferedReader br = new BufferedReader(config); StringBuilder w = new StringBuilder(); @@ -331,7 +363,7 @@ return is; } log.debug("Could not find schema on path " + localPathToSchema + ", resolving " - + SCHEMA_SYSTEM_PROPERTY + " to " + schemaPath()); + + SCHEMA_SYSTEM_PROPERTY + " to " + schemaPath()); } //2. resolve local schema path in infinispan distro @@ -341,7 +373,7 @@ return is; } log.debug("Could not find schema on path " + schemaPath() + ", resolving " - + SCHEMA_URL_SYSTEM_PROPERTY + " to " + schemaURL()); + + SCHEMA_URL_SYSTEM_PROPERTY + " to " + schemaURL()); //3. resolve URL try { @@ -352,8 +384,8 @@ } log.warn("Infinispan schema could not be resolved locally nor fetched from URL. Local path=" - + localPathToSchema + ", schemaPath=" + schemaPath() + ",schemaURL=" - + schemaURL()); + + localPathToSchema + ", schemaPath=" + schemaPath() + ",schemaURL=" + + schemaURL()); return null; } @@ -393,7 +425,7 @@ InputStream is = fileLookup.lookupFile(fileName); if (is == null) throw new FileNotFoundException("File " + fileName - + " could not be found, either on the classpath or on the file system!"); + + " could not be found, either on the classpath or on the file system!"); return is; } @@ -417,4 +449,13 @@ public void willUnmarshall(Object parent) { // no-op } + + /** + * Converts this configuration instance to an XML representation containing the current settings. + * + * @return a string containing the formatted XML representation of this configuration instance. + */ + public String toXmlString() { + return toXmlString(this); -} + } +}