[jboss-cvs] JBossCache/src/org/jboss/cache/config ...

Manik Surtani msurtani at jboss.com
Wed Jul 19 17:34:43 EDT 2006


  User: msurtani
  Date: 06/07/19 17:34:43

  Modified:    src/org/jboss/cache/config    Configuration.java
                        ConfigurationException.java
  Removed:     src/org/jboss/cache/config    ConfigurationImpl.java
  Log:
  JBCACHE-657
  JBCACHE-594
  
  Revision  Changes    Path
  1.4       +407 -43   JBossCache/src/org/jboss/cache/config/Configuration.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Configuration.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/config/Configuration.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- Configuration.java	19 Jul 2006 05:10:11 -0000	1.3
  +++ Configuration.java	19 Jul 2006 21:34:43 -0000	1.4
  @@ -6,78 +6,442 @@
    */
   package org.jboss.cache.config;
   
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
  +import org.jboss.cache.Version;
  +import org.jboss.cache.lock.IsolationLevel;
  +import org.w3c.dom.Attr;
   import org.w3c.dom.Element;
  -
  -import java.util.Set;
  +import org.w3c.dom.NamedNodeMap;
  +import org.w3c.dom.NodeList;
  +import com.sun.tools.doclets.formats.html.ConfigurationImpl;
   
   /**
  - * A configuration object that represents a cache configuration.  Internally all config elements are
  - * stored as Strings.
  - *
  - * Convenience methods that return configuration elements as ints, longs, booleans, etc. are convenience
  - * methods.  It is expected that internally, {@link org.jboss.cache.interceptors.Interceptor}s will be injected
  - * with a Configuration object when the Interceptor is constructed.  It is also expected that the Interceptors
  - * will cache the values they need since the convenience methods are less than efficient.  
  + * Implementation of the Configuration interface.
    *
    * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
  - * @since 2.0.0
    */
  -public interface Configuration
  +public class Configuration
   {
  +    public enum CacheMode
  +    {
  +        LOCAL, REPL_SYNC, REPL_ASYNC, INVALIDATION_SYNC, INVALIDATION_ASYNC }
  +
  +    private Log log = LogFactory.getLog(ConfigurationImpl.class);
  +
  +    /**
  +     * Default replication version, from {@link Version#getVersionShort}.
  +     */
  +    private static final short DEFAULT_REPLICATION_VERSION = Version.getVersionShort();
  +
  +    /**
  +     * Default cluster name.
  +     */
  +    private String clusterName = "TreeCache-Group";
  +
  +    /**
  +     * Default cluster properties.
  +     */
  +    private String clusterConfig = null;
  +
  +    /**
  +     * True if replication is queued.
  +     */
  +    private boolean useReplQueue = false;
  +
  +    /**
  +     * Maximum number of replicated elements to queue.
  +     */
  +    private int replQueueMaxElements = 1000;
  +
  +    /**
  +     * Replicated element queue interval.
  +     */
  +    private long replQueueInterval = 5000;
  +
  +    /**
  +     * True if MBean interceptors are used.
  +     */
  +    private boolean useInterceptorMbeans = true;
  +
  +    private boolean fetchInMemoryState = true;
  +
  +    private short replicationVersion = DEFAULT_REPLICATION_VERSION;
  +    private String replVersionString = Version.getVersionString(DEFAULT_REPLICATION_VERSION);
  +
  +    private long lockAcquisitionTimeout = 10000;
  +
  +    private long syncReplTimeout = 15000;
  +    private String evictionPolicyClass = null;
  +    private CacheMode cacheModeInt = CacheMode.LOCAL;
  +    private String cacheMode = "LOCAL";
  +    private boolean inactiveOnStartup = false;
  +
  +    private long initialStateRetrievalTimeout = 10000;
  +
       /**
  -     * Returns the value of an attribute.
  -     * @param attribute
  -     * @return value
  +     * Isolation level in use, default is {@link org.jboss.cache.lock.IsolationLevel#REPEATABLE_READ}.
        */
  -    String getAttribute(String attribute);
  +    private IsolationLevel isolationLevel = IsolationLevel.REPEATABLE_READ;
   
       /**
  -     * Returns an attribute as an int.
  -     * @param attribute
  -     * @return value as an int
  -     * @throws ConfigurationException if the attribute value is not an int.
  +     * Eviction policy configuration in xml Element
        */
  -    int getAttributeAsInt(String attribute) throws ConfigurationException;
  +    private Element evictionPolicyConfig = null;
  +
   
       /**
  -     * Returns an attribute as a long.
  -     * @param attribute
  -     * @return value as a long
  -     * @throws ConfigurationException if the attribute value is not an long.
  +     * True if we use region based marshalling.  Defaults to false.
        */
  -    long getAttributeAsLong(String attribute) throws ConfigurationException;
  +    private boolean useRegionBasedMarshalling = false;
  +
   
  +    /**
  +     * Class of the implementation of TransactionManagerLookup
  +     */
  +    private String transactionManagerLookupClass = null;
   
       /**
  -     * Returns an attribute as a boolean.
  -     * @param attribute
  -     * @return
  -     * @throws ConfigurationException if the attribute value is not a boolean.
  +     * The XML Element from which to configure the CacheLoader
        */
  -    boolean getAttributeAsBoolean(String attribute) throws ConfigurationException;
  +    private Element cacheLoaderConfig = null;
   
       /**
  -     * Returns an attribute as an XML {@link Element}.
  -     * @param attribute
  -     * @return
  -     * @throws ConfigurationException if the attribute value can not be used to create an XML Element.
  +     * True if there is a synchronous commit phase, otherwise asynchronous commit.
        */
  -    Element getAttributeAsXml(String attribute) throws ConfigurationException;
  +    private boolean syncCommitPhase = false;
   
       /**
  -     * Sets a value under a given attribute.  Cannot be used if this is retrieved from {@link org.jboss.cache.jmx.CacheMBean#getConfiguration()}
  -     * @param attribute
  -     * @param value
  +     * True if there is a synchronous rollback phase, otherwise asynchronous rollback.
        */
  -    void setAttribute(String attribute, String value);
  +    private boolean syncRollbackPhase = false;
   
       /**
  -     * Returns the keys for String, integer, long or boolean type attribs
  +     * Buddy replication configuration XML element
        */
  -    Set<String> getSimpleAttributeNames();
  +    private Element buddyReplicationConfig;
  +
  +    private boolean nodeLockingOptimistic = false;
  +    private String nodeLockingScheme = "PESSIMISTIC";
   
       /**
  -     * Returns the keys for XML type attribs.
  +     * Converts a list of elements to a Java Groups property string.
        */
  -    Set<String> getXmlAttributeNames();
  +    public void setClusterConfig(Element config)
  +    {
  +        StringBuffer buffer = new StringBuffer();
  +        NodeList stack = config.getChildNodes();
  +        int length = stack.getLength();
  +
  +        for (int s = 0; s < length; s++)
  +        {
  +            org.w3c.dom.Node node = stack.item(s);
  +            if (node.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE)
  +            {
  +                continue;
  +            }
  +
  +            Element tag = (Element) node;
  +            String protocol = tag.getTagName();
  +            buffer.append(protocol);
  +            NamedNodeMap attrs = tag.getAttributes();
  +            int attrLength = attrs.getLength();
  +            if (attrLength > 0)
  +            {
  +                buffer.append('(');
  +            }
  +            for (int a = 0; a < attrLength; a++)
  +            {
  +                Attr attr = (Attr) attrs.item(a);
  +                String name = attr.getName();
  +                String value = attr.getValue();
  +                buffer.append(name);
  +                buffer.append('=');
  +                buffer.append(value);
  +                if (a < attrLength - 1)
  +                {
  +                    buffer.append(';');
  +                }
  +            }
  +            if (attrLength > 0)
  +            {
  +                buffer.append(')');
  +            }
  +            buffer.append(':');
  +        }
  +        // Remove the trailing ':'
  +        buffer.setLength(buffer.length() - 1);
  +        clusterConfig = buffer.toString();
  +        if (log.isDebugEnabled()) log.debug("setting cluster properties from xml to: " + clusterConfig);
  +    }
  +
  +    public boolean isNodeLockingOptimistic()
  +    {
  +        return nodeLockingOptimistic;
  +    }
  +
  +    public boolean isUseReplQueue()
  +    {
  +        return useReplQueue;
  +    }
  +
  +    public String getClusterName()
  +    {
  +        return clusterName;
  +    }
  +
  +    public void setClusterName(String clusterName)
  +    {
  +        this.clusterName = clusterName;
  +    }
  +
  +    public String getClusterConfig()
  +    {
  +        return clusterConfig;
  +    }
  +
  +    public void setClusterConfig(String clusterConfig)
  +    {
  +        this.clusterConfig = clusterConfig;
  +    }
  +
  +    public int getReplQueueMaxElements()
  +    {
  +        return replQueueMaxElements;
  +    }
  +
  +    public void setReplQueueMaxElements(int replQueueMaxElements)
  +    {
  +        this.replQueueMaxElements = replQueueMaxElements;
  +    }
  +
  +    public long getReplQueueInterval()
  +    {
  +        return replQueueInterval;
  +    }
  +
  +    public void setReplQueueInterval(long replQueueInterval)
  +    {
  +        this.replQueueInterval = replQueueInterval;
  +    }
  +
  +    public boolean isUseInterceptorMbeans()
  +    {
  +        return useInterceptorMbeans;
  +    }
  +
  +    public void setUseInterceptorMbeans(boolean useInterceptorMbeans)
  +    {
  +        this.useInterceptorMbeans = useInterceptorMbeans;
  +    }
  +
  +    public boolean isFetchInMemoryState()
  +    {
  +        return fetchInMemoryState;
  +    }
  +
  +    public void setFetchInMemoryState(boolean fetchInMemoryState)
  +    {
  +        this.fetchInMemoryState = fetchInMemoryState;
  +    }
  +
  +    public short getReplicationVersion()
  +    {
  +        return replicationVersion;
  +    }
  +
  +    public void setReplicationVersion(short replicationVersion)
  +    {
  +        this.replicationVersion = replicationVersion;
  +    }
  +
  +    public String getReplVersionString()
  +    {
  +        return replVersionString;
  +    }
  +
  +    public void setReplVersionString(String replVersionString)
  +    {
  +        this.replVersionString = replVersionString;
  +    }
  +
  +    public long getLockAcquisitionTimeout()
  +    {
  +        return lockAcquisitionTimeout;
  +    }
  +
  +    public void setLockAcquisitionTimeout(long lockAcquisitionTimeout)
  +    {
  +        this.lockAcquisitionTimeout = lockAcquisitionTimeout;
  +    }
  +
  +    public long getSyncReplTimeout()
  +    {
  +        return syncReplTimeout;
  +    }
  +
  +    public void setSyncReplTimeout(long syncReplTimeout)
  +    {
  +        this.syncReplTimeout = syncReplTimeout;
  +    }
  +
  +    public String getEvictionPolicyClass()
  +    {
  +        return evictionPolicyClass;
  +    }
  +
  +    public void setEvictionPolicyClass(String evictionPolicyClass)
  +    {
  +        this.evictionPolicyClass = evictionPolicyClass;
  +    }
  +
  +    public CacheMode getCacheModeInt()
  +    {
  +        return cacheModeInt;
  +    }
  +
  +    public void setCacheModeInt(CacheMode cacheModeInt)
  +    {
  +        this.cacheModeInt = cacheModeInt;
  +    }
  +
  +    public String getCacheMode()
  +    {
  +        return cacheMode;
  +    }
  +
  +    public void setCacheMode(String cacheMode)
  +    {
  +        this.cacheMode = cacheMode;
  +    }
  +
  +    public boolean isInactiveOnStartup()
  +    {
  +        return inactiveOnStartup;
  +    }
  +
  +    public void setInactiveOnStartup(boolean inactiveOnStartup)
  +    {
  +        this.inactiveOnStartup = inactiveOnStartup;
  +    }
  +    public IsolationLevel getIsolationLevel()
  +    {
  +        return isolationLevel;
  +    }
  +
  +    public void setIsolationLevel(String isolationLevel)
  +    {
  +        this.isolationLevel = IsolationLevel.stringToIsolationLevel(isolationLevel);
  +        if (this.isolationLevel == null)
  +        {
  +           throw new ConfigurationException("IsolationLevel: level \"" + isolationLevel + "\" is invalid", "IsolationLevel");
  +        }
  +    }
  +
  +    public Element getEvictionPolicyConfig()
  +    {
  +        return evictionPolicyConfig;
  +    }
  +
  +    public void setEvictionPolicyConfig(Element evictionPolicyConfig)
  +    {
  +        this.evictionPolicyConfig = evictionPolicyConfig;
  +    }
  +
  +    public boolean isUseRegionBasedMarshalling()
  +    {
  +        return useRegionBasedMarshalling;
  +    }
  +
  +    public void setUseRegionBasedMarshalling(boolean useRegionBasedMarshalling)
  +    {
  +        this.useRegionBasedMarshalling = useRegionBasedMarshalling;
  +    }
  +
  +    public String getTransactionManagerLookupClass()
  +    {
  +        return transactionManagerLookupClass;
  +    }
  +
  +    public void setTransactionManagerLookupClass(String transactionManagerLookupClass)
  +    {
  +        this.transactionManagerLookupClass = transactionManagerLookupClass;
  +    }
  +
  +    public Element getCacheLoaderConfig()
  +    {
  +        return cacheLoaderConfig;
  +    }
  +
  +    public void setCacheLoaderConfig(Element cacheLoaderConfig)
  +    {
  +        this.cacheLoaderConfig = cacheLoaderConfig;
  +    }
  +
  +    public boolean isSyncCommitPhase()
  +    {
  +        return syncCommitPhase;
  +    }
  +
  +    public void setSyncCommitPhase(boolean syncCommitPhase)
  +    {
  +        this.syncCommitPhase = syncCommitPhase;
  +    }
  +
  +    public boolean isSyncRollbackPhase()
  +    {
  +        return syncRollbackPhase;
  +    }
  +
  +    public void setSyncRollbackPhase(boolean syncRollbackPhase)
  +    {
  +        this.syncRollbackPhase = syncRollbackPhase;
  +    }
  +
  +    public Element getBuddyReplicationConfig()
  +    {
  +        return buddyReplicationConfig;
  +    }
  +
  +    public void setBuddyReplicationConfig(Element buddyReplicationConfig)
  +    {
  +        this.buddyReplicationConfig = buddyReplicationConfig;
  +    }
  +
  +    public String getNodeLockingScheme()
  +    {
  +        return nodeLockingScheme;
  +    }
  +
  +    public void setNodeLockingScheme(String nodeLockingScheme)
  +    {
  +        this.nodeLockingScheme = nodeLockingScheme;
  +    }
  +
  +    public void setUseReplQueue(boolean useReplQueue)
  +    {
  +        this.useReplQueue = useReplQueue;
  +    }
  +
  +    public void setIsolationLevel(IsolationLevel isolationLevel)
  +    {
  +        this.isolationLevel = isolationLevel;
  +    }
  +
  +    public void setNodeLockingOptimistic(boolean nodeLockingOptimistic)
  +    {
  +        this.nodeLockingOptimistic = nodeLockingOptimistic;
  +    }
  +
  +    public long getInitialStateRetrievalTimeout()
  +    {
  +        return initialStateRetrievalTimeout;
  +    }
  +
  +    public void setInitialStateRetrievalTimeout(long initialStateRetrievalTimeout)
  +    {
  +        this.initialStateRetrievalTimeout = initialStateRetrievalTimeout;
  +    }
  +
  +
   }
  
  
  
  1.2       +6 -0      JBossCache/src/org/jboss/cache/config/ConfigurationException.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ConfigurationException.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/config/ConfigurationException.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- ConfigurationException.java	21 Jun 2006 11:17:25 -0000	1.1
  +++ ConfigurationException.java	19 Jul 2006 21:34:43 -0000	1.2
  @@ -29,6 +29,12 @@
           super(string);
       }
   
  +    public ConfigurationException(String string, String erroneousAttribute)
  +    {
  +        super(string);
  +        erroneousAttributes.add(erroneousAttribute);
  +    }
  +
       public ConfigurationException(String string, Throwable throwable)
       {
           super(string, throwable);
  
  
  



More information about the jboss-cvs-commits mailing list