Author: mircea.markus
Date: 2008-06-25 13:04:10 -0400 (Wed, 25 Jun 2008)
New Revision: 6042
Added:
core/trunk/src/main/etc/META-INF/config2to3.xslt
core/trunk/src/main/java/org/jboss/cache/config/parsing/ConfigFilesConvertor.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/element/
core/trunk/src/main/java/org/jboss/cache/config/parsing/element/BuddyElementParser.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/element/LoadersElementParser.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/BuddyElementParserTest.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/JGroupsStackParserTest.java
Removed:
core/trunk/src/main/java/org/jboss/cache/config/parsing/BuddyReplicationElementParser.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheLoadersElementParser.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/EvictionElementParser.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParserOld.java
Modified:
core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java
core/trunk/src/main/java/org/jboss/cache/config/Configuration.java
core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java
core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionConfig.java
core/trunk/src/main/java/org/jboss/cache/config/MissingPolicyException.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlParser.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/JGroupsStackParser.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java
core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicyConfigBase.java
core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationConfiguration.java
core/trunk/src/main/java/org/jboss/cache/eviction/LRUConfiguration.java
core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
core/trunk/src/main/java/org/jboss/cache/jmx/LegacyConfiguration.java
core/trunk/src/test/java/org/jboss/cache/CacheFactoryTest.java
core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationConfigTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
core/trunk/src/test/java/org/jboss/cache/config/ConfigurationCloningTest.java
core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/config/StringPropertyReplacementTest.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/CacheLoadersElementParserTest.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/FIFOConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/LFUConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/RegionManagerTest.java
core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java
core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java
core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/jmx/LegacyConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/jmx/NotificationTest.java
core/trunk/src/test/java/org/jboss/cache/loader/AbstractCacheLoaderTestBase.java
core/trunk/src/test/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderCompatibilityTest.java
core/trunk/src/test/java/org/jboss/cache/loader/AsyncFileCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderManagerTest.java
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderPurgingTest.java
core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderBasicTest.java
core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderFullTest.java
core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheServerTest.java
core/trunk/src/test/java/org/jboss/cache/mgmt/MgmtTestBase.java
core/trunk/src/test/java/org/jboss/cache/mgmt/PassivationTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithPassivationTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/BasicPassivationTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/ConcurrentPassivationTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/LocalPassivationIntegrationTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToBdbjeCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToFileCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToJDBCCacheLoaderTest.java
core/trunk/src/test/resources/META-INF/conf-test/all-elements-file-3.x.xml
core/trunk/src/test/resources/META-INF/conf-test/parser-test-file-2.x.xml
core/trunk/src/test/resources/META-INF/conf-test/parser-test-file-3.x.xml
Log:
porting existing code to use the new XML parser
Added: core/trunk/src/main/etc/META-INF/config2to3.xslt
===================================================================
--- core/trunk/src/main/etc/META-INF/config2to3.xslt (rev 0)
+++ core/trunk/src/main/etc/META-INF/config2to3.xslt 2008-06-25 17:04:10 UTC (rev 6042)
@@ -0,0 +1,420 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
+ <xsl:output method="xml" indent="yes"/>
+
+ <xsl:template match="/">
+ <xsl:element name="jbosscache">
+ <xsl:call-template name="locking"/>
+ <xsl:call-template name="transaction"/>
+ <xsl:call-template name="serialization"/>
+ <xsl:call-template name="startup"/>
+ <xsl:call-template name="transport"/>
+ <xsl:apply-templates select="//attribute"/>
+ <!--<xsl:call-template name="invalidation"/> -->
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="//attribute"/>
+
+ <xsl:template name="locking">
+ <xsl:if
+ test="//attribute[@name='IsolationLevel'] |
//attribute[@name='LockAcquisitionTimeout'] |
//attribute[@name='LockParentForChildInsertRemove']">
+ <xsl:element name="locking">
+ <xsl:if test="//attribute[@name='IsolationLevel']">
+ <xsl:attribute name="isolationLevel">
+ <xsl:value-of
select="normalize-space(//attribute[@name='IsolationLevel'])"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if
test="//attribute[@name='LockAcquisitionTimeout']">
+ <xsl:attribute name="lockAcquisitionTimeout">
+ <xsl:value-of
select="normalize-space(//attribute[@name='LockAcquisitionTimeout'])"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if
test="//attribute[@name='LockParentForChildInsertRemove']">
+ <xsl:attribute name="lockParentForChildInsertRemove">
+ <xsl:value-of
select="normalize-space(//attribute[@name='LockParentForChildInsertRemove'])"/>
+ </xsl:attribute>
+ </xsl:if>
+ </xsl:element>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template name="transaction">
+ <xsl:if
+ test="//attribute[@name='TransactionManagerLookupClass'] |
//attribute[@name='SyncRollbackPhase'] |
//attribute[@name='SyncCommitPhase']">
+ <xsl:element name="transaction">
+ <xsl:if
test="//attribute[@name='TransactionManagerLookupClass']">
+ <xsl:attribute name="transactionManagerLookupClass">
+ <xsl:value-of
select="normalize-space(//attribute[@name='TransactionManagerLookupClass'])"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="//attribute[@name='SyncCommitPhase']">
+ <xsl:attribute name="syncCommitPhase">
+ <xsl:value-of
select="normalize-space(//attribute[@name='SyncCommitPhase'])"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if
test="//attribute[@name='SyncRollbackPhase']">
+ <xsl:attribute name="syncRollbackPhase">
+ <xsl:value-of
select="normalize-space(//attribute[@name='SyncRollbackPhase'])"/>
+ </xsl:attribute>
+ </xsl:if>
+ </xsl:element>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template name="serialization">
+ <xsl:if
+ test="//attribute[@name='ObjectInputStreamPoolSize'] |
//attribute[@name='ObjectOutputStreamPoolSize'] |
//attribute[@name='ReplicationVersion'] |
//attribute[@name='MarshallerClass'] |
//attribute[@name='UseLazyDeserialization'] |
//attribute[@name='UseRegionBasedMarshalling']">
+ <serialization>
+ <xsl:if
test="//attribute[@name='ObjectInputStreamPoolSize']">
+ <xsl:attribute name="objectInputStreamPoolSize">
+ <xsl:value-of
select="normalize-space(//attribute[@name='ObjectInputStreamPoolSize'])"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if
test="//attribute[@name='ObjectOutputStreamPoolSize']">
+ <xsl:attribute name="objectOutputStreamPoolSize">
+ <xsl:value-of
select="normalize-space(//attribute[@name='ObjectOutputStreamPoolSize'])"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if
test="//attribute[@name='ReplicationVersion']">
+ <xsl:attribute name="version">
+ <xsl:value-of
select="normalize-space(//attribute[@name='ReplicationVersion'])"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="//attribute[@name='MarshallerClass']">
+ <xsl:attribute name="marshallerClass">
+ <xsl:value-of
select="normalize-space(//attribute[@name='MarshallerClass'])"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if
test="//attribute[@name='UseLazyDeserialization']">
+ <xsl:attribute name="useLazyDeserialization">
+ <xsl:value-of
select="normalize-space(//attribute[@name='UseLazyDeserialization'])"/>
+ </xsl:attribute>
+ </xsl:if>
+
+ <xsl:if
test="//attribute[@name='UseRegionBasedMarshalling']">
+ <xsl:attribute name="useRegionBasedMarshalling">
+ <xsl:value-of
select="normalize-space(//attribute[@name='UseRegionBasedMarshalling'])"/>
+ </xsl:attribute>
+ </xsl:if>
+ </serialization>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="//attribute[@name='CacheMode']">
+ <xsl:if test="(normalize-space(.) = 'INVALIDATION_ASYNC') or
(normalize-space(.) = 'INVALIDATION_SYNC')">
+ <invalidation>
+ <xsl:if test="(normalize-space(.) =
'INVALIDATION_ASYNC')">
+ <xsl:element name="async">
+ <xsl:call-template name="asyncAttributes"/>
+ </xsl:element>
+ </xsl:if>
+ <xsl:if test="(normalize-space(.) =
'INVALIDATION_SYNC')">
+ <xsl:element name="sync">
+ <xsl:call-template name="syncAttributes"/>
+ </xsl:element>
+ </xsl:if>
+ </invalidation>
+ </xsl:if>
+ <xsl:if test="(normalize-space(.) = 'REPL_ASYNC') or
(normalize-space(.) = 'REPL_SYNC')">
+ <replication>
+ <xsl:if test="(normalize-space(.) = 'REPL_ASYNC')">
+ <xsl:element name="async">
+ <xsl:call-template name="asyncAttributes"/>
+ </xsl:element>
+ </xsl:if>
+ <xsl:if test="(normalize-space(.) = 'REPL_SYNC')">
+ <xsl:element name="sync">
+ <xsl:call-template name="syncAttributes"/>
+ </xsl:element>
+ </xsl:if>
+ <xsl:call-template name="buddy"/>
+ </replication>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template name="buddy">
+ <xsl:if
test="//attribute[@name='BuddyReplicationConfig']">
+ <buddy>
+ <xsl:if test="//buddyReplicationEnabled">
+ <xsl:attribute name="enabled">
+ <xsl:value-of select="//buddyReplicationEnabled"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="//buddyPoolName">
+ <xsl:attribute name="poolName">
+ <xsl:value-of select="//buddyPoolName"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="//buddyCommunicationTimeout">
+ <xsl:attribute name="communicationTimeout">
+ <xsl:value-of select="//buddyCommunicationTimeout"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="//autoDataGravitation | //dataGravitationRemoveOnFind |
//dataGravitationSearchBackupTrees">
+ <dataGravitation>
+ <xsl:if test="//autoDataGravitation">
+ <xsl:attribute name="auto">
+ <xsl:value-of select="//autoDataGravitation"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="//dataGravitationRemoveOnFind">
+ <xsl:attribute name="removeOnFind">
+ <xsl:value-of
select="//dataGravitationRemoveOnFind"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="//dataGravitationSearchBackupTrees">
+ <xsl:attribute name="searchBackupTrees">
+ <xsl:value-of
select="//dataGravitationSearchBackupTrees"/>
+ </xsl:attribute>
+ </xsl:if>
+ </dataGravitation>
+ </xsl:if>
+ <xsl:if test="//buddyLocatorProperties">
+ <locator>
+ <xsl:if test="//buddyLocatorClass">
+ <xsl:attribute name="class">
+ <xsl:value-of select="//buddyLocatorClass"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="//buddyLocatorProperties">
+ <properties>
+ <xsl:value-of
select="//buddyLocatorProperties"/>
+ </properties>
+ </xsl:if>
+ </locator>
+ </xsl:if>
+ </buddy>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template name="asyncAttributes">
+ <xsl:if test="//attribute[@name='UseReplQueue']">
+ <xsl:attribute name="useReplQueue">
+ <xsl:value-of
select="//attribute[@name='UseReplQueue']"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="//attribute[@name='ReplQueueInterval']">
+ <xsl:attribute name="replQueueInterval">
+ <xsl:value-of
select="//attribute[@name='ReplQueueInterval']"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="//attribute[@name='ReplQueueMaxElements']">
+ <xsl:attribute name="replQueueMaxElements">
+ <xsl:value-of
select="//attribute[@name='ReplQueueMaxElements']"/>
+ </xsl:attribute>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template name="syncAttributes">
+ <xsl:if test="//attribute[@name='SyncReplTimeout']">
+ <xsl:attribute name="replTimeout">
+ <xsl:value-of
select="//attribute[@name='SyncReplTimeout']"/>
+ </xsl:attribute>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template name="startup">
+ <xsl:if
+ test="//attribute[@name='FetchInMemoryState'] |
//attribute[@name='StateRetrievalTimeout'] |
//attribute[@name='InactiveOnStartup']">
+ <xsl:element name="startup">
+ <xsl:if
test="//attribute[@name='FetchInMemoryState']">
+ <xsl:attribute name="fetchInMemoryState">
+ <xsl:value-of
select="normalize-space(//attribute[@name='FetchInMemoryState'])"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if
test="//attribute[@name='StateRetrievalTimeout']">
+ <xsl:attribute name="stateRetrievalTimeout">
+ <xsl:value-of
select="normalize-space(//attribute[@name='StateRetrievalTimeout'])"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if
test="//attribute[@name='InactiveOnStartup']">
+ <xsl:attribute name="inactiveOnStartup">
+ <xsl:value-of
select="normalize-space(//attribute[@name='InactiveOnStartup'])"/>
+ </xsl:attribute>
+ </xsl:if>
+ </xsl:element>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template
match="//attribute[@name='ShutdownHookBehavior']">
+ <shutdown>
+ <xsl:attribute name="hookBehavior">
+ <xsl:value-of select="normalize-space(.)"/>
+ </xsl:attribute>
+ </shutdown>
+ </xsl:template>
+
+ <xsl:template
match="//attribute[@name='ExposeManagementStatistics']">
+ <jmxStatistics>
+ <xsl:attribute name="enabled">
+ <xsl:value-of select="normalize-space(.)"/>
+ </xsl:attribute>
+ </jmxStatistics>
+ </xsl:template>
+
+ <xsl:template
match="//attribute[@name='EvictionPolicyConfig']">
+ <eviction>
+ <xsl:if
test="./config/attribute[@name='wakeUpIntervalSeconds']">
+ <xsl:attribute name="wakeUpIntervalSeconds">
+ <xsl:value-of
select="normalize-space(./config/attribute[@name='wakeUpIntervalSeconds'])"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="./config/attribute[@name='policyClass'] |
./config/attribute[@name='policyClass']">
+ <defaults>
+ <xsl:if
test="./config/attribute[@name='policyClass']">
+ <xsl:attribute name="policyClass">
+ <xsl:value-of
select="normalize-space(./config/attribute[@name='policyClass'])"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if
test="./config/attribute[@name='eventQueueSize']">
+ <xsl:attribute name="eventQueueSize">
+ <xsl:value-of
select="normalize-space(./config/attribute[@name='eventQueueSize'])"/>
+ </xsl:attribute>
+ </xsl:if>
+ </defaults>
+ </xsl:if>
+ <xsl:if test="./config/region[@name='/_default_']">
+ <root>
+ <xsl:copy-of
select="./config/region[@name='/_default_']/*"/>
+ </root>
+ </xsl:if>
+ <xsl:for-each
select="./config/region[@name!='/_default_']">
+ <region>
+ <xsl:if test="@name">
+ <xsl:attribute name="name">
+ <xsl:value-of select="@name"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:copy-of select="./*"/>
+ </region>
+ </xsl:for-each>
+ </eviction>
+ </xsl:template>
+
+ <xsl:template
match="//attribute[@name='CacheLoaderConfiguration']">
+ <loaders>
+ <xsl:if test="./config/passivation">
+ <xsl:attribute name="passivation">
+ <xsl:value-of select="./config/passivation"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="./config/shared">
+ <xsl:attribute name="shared">
+ <xsl:value-of select="./config/shared"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="./config/preload">
+ <preload>
+ <xsl:call-template name="preloadTokenizer">
+ <xsl:with-param name="string"
select="./config/preload"/>
+ <xsl:with-param name="delimiter"
select="','"/>
+ </xsl:call-template>
+ </preload>
+ </xsl:if>
+ <xsl:for-each select="./config/cacheloader">
+ <loader>
+ <xsl:if test="./class">
+ <xsl:attribute name="class">
+ <xsl:value-of select="./class"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="./async">
+ <xsl:attribute name="async">
+ <xsl:value-of select="./async"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="./fetchPersistentState">
+ <xsl:attribute name="fetchPersistentState">
+ <xsl:value-of select="./fetchPersistentState"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="./ignoreModifications">
+ <xsl:attribute name="ignoreModifications">
+ <xsl:value-of select="./ignoreModifications"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="./purgeOnStartup">
+ <xsl:attribute name="purgeOnStartup">
+ <xsl:value-of select="./purgeOnStartup"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="./properties">
+ <xsl:copy-of select="./properties"/>
+ </xsl:if>
+ <xsl:if test="./singletonStore">
+ <singletonStore>
+ <xsl:if test="./singletonStore/enabled">
+ <xsl:attribute name="enabled">
+ <xsl:value-of
select="./singletonStore/enabled"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="./singletonStore/enabled">
+ <xsl:attribute name="enabled">
+ <xsl:value-of
select="./singletonStore/enabled"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="./singletonStore/class">
+ <xsl:attribute name="class">
+ <xsl:value-of
select="./singletonStore/class"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:copy-of select="./singletonStore/properties"/>
+ </singletonStore>
+ </xsl:if>
+ </loader>
+ </xsl:for-each>
+ </loaders>
+ </xsl:template>
+
+ <xsl:template name="preloadTokenizer">
+ <xsl:param name="string"/>
+ <xsl:param name="delimiter" select="' '"/>
+ <xsl:choose>
+ <xsl:when test="$delimiter and contains($string, $delimiter)">
+ <node>
+ <xsl:attribute name="fqn">
+ <xsl:value-of
select="substring-before($string,$delimiter)"/>
+ </xsl:attribute>
+ </node>
+ <xsl:call-template name="preloadTokenizer">
+ <xsl:with-param name="string"
select="substring-after($string,$delimiter)"/>
+ <xsl:with-param name="delimiter"
select="$delimiter"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <node>
+ <xsl:attribute name="fqn">
+ <xsl:value-of select="$string"/>
+ </xsl:attribute>
+ </node>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <xsl:template name="transport">
+ <xsl:if
+ test="//attribute[@name='ClusterName'] |
//attribute[@name='MultiplexerStack'] |
//attribute[@name='ClusterConfig']">
+ <transport>
+ <xsl:if test="//attribute[@name='ClusterName']">
+ <xsl:attribute name="clusterName">
+ <xsl:value-of
select="normalize-space(//attribute[@name='ClusterName'])"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if
test="//attribute[@name='MultiplexerStack']">
+ <xsl:attribute name="multiplexerStack">
+ <xsl:value-of
select="normalize-space(//attribute[@name='MultiplexerStack'])"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="//attribute[@name='ClusterConfig']">
+ <jgroupsConfig>
+ <xsl:copy-of
select="//attribute[@name='ClusterConfig']/config/*"/>
+ </jgroupsConfig>
+ </xsl:if>
+ </transport>
+ </xsl:if>
+ </xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file
Modified: core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-06-25 15:57:45
UTC (rev 6041)
+++ core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-06-25 17:04:10
UTC (rev 6042)
@@ -8,7 +8,7 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
import org.jboss.cache.factories.ComponentFactory;
import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.invocation.CacheInvocationDelegate;
@@ -62,7 +62,7 @@
public Cache<K, V> createCache(String configFileName, boolean start) throws
ConfigurationException
{
- XmlConfigurationParserOld parser = new XmlConfigurationParserOld();
+ XmlConfigurationParser2x parser = new XmlConfigurationParser2x();
Configuration c = parser.parseFile(configFileName);
return createCache(c, start);
}
@@ -141,14 +141,14 @@
public Cache<K, V> createCache(InputStream is) throws ConfigurationException
{
- XmlConfigurationParserOld parser = new XmlConfigurationParserOld();
+ XmlConfigurationParser2x parser = new XmlConfigurationParser2x();
Configuration c = parser.parseStream(is);
return createCache(c);
}
public Cache<K, V> createCache(InputStream is, boolean start) throws
ConfigurationException
{
- XmlConfigurationParserOld parser = new XmlConfigurationParserOld();
+ XmlConfigurationParser2x parser = new XmlConfigurationParser2x();
Configuration c = parser.parseStream(is);
return createCache(c, start);
}
Modified: core/trunk/src/main/java/org/jboss/cache/config/Configuration.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/Configuration.java 2008-06-25 15:57:45
UTC (rev 6041)
+++ core/trunk/src/main/java/org/jboss/cache/config/Configuration.java 2008-06-25 17:04:10
UTC (rev 6042)
@@ -7,7 +7,8 @@
package org.jboss.cache.config;
import org.jboss.cache.Version;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
+import org.jboss.cache.config.parsing.JGroupsStackParser;
import org.jboss.cache.factories.annotations.NonVolatile;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.marshall.Marshaller;
@@ -30,6 +31,7 @@
private Marshaller marshaller;
+ private JGroupsStackParser jGroupsStackParser = new JGroupsStackParser();
public void setCacheMarshaller(Marshaller instance)
{
@@ -207,7 +209,7 @@
*/
public void setClusterConfig(Element config)
{
- setClusterConfig(XmlConfigurationParserOld.parseClusterConfigXml(config));
+ setClusterConfig(jGroupsStackParser.parseClusterConfigXml(config));
}
public void setClusterName(String clusterName)
Modified: core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java 2008-06-25
15:57:45 UTC (rev 6041)
+++ core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -36,14 +36,8 @@
*/
private static final long serialVersionUID = -7979639000026975201L;
- public static final String WAKEUP_INTERVAL_SECONDS =
"wakeUpIntervalSeconds";
-
public static final int WAKEUP_DEFAULT = 5;
- public static final String EVENT_QUEUE_SIZE = "eventQueueSize";
-
- public static final String EVICTION_POLICY_CLASS = "policyClass";
-
public static final int EVENT_QUEUE_SIZE_DEFAULT = 200000;
private String defaultEvictionPolicyClass;
@@ -132,7 +126,7 @@
{
if (evictionRegionConfigs == null)
{
- return new ArrayList<EvictionRegionConfig>(1);
+ evictionRegionConfigs = new ArrayList<EvictionRegionConfig>(1);
}
return evictionRegionConfigs;
}
@@ -174,6 +168,7 @@
{
testImmutability("WakeupInterval");
this.wakeupInterval = wakeupInterval;
+ this.wakeupIntervalSeconds = (int)wakeupInterval/1000;
}
/**
@@ -193,7 +188,7 @@
{
testImmutability("wakeupIntervalSeconds");
this.wakeupIntervalSeconds = wakeupIntervalSeconds;
- setWakeupInterval(wakeupIntervalSeconds * 1000);
+ this.wakeupInterval = wakeupIntervalSeconds * 1000;
}
public boolean equals(Object o)
Modified: core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionConfig.java 2008-06-25
15:57:45 UTC (rev 6041)
+++ core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionConfig.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -36,8 +36,6 @@
public static final String NAME = "name";
public static final String REGION = "region";
- public static final String REGION_POLICY_CLASS = "policyClass";
- public static final String EVENT_QUEUE_SIZE = "eventQueueSize";
private Fqn regionFqn;
@Dynamic
@@ -131,7 +129,10 @@
if (obj instanceof EvictionRegionConfig)
{
EvictionRegionConfig other = (EvictionRegionConfig) obj;
- return Util.safeEquals(this.regionFqn, other.regionFqn);
+ boolean equalRegions = Util.safeEquals(this.regionFqn, other.regionFqn);
+ boolean equalConfigurations = Util.safeEquals(this.evictionPolicyConfig,
other.evictionPolicyConfig);
+ boolean equalEventQueuSizes = this.getEventQueueSize() ==
other.getEventQueueSize();
+ return equalRegions && equalConfigurations &&
equalConfigurations;
}
return false;
}
Modified: core/trunk/src/main/java/org/jboss/cache/config/MissingPolicyException.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/MissingPolicyException.java 2008-06-25
15:57:45 UTC (rev 6041)
+++ core/trunk/src/main/java/org/jboss/cache/config/MissingPolicyException.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.config;
-public class MissingPolicyException extends RuntimeException
+public class MissingPolicyException extends ConfigurationException
{
/** The serialVersionUID */
Deleted:
core/trunk/src/main/java/org/jboss/cache/config/parsing/BuddyReplicationElementParser.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/config/parsing/BuddyReplicationElementParser.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/main/java/org/jboss/cache/config/parsing/BuddyReplicationElementParser.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -1,56 +0,0 @@
-package org.jboss.cache.config.parsing;
-
-import org.jboss.cache.config.BuddyReplicationConfig;
-import org.w3c.dom.Element;
-
-import java.util.Properties;
-
-/**
- * Utility class for parsing 'buddyReplication' element in the .xml configuration
file.
- *
- * @author Mircea.Markus(a)jboss.com
- * @since 3.0
- */
-public class BuddyReplicationElementParser extends XmlParserBase
-{
- public BuddyReplicationConfig parseBuddyReplicationElement(Element element)
- {
- BuddyReplicationConfig brc = new BuddyReplicationConfig();
- String enabled = element.getAttribute("enabled");
- if (existsAttribute(enabled)) brc.setEnabled(getBoolean(enabled));
- String buddyPoolName = element.getAttribute("buddyPoolName");
- if (existsAttribute(buddyPoolName)) brc.setBuddyPoolName(buddyPoolName);
- String buddyCommunicationTimeout =
element.getAttribute("buddyCommunicationTimeout");
- if (existsAttribute(buddyCommunicationTimeout))
- brc.setBuddyCommunicationTimeout(getInt(buddyCommunicationTimeout));
-
- parseDataGravitationElement(getSingleElement("dataGravitation", element),
brc);
- BuddyReplicationConfig.BuddyLocatorConfig blc =
parseBuddyLocatorConfig(getSingleElement("buddyLocator", element));
- brc.setBuddyLocatorConfig(blc);
- return brc;
- }
-
- private BuddyReplicationConfig.BuddyLocatorConfig parseBuddyLocatorConfig(Element
element)
- {
- if (element == null) return null;
- BuddyReplicationConfig.BuddyLocatorConfig result = new
BuddyReplicationConfig.BuddyLocatorConfig();
- String buddyLocatorClass = element.getAttribute("class");
- if (existsAttribute(buddyLocatorClass))
result.setBuddyLocatorClass(buddyLocatorClass);
- Properties props = null;
- props = XmlConfigHelper.readPropertiesContents(element, "properties");
- result.setBuddyLocatorClass(buddyLocatorClass);
- result.setBuddyLocatorProperties(props);
- return result;
- }
-
- private void parseDataGravitationElement(Element element, BuddyReplicationConfig brc)
- {
- if (element == null) return;
- String auto = element.getAttribute("auto");
- if (existsAttribute(auto)) brc.setAutoDataGravitation(getBoolean(auto));
- String removeOnFind = element.getAttribute("removeOnFind");
- if (existsAttribute(removeOnFind))
brc.setDataGravitationRemoveOnFind(getBoolean(removeOnFind));
- String searchBackupTrees = element.getAttribute("searchBackupTrees");
- if (existsAttribute(searchBackupTrees))
brc.setDataGravitationSearchBackupTrees(getBoolean(searchBackupTrees));
- }
-}
Modified:
core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlParser.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlParser.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlParser.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -73,7 +73,7 @@
private static final Log log = LogFactory.getLog(CacheConfigsXmlParser.class);
- private final XmlConfigurationParserOld parser = new XmlConfigurationParserOld();
+ private final XmlConfigurationParser2x parser = new XmlConfigurationParser2x();
public Map<String, Configuration> parseConfigs(String fileName) throws
CloneNotSupportedException
{
Deleted:
core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheLoadersElementParser.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheLoadersElementParser.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheLoadersElementParser.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -1,108 +0,0 @@
-package org.jboss.cache.config.parsing;
-
-import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.ConfigurationException;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import java.util.Properties;
-
-/**
- * Utility class for parsing the 'caceheloaders' element in the .xml
configuration file.
- *
- * @author Mircea.Markus(a)jboss.com
- * @since 3.0
- */
-public class CacheLoadersElementParser extends XmlParserBase
-{
-
- public CacheLoaderConfig parseCacheLoadersElement(Element element)
- {
- CacheLoaderConfig cacheLoaderConfig = new CacheLoaderConfig();
- String passivation = element.getAttribute("passivation");
- if (existsAttribute(passivation))
cacheLoaderConfig.setPassivation(getBoolean(passivation));
- String shared = element.getAttribute("shared");
- if (existsAttribute(shared)) cacheLoaderConfig.setShared(getBoolean(shared));
- String preload = getPreloadString(getSingleElement("preload", element));
- if (preload != null) cacheLoaderConfig.setPreload(preload);
-
- NodeList cacheLoaderNodes = element.getElementsByTagName("cacheLoader");
- for (int i = 0; i < cacheLoaderNodes.getLength(); i++)
- {
- Element indivElement = (Element) cacheLoaderNodes.item(i);
- CacheLoaderConfig.IndividualCacheLoaderConfig iclc =
parseIndividualCacheLoaderConfig(indivElement);
- cacheLoaderConfig.addIndividualCacheLoaderConfig(iclc);
- }
-
- return cacheLoaderConfig;
- }
-
- private CacheLoaderConfig.IndividualCacheLoaderConfig
parseIndividualCacheLoaderConfig(Element indivElement)
- {
- CacheLoaderConfig.IndividualCacheLoaderConfig iclc = new
CacheLoaderConfig.IndividualCacheLoaderConfig();
-
- String async = indivElement.getAttribute("async");
- if (existsAttribute(async)) iclc.setAsync(getBoolean(async));
- String fetchPersistentState =
indivElement.getAttribute("fetchPersistentState");
- if (existsAttribute(fetchPersistentState))
iclc.setFetchPersistentState(getBoolean(fetchPersistentState));
- String ignoreModifications =
indivElement.getAttribute("ignoreModifications");
- if (existsAttribute(ignoreModifications))
iclc.setIgnoreModifications(getBoolean(ignoreModifications));
- String purgeOnStartup = indivElement.getAttribute("purgeOnStartup");
- if (existsAttribute(purgeOnStartup))
iclc.setPurgeOnStartup(getBoolean(purgeOnStartup));
- String clClass = indivElement.getAttribute("class");
- if (!existsAttribute(clClass)) throw new ConfigurationException("Missing
'class' attribute for cache loader configuration");
- iclc.setClassName(clClass);
- iclc.setProperties(XmlConfigHelper.readPropertiesContents(indivElement,
"properties"));
- CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig ssc =
parseSingletonStoreConfig(indivElement);
- if (ssc != null)
- {
- iclc.setSingletonStoreConfig(ssc);
- }
- return iclc;
- }
-
- private String getPreloadString(Element preloadElement)
- {
- if (preloadElement == null) return null; //might be no preload
- NodeList nodesToPreload = preloadElement.getElementsByTagName("node");
- StringBuffer result = new StringBuffer();
- for (int i = 0; i < nodesToPreload.getLength(); i++)
- {
- Element node = (Element) nodesToPreload.item(i);
- String fqn2preload = node.getAttribute("fqn");
- if (!existsAttribute(fqn2preload)) throw new
ConfigurationException("Missing 'fqn' attribute in 'preload\\norde'
tag");
- if (i > 0) result.append(",");
- result.append(fqn2preload);
- }
- //no elements defined for preload so by default load the root
- if (nodesToPreload.getLength() == 0)
- {
- result.append("");
- }
- return result.toString();
- }
-
- static CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig
parseSingletonStoreConfig(Element cacheLoaderelement)
- {
- /* singletonStore element can only appear once in a cacheloader, so we just take
the first one ignoring any
- subsequent definitions in cacheloader element*/
- Node singletonStoreNode =
cacheLoaderelement.getElementsByTagName("singletonStore").item(0);
- if (singletonStoreNode != null && singletonStoreNode.getNodeType() ==
Node.ELEMENT_NODE)
- {
- Element singletonStoreElement = (Element) singletonStoreNode;
- boolean singletonStoreEnabled =
XmlConfigHelper.readBooleanContents(singletonStoreElement, "enabled");
- String singletonStoreClass =
XmlConfigHelper.readStringContents(singletonStoreElement, "class");
- Properties singletonStoreproperties;
- singletonStoreproperties =
XmlConfigHelper.readPropertiesContents(singletonStoreElement, "properties");
- CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig ssc = new
CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig();
- ssc.setSingletonStoreEnabled(singletonStoreEnabled);
- ssc.setSingletonStoreClass(singletonStoreClass);
- ssc.setSingletonStoreproperties(singletonStoreproperties);
-
- return ssc;
- }
-
- return null;
- }
-}
Added: core/trunk/src/main/java/org/jboss/cache/config/parsing/ConfigFilesConvertor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/ConfigFilesConvertor.java
(rev 0)
+++
core/trunk/src/main/java/org/jboss/cache/config/parsing/ConfigFilesConvertor.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -0,0 +1,53 @@
+package org.jboss.cache.config.parsing;
+
+import org.w3c.dom.Document;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.File;
+
+/**
+ * Class used for converting a config file from from 2.x version to 3.x verison.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+public class ConfigFilesConvertor
+{
+ static Document document;
+
+
+ public static void main(String[] argv) throws Exception
+ {
+ if (argv.length != 2)
+ {
+ System.err.println("Usage: java Stylizer stylesheet xmlfile");
+ System.exit(1);
+ }
+
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+
+ //factory.setNamespaceAware(true);
+ //factory.setValidating(true);
+ File stylesheet = new File(argv[0]);
+ File datafile = new File(argv[1]);
+
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ document = builder.parse(datafile);
+
+ // Use a Transformer for output
+ TransformerFactory tFactory = TransformerFactory.newInstance();
+ StreamSource stylesource = new StreamSource(stylesheet);
+ Transformer transformer = tFactory.newTransformer(stylesource);
+
+ DOMSource source = new DOMSource(document);
+ StreamResult result = new StreamResult(System.out);
+ transformer.transform(source, result);
+ }
+}
\ No newline at end of file
Deleted:
core/trunk/src/main/java/org/jboss/cache/config/parsing/EvictionElementParser.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/config/parsing/EvictionElementParser.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/main/java/org/jboss/cache/config/parsing/EvictionElementParser.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -1,110 +0,0 @@
-package org.jboss.cache.config.parsing;
-
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.jboss.cache.config.EvictionConfig;
-import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.config.MissingPolicyException;
-import org.jboss.cache.config.EvictionPolicyConfig;
-import org.jboss.cache.eviction.EvictionPolicy;
-import org.jboss.cache.util.Util;
-import org.jboss.cache.RegionManager;
-
-import java.util.List;
-import java.util.ArrayList;
-
-/**
- * Knows how to parse the <b>eviction</b> element uder a parser.
- *
- * @author Mircea.Markus(a)jboss.com
- * @since 3.0
- */
-public class EvictionElementParser extends XmlParserBase
-{
- public EvictionConfig getEvictionConfig(Element evictionElement)
- {
- EvictionConfig evictionConfig = new EvictionConfig();
- String wakeUpInterval = evictionElement.getAttribute("wakeUpInterval");
- if (existsAttribute(wakeUpInterval))
evictionConfig.setWakeupInterval(getInt(wakeUpInterval));
- String defaultPolicyClass =
evictionElement.getAttribute("defaultPolicyClass");
- if (existsAttribute(defaultPolicyClass))
evictionConfig.setDefaultEvictionPolicyClass(defaultPolicyClass);
- String defaultEventQueueSize =
evictionElement.getAttribute("defaultEventQueueSize");
- if (existsAttribute(defaultEventQueueSize))
evictionConfig.setDefaultEventQueueSize(getInt(defaultEventQueueSize));
- List<EvictionRegionConfig> evictionRegionConfigs = new
ArrayList<EvictionRegionConfig>(3);
- Element defaultRegion = getSingleElement("default", evictionElement);
- if (defaultRegion != null)
- {
- EvictionRegionConfig erc = getEvictionRegionConfig(defaultRegion,
defaultPolicyClass, getInt(defaultEventQueueSize));
- erc.setRegionName(RegionManager.DEFAULT_REGION.toString());
- evictionRegionConfigs.add(erc);
- }
- NodeList regions = evictionElement.getElementsByTagName("region");
- for (int i = 0; i < regions.getLength(); i++)
- {
- Element regionConfig = (Element) regions.item(i);
- EvictionRegionConfig erc = getEvictionRegionConfig(regionConfig,
defaultPolicyClass, getInt(defaultEventQueueSize));
- evictionRegionConfigs.add(erc);
- }
- evictionConfig.setEvictionRegionConfigs(evictionRegionConfigs);
- return evictionConfig;
- }
-
- private EvictionRegionConfig getEvictionRegionConfig(Element element, String
defaultPolicyClass, int defaultEventQueueSize)
- {
- EvictionRegionConfig erc = new EvictionRegionConfig();
- erc.setRegionName(element.getAttribute("name"));
- String queueSize = element.getAttribute("eventQueueSize");
- if (existsAttribute(queueSize))
- {
- erc.setEventQueueSize(getInt(queueSize));
- }
- else
- {
- erc.setEventQueueSize(defaultEventQueueSize);
- }
- String policyClass = element.getAttribute("policyClass");
- if (!existsAttribute(policyClass))
- {
- if (defaultPolicyClass == null)
- {
- throw new MissingPolicyException("There is no Eviction Policy Class
specified on the region or for the entire cache!");
- }
- else
- {
- policyClass = defaultPolicyClass;
- }
- }
- EvictionPolicy policy;
- try
- {
- policy = (EvictionPolicy) Util.loadClass(policyClass).newInstance();
- }
- catch (Exception e)
- {
- throw new RuntimeException("Eviction class is not properly loaded in
classloader", e);
- }
-
- EvictionPolicyConfig epc;
- try
- {
- epc = policy.getEvictionConfigurationClass().newInstance();
- }
- catch (Exception e)
- {
- throw new RuntimeException("Failed to instantiate eviction configuration of
class " +
- policy.getEvictionConfigurationClass(), e);
- }
- parseEvictionPolicyConfig(element, epc);
- erc.setEvictionPolicyConfig(epc);
- return erc;
- }
-
- public static void parseEvictionPolicyConfig(Element element, EvictionPolicyConfig
target)
- {
- target.reset();
- ParsedAttributes attributes = XmlConfigHelper.extractAttributes(element);
- XmlConfigHelper.setValues(target, attributes.stringAttribs, false);
- XmlConfigHelper.setValues(target, attributes.xmlAttribs, true);
- target.validate();
- }
-}
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/JGroupsStackParser.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/config/parsing/JGroupsStackParser.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/main/java/org/jboss/cache/config/parsing/JGroupsStackParser.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -14,14 +14,12 @@
*/
public class JGroupsStackParser
{
-
- //todo - further refine in smaller methods and make not-static
/**
* Parses the cluster config which is used to start a JGroups channel
*
* @param config an old-style JGroups protocol config String
*/
- public static String parseClusterConfigXml(Element config)
+ public String parseClusterConfigXml(Element config)
{
StringBuffer buffer = new StringBuffer();
NodeList stack = config.getChildNodes();
@@ -38,33 +36,43 @@
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(')');
- }
+ processAttributes(buffer, tag);
buffer.append(':');
}
// Remove the trailing ':'
buffer.setLength(buffer.length() - 1);
return buffer.toString();
}
+
+ private void processAttributes(StringBuffer buffer, Element tag)
+ {
+ 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);
+ processSingleAttribute(buffer, attr);
+ if (a < attrLength - 1)
+ {
+ buffer.append(';');
+ }
+ }
+ if (attrLength > 0)
+ {
+ buffer.append(')');
+ }
+ }
+
+ private void processSingleAttribute(StringBuffer buffer, Attr attr)
+ {
+ String name = attr.getName();
+ String value = attr.getValue();
+ buffer.append(name);
+ buffer.append('=');
+ buffer.append(value);
+ }
}
Modified:
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -3,6 +3,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.config.*;
+import org.jboss.cache.config.parsing.element.BuddyElementParser;
+import org.jboss.cache.config.parsing.element.LoadersElementParser;
+import org.jboss.cache.config.parsing.element.EvictionElementParser;
import org.jboss.cache.lock.IsolationLevel;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -79,8 +82,7 @@
configureShutdown(getSingleElement("shutdown"));
configureJmxStatistics(getSingleElement("jmxStatistics"));
configureEviction(getSingleElement("eviction"));
- configureCacheLoaders(getSingleElement("cacheLoaders"));
- configureBuddyReplication(getSingleElement("buddyReplication"));
+ configureCacheLoaders(getSingleElement("loaders"));
configureCustomInterceptors(getSingleElement("customInterceptors"));
return config;
}
@@ -144,16 +146,16 @@
private void configureBuddyReplication(Element element)
{
if (element == null) return;//buddy config might not exist, expect that
- BuddyReplicationElementParser buddyElementParser = new
BuddyReplicationElementParser();
- BuddyReplicationConfig brConfig =
buddyElementParser.parseBuddyReplicationElement(element);
+ BuddyElementParser buddyElementParser = new BuddyElementParser();
+ BuddyReplicationConfig brConfig = buddyElementParser.parseBuddyElement(element);
config.setBuddyReplicationConfig(brConfig);
}
private void configureCacheLoaders(Element element)
{
if (element == null) return; //null cache loaders are allowed
- CacheLoadersElementParser clElementParser = new CacheLoadersElementParser();
- CacheLoaderConfig cacheLoaderConfig =
clElementParser.parseCacheLoadersElement(element);
+ LoadersElementParser clElementParser = new LoadersElementParser();
+ CacheLoaderConfig cacheLoaderConfig =
clElementParser.parseLoadersElement(element);
config.setCacheLoaderConfig(cacheLoaderConfig);
}
@@ -161,10 +163,9 @@
{
if (evictionElement == null) return; //no eviction might be configured
EvictionElementParser evictionElementParser = new EvictionElementParser();
-
config.setEvictionConfig(evictionElementParser.getEvictionConfig(evictionElement));
+
config.setEvictionConfig(evictionElementParser.parseEvictionElement(evictionElement));
}
-
private void configureJmxStatistics(Element element)
{
if (element == null) return; //might not be specified
@@ -183,15 +184,13 @@
{
String clusterName = element.getAttribute("clusterName");
config.setClusterName(clusterName);
- Element multiplexer = getSingleElement("multiplexer", element);
- if (multiplexer != null)
- {
- config.setMultiplexerStack(multiplexer.getAttribute("stack"));
- }
+ String multiplexerStack = element.getAttribute("multiplexerStack");
+ if (existsAttribute(multiplexerStack))
config.setMultiplexerStack(multiplexerStack);
Element clusterConfig = getSingleElement("jgroupsConfig", element);
if (clusterConfig != null)
{
- String clusterConfigStr =
JGroupsStackParser.parseClusterConfigXml(clusterConfig);
+ JGroupsStackParser stackParser = new JGroupsStackParser();
+ String clusterConfigStr = stackParser.parseClusterConfigXml(clusterConfig);
config.setClusterConfig(clusterConfigStr);
}
}
@@ -239,6 +238,7 @@
config.setCacheMode(Configuration.CacheMode.REPL_SYNC);
configureSyncMode(getSingleElement("sync", element));
}
+ configureBuddyReplication(getSingleElement("buddy", element));
}
private void configureSyncMode(Element element)
Copied:
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java
(from rev 5995,
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParserOld.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java
(rev 0)
+++
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -0,0 +1,560 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at
gnu.org.
+ */
+package org.jboss.cache.config.parsing;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.buddyreplication.NextMemberBuddyLocator;
+import org.jboss.cache.config.BuddyReplicationConfig;
+import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig;
+import org.jboss.cache.config.CacheLoaderConfig;
+import
org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.ConfigurationException;
+import org.jboss.cache.config.EvictionConfig;
+import org.jboss.cache.config.EvictionPolicyConfig;
+import org.jboss.cache.config.EvictionRegionConfig;
+import org.jboss.cache.config.MissingPolicyException;
+import org.jboss.cache.eviction.EvictionPolicy;
+import org.jboss.cache.util.Util;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
+import org.jboss.cache.config.parsing.element.EvictionElementParser;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
+
+/**
+ * Reads in XMLconfiguration files and spits out a {@link
org.jboss.cache.config.Configuration} object. When deployed as a
+ * JBoss MBean, this role is performed by the JBoss Microcontainer. This class is only
used internally in unit tests
+ * or within {@link org.jboss.cache.CacheFactory} implementations for standalone JBoss
Cache usage.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani
(manik(a)jboss.org)</a>
+ * @author <a href="mailto:galder.zamarreno@jboss.com">Galder
Zamarreno</a>
+ * @since 2.00.
+ * @deprecated
+ */
+public class XmlConfigurationParser2x
+{
+ private static final Log log = LogFactory.getLog(XmlConfigurationParser2x.class);
+
+ public static final String ATTR = "attribute";
+ public static final String NAME = "name";
+
+ /**
+ * Parses an XML file and returns a new configuration. This method attempts to look
for the file name passed in on
+ * the classpath. If not found, it will search for the file on the file system
instead, treating the name as an
+ * absolute path.
+ *
+ * @param filename the name of the XML file to parse.
+ * @return a configured Configuration object representing the configuration in the
file
+ */
+ public Configuration parseFile(String filename)
+ {
+ InputStream is = getAsInputStreamFromClassLoader(filename);
+ if (is == null)
+ {
+ if (log.isDebugEnabled())
+ log.debug("Unable to find configuration file " + filename + "
in classpath; searching for this file on the filesystem instead.");
+ try
+ {
+ is = new FileInputStream(filename);
+ }
+ catch (FileNotFoundException e)
+ {
+ throw new ConfigurationException("Unable to find config file " +
filename + " either in classpath or on the filesystem!", e);
+ }
+ }
+
+ return parseStream(is);
+ }
+
+ /**
+ * Parses an input stream containing XML text and returns a new configuration.
+ *
+ * @param stream input stream to parse. SHould not be null.
+ * @return a configured Configuration object representing the configuration in the
stream
+ * @since 2.1.0
+ */
+ public Configuration parseStream(InputStream stream)
+ {
+ // loop through all elements in XML.
+ Element root = XmlConfigHelper.getDocumentRoot(stream);
+ Element mbeanElement = getMBeanElement(root);
+
+ return parseConfiguration(mbeanElement);
+ }
+
+ public Configuration parseConfiguration(Element configurationRoot)
+ {
+ ParsedAttributes attributes =
XmlConfigHelper.extractAttributes(configurationRoot);
+
+ // Deal with legacy attributes we no longer support
+ handleRemovedAttributes(attributes);
+
+ // Deal with legacy attributes that we renamed or otherwise altered
+ handleRenamedAttributes(attributes);
+
+ Configuration c = new Configuration();
+ XmlConfigHelper.setValues(c, attributes.stringAttribs, false);
+ // Special handling for XML elements -- we hard code the parsing
+ setXmlValues(c, attributes.xmlAttribs);
+
+ return c;
+ }
+
+ /**
+ * Check for and remove any attributes that were supported in the
+ * 1.x releases and no longer are. Log a WARN or throw a
+ * {@link ConfigurationException} if any are found. Which is done depends
+ * on the attribute:
+ * <p/>
+ * <ul>
+ * <li><i>MultiplexerService</i> -- throws an Exception</li>
+ * <li><i>ServiceName</i> -- logs a WARN</li>
+ * </ul>
+ *
+ * @param attributes
+ */
+ protected void handleRemovedAttributes(ParsedAttributes attributes)
+ {
+ String evictionPolicy =
attributes.stringAttribs.remove("EvictionPolicyClass");
+ if (evictionPolicy != null)
+ {
+ throw new ConfigurationException("XmlConfigurationParser does not " +
+ "support the JBC 1.x attribute EvictionPolicyClass. Set the default
" +
+ "eviction policy via the policyClass element in the EvictionConfig
section");
+ }
+ String multiplexerService =
attributes.stringAttribs.remove("MultiplexerService");
+ if (multiplexerService != null)
+ {
+ throw new ConfigurationException("XmlConfigurationParser does not " +
+ "support the JBC 1.x attribute MultiplexerService. Inject the "
+
+ "multiplexer directly using
Configuration.getRuntimeConfig().setMuxChannelFactory()");
+ }
+ String serviceName = attributes.stringAttribs.remove("ServiceName");
+ if (serviceName != null)
+ {
+ log.warn("XmlConfigurationParser does not support the deprecated " +
+ "attribute ServiceName. If JMX registration is needed, " +
+ "register a CacheJmxWrapper or PojoCacheJmxWrapper in " +
+ "JMX with the desired name");
+ }
+ }
+
+ /**
+ * Check for any attributes that were supported in the
+ * 1.x releases but whose name has changed. Log a WARN if any are found, but
+ * convert the attribute to the new name.
+ * <p/>
+ * <ul>
+ * <li><i>UseMbean</i> becomes
<i>ExposeManagementStatistics</i></li>
+ * </ul>
+ *
+ * @param attributes
+ */
+ private void handleRenamedAttributes(ParsedAttributes attributes)
+ {
+ String keepStats =
attributes.stringAttribs.remove("UseInterceptorMbeans");
+ if (keepStats != null &&
attributes.stringAttribs.get("ExposeManagementStatistics") == null)
+ {
+ log.warn("Found non-existent JBC 1.x attribute
'UseInterceptorMbeans' and replaced " +
+ "with 'ExposeManagementStatistics'. Please update your config
" +
+ "to use the new attribute name");
+ attributes.stringAttribs.put("ExposeManagementStatistics",
keepStats);
+ }
+ Element clc = attributes.xmlAttribs.remove("CacheLoaderConfiguration");
+ if (clc != null && attributes.xmlAttribs.get("CacheLoaderConfig")
== null)
+ {
+ log.warn("Found non-existent JBC 1.x attribute
'CacheLoaderConfiguration' and replaced " +
+ "with 'CacheLoaderConfig'. Please update your config "
+
+ "to use the new attribute name");
+ attributes.xmlAttribs.put("CacheLoaderConfig", clc);
+ }
+ }
+
+ protected InputStream getAsInputStreamFromClassLoader(String filename)
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ InputStream is = cl == null ? null : cl.getResourceAsStream(filename);
+ if (is == null)
+ {
+ // check system class loader
+ is = getClass().getClassLoader().getResourceAsStream(filename);
+ }
+ return is;
+ }
+
+ protected Element getMBeanElement(Element root)
+ {
+ // This is following JBoss convention.
+ NodeList list = root.getElementsByTagName(XmlConfigHelper.ROOT);
+ if (list == null) throw new ConfigurationException("Can't find " +
XmlConfigHelper.ROOT + " tag");
+
+ if (list.getLength() > 1) throw new ConfigurationException("Has multiple
" + XmlConfigHelper.ROOT + " tag");
+
+ Node node = list.item(0);
+ Element element;
+ if (node.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
+ {
+ element = (Element) node;
+ }
+ else
+ {
+ throw new ConfigurationException("Can't find " +
XmlConfigHelper.ROOT + " element");
+ }
+ return element;
+ }
+
+ protected void setXmlValues(Configuration conf, Map<String, Element> attribs)
+ {
+ for (Entry<String, Element> entry : attribs.entrySet())
+ {
+ String propname = entry.getKey();
+ if ("BuddyReplicationConfiguration".equals(propname)
+ || "BuddyReplicationConfig".equals(propname))
+ {
+ BuddyReplicationConfig brc = parseBuddyReplicationConfig(entry.getValue());
+ conf.setBuddyReplicationConfig(brc);
+ }
+ else if ("CacheLoaderConfiguration".equals(propname)
+ || "CacheLoaderConfig".equals(propname))
+ {
+ CacheLoaderConfig clc = parseCacheLoaderConfig(entry.getValue());
+ conf.setCacheLoaderConfig(clc);
+ }
+ else if ("EvictionPolicyConfiguration".equals(propname)
+ || "EvictionPolicyConfig".equals(propname))
+ {
+ EvictionConfig ec = parseEvictionConfig(entry.getValue());
+ conf.setEvictionConfig(ec);
+ }
+ else if ("ClusterConfig".equals(propname))
+ {
+ String jgc = parseClusterConfigXml(entry.getValue());
+ conf.setClusterConfig(jgc);
+ }
+ else
+ {
+ throw new ConfigurationException("Unknown configuration element " +
propname);
+ }
+ }
+ }
+
+ private static BuddyReplicationConfig parseBuddyReplicationConfig(Element element)
+ {
+ BuddyReplicationConfig brc = new BuddyReplicationConfig();
+ brc.setEnabled(XmlConfigHelper.readBooleanContents(element,
"buddyReplicationEnabled"));
+ brc.setDataGravitationRemoveOnFind(XmlConfigHelper.readBooleanContents(element,
"dataGravitationRemoveOnFind", true));
+
brc.setDataGravitationSearchBackupTrees(XmlConfigHelper.readBooleanContents(element,
"dataGravitationSearchBackupTrees", true));
+ brc.setAutoDataGravitation(brc.isEnabled() &&
XmlConfigHelper.readBooleanContents(element, "autoDataGravitation", false));
+
+ String strBuddyCommunicationTimeout = XmlConfigHelper.readStringContents(element,
"buddyCommunicationTimeout");
+ try
+ {
+
brc.setBuddyCommunicationTimeout(Integer.parseInt(strBuddyCommunicationTimeout));
+ }
+ catch (Exception e)
+ {
+ }
+ finally
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Using buddy communication timeout of " +
brc.getBuddyCommunicationTimeout() + " millis");
+ }
+ }
+ String buddyPoolName = XmlConfigHelper.readStringContents(element,
"buddyPoolName");
+ if ("".equals(buddyPoolName))
+ {
+ buddyPoolName = null;
+ }
+
+ brc.setBuddyPoolName(buddyPoolName);
+
+ // now read the buddy locator details
+
+ String buddyLocatorClass = XmlConfigHelper.readStringContents(element,
"buddyLocatorClass");
+ if (buddyLocatorClass == null || buddyLocatorClass.length() == 0)
+ {
+ buddyLocatorClass = NextMemberBuddyLocator.class.getName();
+ }
+ Properties props = null;
+ props = XmlConfigHelper.readPropertiesContents(element,
"buddyLocatorProperties");
+ BuddyLocatorConfig blc = new BuddyLocatorConfig();
+ blc.setBuddyLocatorClass(buddyLocatorClass);
+ blc.setBuddyLocatorProperties(props);
+ brc.setBuddyLocatorConfig(blc);
+
+ return brc;
+ }
+
+ private static CacheLoaderConfig parseCacheLoaderConfig(Element element)
+ {
+ CacheLoaderConfig clc = new CacheLoaderConfig();
+ clc.setPassivation(XmlConfigHelper.readBooleanContents(element,
"passivation"));
+ String s = XmlConfigHelper.readStringContents(element, "preload");
+ if (s != null && s.length() > 0) clc.setPreload(s);
+ clc.setShared(XmlConfigHelper.readBooleanContents(element, "shared"));
+
+ NodeList cacheLoaderNodes = element.getElementsByTagName("cacheloader");
+ for (int i = 0; i < cacheLoaderNodes.getLength(); i++)
+ {
+ Node node = cacheLoaderNodes.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE)
+ {
+ Element indivElement = (Element) node;
+ CacheLoaderConfig.IndividualCacheLoaderConfig iclc = new
CacheLoaderConfig.IndividualCacheLoaderConfig();
+ iclc.setAsync(XmlConfigHelper.readBooleanContents(indivElement,
"async", false));
+ iclc.setIgnoreModifications(XmlConfigHelper.readBooleanContents(indivElement,
"ignoreModifications", false));
+
iclc.setFetchPersistentState(XmlConfigHelper.readBooleanContents(indivElement,
"fetchPersistentState", false));
+ iclc.setPurgeOnStartup(XmlConfigHelper.readBooleanContents(indivElement,
"purgeOnStartup", false));
+ iclc.setClassName(XmlConfigHelper.readStringContents(indivElement,
"class"));
+ iclc.setProperties(XmlConfigHelper.readPropertiesContents(indivElement,
"properties"));
+
+ SingletonStoreConfig ssc = parseSingletonStoreConfig(indivElement);
+ if (ssc != null)
+ {
+ iclc.setSingletonStoreConfig(ssc);
+ }
+
+ clc.addIndividualCacheLoaderConfig(iclc);
+ }
+ }
+ return clc;
+ }
+
+ private static CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig
parseSingletonStoreConfig(Element cacheLoaderelement)
+ {
+ /* singletonStore element can only appear once in a cacheloader, so we just take
the first one ignoring any
+ subsequent definitions in cacheloader element*/
+ Node singletonStoreNode =
cacheLoaderelement.getElementsByTagName("singletonStore").item(0);
+ if (singletonStoreNode != null && singletonStoreNode.getNodeType() ==
Node.ELEMENT_NODE)
+ {
+ Element singletonStoreElement = (Element) singletonStoreNode;
+ boolean singletonStoreEnabled =
XmlConfigHelper.readBooleanContents(singletonStoreElement, "enabled");
+ String singletonStoreClass =
XmlConfigHelper.readStringContents(singletonStoreElement, "class");
+ Properties singletonStoreproperties;
+ singletonStoreproperties =
XmlConfigHelper.readPropertiesContents(singletonStoreElement, "properties");
+ CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig ssc = new
CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig();
+ ssc.setSingletonStoreEnabled(singletonStoreEnabled);
+ ssc.setSingletonStoreClass(singletonStoreClass);
+ ssc.setSingletonStoreproperties(singletonStoreproperties);
+
+ return ssc;
+ }
+
+ return null;
+ }
+
+
+ private static EvictionConfig parseEvictionConfig(Element element)
+ {
+ EvictionConfig ec = new EvictionConfig();
+
+ if (element != null)
+ {
+ // If they set the default eviction policy in the element, use that
+ // in preference to the external attribute
+ String temp = XmlConfigHelper.getTagContents(element,
+ "policyClass", ATTR, NAME);
+ if (temp != null && temp.length() > 0)
+ {
+ ec.setDefaultEvictionPolicyClass(temp);
+ }
+
+ temp = XmlConfigHelper.getTagContents(element,
+ "wakeUpIntervalSeconds", ATTR, NAME);
+
+ int wakeupIntervalSeconds = 0;
+ if (temp != null)
+ {
+ wakeupIntervalSeconds = Integer.parseInt(temp);
+ }
+
+ if (wakeupIntervalSeconds <= 0)
+ {
+ wakeupIntervalSeconds = EvictionConfig.WAKEUP_DEFAULT;
+ }
+
+ ec.setWakeupIntervalSeconds(wakeupIntervalSeconds);
+
+ int eventQueueSize = 0;
+ temp = XmlConfigHelper.getTagContents(element,
+ "eventQueueSize", ATTR, NAME);
+
+ if (temp != null)
+ {
+ eventQueueSize = Integer.parseInt(temp);
+ }
+
+ if (eventQueueSize <= 0)
+ {
+ eventQueueSize = EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT;
+ }
+
+ ec.setDefaultEventQueueSize(eventQueueSize);
+
+ NodeList list = element.getElementsByTagName(EvictionRegionConfig.REGION);
+ if (list != null && list.getLength() > 0)
+ {
+ List regionConfigs = new ArrayList(list.getLength());
+ for (int i = 0; i < list.getLength(); i++)
+ {
+ org.w3c.dom.Node node = list.item(i);
+ if (node.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE)
+ {
+ continue;
+ }
+ try
+ {
+ regionConfigs.add(parseEvictionRegionConfig((Element) node,
ec.getDefaultEvictionPolicyClass(), eventQueueSize));
+ }
+ catch (MissingPolicyException missingPolicy)
+ {
+
LogFactory.getLog(EvictionConfig.class).warn(missingPolicy.getLocalizedMessage());
+ throw missingPolicy;
+ }
+ }
+
+ ec.setEvictionRegionConfigs(regionConfigs);
+ }
+ }
+
+ return ec;
+
+ }
+
+ private static EvictionRegionConfig parseEvictionRegionConfig(Element element,
+ String
defaultEvictionClass,
+ int
defaultQueueCapacity)
+ {
+ EvictionRegionConfig erc = new EvictionRegionConfig();
+
+ erc.setRegionName(element.getAttribute(EvictionRegionConfig.NAME));
+
+ String temp = element.getAttribute("eventQueueSize");
+ if (temp != null && temp.length() > 0)
+ {
+ erc.setEventQueueSize(Integer.parseInt(temp));
+ }
+ else
+ {
+ erc.setEventQueueSize(defaultQueueCapacity);
+ }
+ String evictionClass = element.getAttribute("policyClass");
+
+ if (evictionClass == null || evictionClass.length() == 0)
+ {
+ evictionClass = defaultEvictionClass;
+ // if it's still null... what do we setCache?
+ if (evictionClass == null || evictionClass.length() == 0)
+ {
+ throw new MissingPolicyException(
+ "There is no Eviction Policy Class specified on the region or for
the entire cache!");
+ }
+ }
+
+ EvictionPolicy policy;
+ try
+ {
+ policy = (EvictionPolicy) Util.loadClass(evictionClass).newInstance();
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Eviction class is not properly loaded in
classloader", e);
+ }
+
+ EvictionPolicyConfig epc;
+ try
+ {
+ epc = policy.getEvictionConfigurationClass().newInstance();
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Failed to instantiate eviction configuration of
class " +
+ policy.getEvictionConfigurationClass(), e);
+ }
+
+ EvictionElementParser.parseEvictionPolicyConfig(element, epc);
+
+ erc.setEvictionPolicyConfig(epc);
+ return erc;
+
+ }
+
+ /**
+ * Parses the cluster config which is used to start a JGroups channel
+ *
+ * @param config an old-style JGroups protocol config String
+ */
+ public static String parseClusterConfigXml(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);
+ return buffer.toString();
+ }
+
+}
Property changes on:
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted:
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParserOld.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParserOld.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParserOld.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -1,536 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at
gnu.org.
- */
-package org.jboss.cache.config.parsing;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.buddyreplication.NextMemberBuddyLocator;
-import org.jboss.cache.config.BuddyReplicationConfig;
-import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig;
-import org.jboss.cache.config.CacheLoaderConfig;
-import
org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.EvictionConfig;
-import org.jboss.cache.config.EvictionPolicyConfig;
-import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.config.MissingPolicyException;
-import org.jboss.cache.eviction.EvictionPolicy;
-import org.jboss.cache.util.Util;
-import org.jboss.cache.config.parsing.XmlConfigHelper;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-
-/**
- * Reads in XMLconfiguration files and spits out a {@link
org.jboss.cache.config.Configuration} object. When deployed as a
- * JBoss MBean, this role is performed by the JBoss Microcontainer. This class is only
used internally in unit tests
- * or within {@link org.jboss.cache.CacheFactory} implementations for standalone JBoss
Cache usage.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani
(manik(a)jboss.org)</a>
- * @author <a href="mailto:galder.zamarreno@jboss.com">Galder
Zamarreno</a>
- * @since 2.00.
- * @deprecated
- */
-public class XmlConfigurationParserOld
-{
- private static final Log log = LogFactory.getLog(XmlConfigurationParserOld.class);
-
- public static final String ATTR = "attribute";
- public static final String NAME = "name";
-
- /**
- * Parses an XML file and returns a new configuration. This method attempts to look
for the file name passed in on
- * the classpath. If not found, it will search for the file on the file system
instead, treating the name as an
- * absolute path.
- *
- * @param filename the name of the XML file to parse.
- * @return a configured Configuration object representing the configuration in the
file
- */
- public Configuration parseFile(String filename)
- {
- InputStream is = getAsInputStreamFromClassLoader(filename);
- if (is == null)
- {
- if (log.isDebugEnabled())
- log.debug("Unable to find configuration file " + filename + "
in classpath; searching for this file on the filesystem instead.");
- try
- {
- is = new FileInputStream(filename);
- }
- catch (FileNotFoundException e)
- {
- throw new ConfigurationException("Unable to find config file " +
filename + " either in classpath or on the filesystem!", e);
- }
- }
-
- return parseStream(is);
- }
-
- /**
- * Parses an input stream containing XML text and returns a new configuration.
- *
- * @param stream input stream to parse. SHould not be null.
- * @return a configured Configuration object representing the configuration in the
stream
- * @since 2.1.0
- */
- public Configuration parseStream(InputStream stream)
- {
- // loop through all elements in XML.
- Element root = XmlConfigHelper.getDocumentRoot(stream);
- Element mbeanElement = getMBeanElement(root);
-
- return parseConfiguration(mbeanElement);
- }
-
- public Configuration parseConfiguration(Element configurationRoot)
- {
- ParsedAttributes attributes =
XmlConfigHelper.extractAttributes(configurationRoot);
-
- // Deal with legacy attributes we no longer support
- handleRemovedAttributes(attributes);
-
- // Deal with legacy attributes that we renamed or otherwise altered
- handleRenamedAttributes(attributes);
-
- Configuration c = new Configuration();
- XmlConfigHelper.setValues(c, attributes.stringAttribs, false);
- // Special handling for XML elements -- we hard code the parsing
- setXmlValues(c, attributes.xmlAttribs);
-
- return c;
- }
-
- /**
- * Check for and remove any attributes that were supported in the
- * 1.x releases and no longer are. Log a WARN or throw a
- * {@link ConfigurationException} if any are found. Which is done depends
- * on the attribute:
- * <p/>
- * <ul>
- * <li><i>MultiplexerService</i> -- throws an Exception</li>
- * <li><i>ServiceName</i> -- logs a WARN</li>
- * </ul>
- *
- * @param attributes
- */
- protected void handleRemovedAttributes(ParsedAttributes attributes)
- {
- String evictionPolicy =
attributes.stringAttribs.remove("EvictionPolicyClass");
- if (evictionPolicy != null)
- {
- throw new ConfigurationException("XmlConfigurationParser does not " +
- "support the JBC 1.x attribute EvictionPolicyClass. Set the default
" +
- "eviction policy via the policyClass element in the EvictionConfig
section");
- }
- String multiplexerService =
attributes.stringAttribs.remove("MultiplexerService");
- if (multiplexerService != null)
- {
- throw new ConfigurationException("XmlConfigurationParser does not " +
- "support the JBC 1.x attribute MultiplexerService. Inject the "
+
- "multiplexer directly using
Configuration.getRuntimeConfig().setMuxChannelFactory()");
- }
- String serviceName = attributes.stringAttribs.remove("ServiceName");
- if (serviceName != null)
- {
- log.warn("XmlConfigurationParser does not support the deprecated " +
- "attribute ServiceName. If JMX registration is needed, " +
- "register a CacheJmxWrapper or PojoCacheJmxWrapper in " +
- "JMX with the desired name");
- }
- }
-
- /**
- * Check for any attributes that were supported in the
- * 1.x releases but whose name has changed. Log a WARN if any are found, but
- * convert the attribute to the new name.
- * <p/>
- * <ul>
- * <li><i>UseMbean</i> becomes
<i>ExposeManagementStatistics</i></li>
- * </ul>
- *
- * @param attributes
- */
- private void handleRenamedAttributes(ParsedAttributes attributes)
- {
- String keepStats =
attributes.stringAttribs.remove("UseInterceptorMbeans");
- if (keepStats != null &&
attributes.stringAttribs.get("ExposeManagementStatistics") == null)
- {
- log.warn("Found non-existent JBC 1.x attribute
'UseInterceptorMbeans' and replaced " +
- "with 'ExposeManagementStatistics'. Please update your config
" +
- "to use the new attribute name");
- attributes.stringAttribs.put("ExposeManagementStatistics",
keepStats);
- }
- Element clc = attributes.xmlAttribs.remove("CacheLoaderConfiguration");
- if (clc != null && attributes.xmlAttribs.get("CacheLoaderConfig")
== null)
- {
- log.warn("Found non-existent JBC 1.x attribute
'CacheLoaderConfiguration' and replaced " +
- "with 'CacheLoaderConfig'. Please update your config "
+
- "to use the new attribute name");
- attributes.xmlAttribs.put("CacheLoaderConfig", clc);
- }
- }
-
- protected InputStream getAsInputStreamFromClassLoader(String filename)
- {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- InputStream is = cl == null ? null : cl.getResourceAsStream(filename);
- if (is == null)
- {
- // check system class loader
- is = getClass().getClassLoader().getResourceAsStream(filename);
- }
- return is;
- }
-
- protected Element getMBeanElement(Element root)
- {
- // This is following JBoss convention.
- NodeList list = root.getElementsByTagName(XmlConfigHelper.ROOT);
- if (list == null) throw new ConfigurationException("Can't find " +
XmlConfigHelper.ROOT + " tag");
-
- if (list.getLength() > 1) throw new ConfigurationException("Has multiple
" + XmlConfigHelper.ROOT + " tag");
-
- Node node = list.item(0);
- Element element;
- if (node.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
- {
- element = (Element) node;
- }
- else
- {
- throw new ConfigurationException("Can't find " +
XmlConfigHelper.ROOT + " element");
- }
- return element;
- }
-
- protected void setXmlValues(Configuration conf, Map<String, Element> attribs)
- {
- for (Entry<String, Element> entry : attribs.entrySet())
- {
- String propname = entry.getKey();
- if ("BuddyReplicationConfiguration".equals(propname)
- || "BuddyReplicationConfig".equals(propname))
- {
- BuddyReplicationConfig brc = parseBuddyReplicationConfig(entry.getValue());
- conf.setBuddyReplicationConfig(brc);
- }
- else if ("CacheLoaderConfiguration".equals(propname)
- || "CacheLoaderConfig".equals(propname))
- {
- CacheLoaderConfig clc = parseCacheLoaderConfig(entry.getValue());
- conf.setCacheLoaderConfig(clc);
- }
- else if ("EvictionPolicyConfiguration".equals(propname)
- || "EvictionPolicyConfig".equals(propname))
- {
- EvictionConfig ec = parseEvictionConfig(entry.getValue());
- conf.setEvictionConfig(ec);
- }
- else if ("ClusterConfig".equals(propname))
- {
- String jgc = parseClusterConfigXml(entry.getValue());
- conf.setClusterConfig(jgc);
- }
- else
- {
- throw new ConfigurationException("Unknown configuration element " +
propname);
- }
- }
- }
-
- public static BuddyReplicationConfig parseBuddyReplicationConfig(Element element)
- {
- BuddyReplicationConfig brc = new BuddyReplicationConfig();
- brc.setEnabled(XmlConfigHelper.readBooleanContents(element,
"buddyReplicationEnabled"));
- brc.setDataGravitationRemoveOnFind(XmlConfigHelper.readBooleanContents(element,
"dataGravitationRemoveOnFind", true));
-
brc.setDataGravitationSearchBackupTrees(XmlConfigHelper.readBooleanContents(element,
"dataGravitationSearchBackupTrees", true));
- brc.setAutoDataGravitation(brc.isEnabled() &&
XmlConfigHelper.readBooleanContents(element, "autoDataGravitation", false));
-
- String strBuddyCommunicationTimeout = XmlConfigHelper.readStringContents(element,
"buddyCommunicationTimeout");
- try
- {
-
brc.setBuddyCommunicationTimeout(Integer.parseInt(strBuddyCommunicationTimeout));
- }
- catch (Exception e)
- {
- }
- finally
- {
- if (log.isDebugEnabled())
- {
- log.debug("Using buddy communication timeout of " +
brc.getBuddyCommunicationTimeout() + " millis");
- }
- }
- String buddyPoolName = XmlConfigHelper.readStringContents(element,
"buddyPoolName");
- if ("".equals(buddyPoolName))
- {
- buddyPoolName = null;
- }
-
- brc.setBuddyPoolName(buddyPoolName);
-
- // now read the buddy locator details
-
- String buddyLocatorClass = XmlConfigHelper.readStringContents(element,
"buddyLocatorClass");
- if (buddyLocatorClass == null || buddyLocatorClass.length() == 0)
- {
- buddyLocatorClass = NextMemberBuddyLocator.class.getName();
- }
- Properties props = null;
- props = XmlConfigHelper.readPropertiesContents(element,
"buddyLocatorProperties");
- BuddyLocatorConfig blc = new BuddyLocatorConfig();
- blc.setBuddyLocatorClass(buddyLocatorClass);
- blc.setBuddyLocatorProperties(props);
- brc.setBuddyLocatorConfig(blc);
-
- return brc;
- }
-
- public static CacheLoaderConfig parseCacheLoaderConfig(Element element)
- {
- CacheLoaderConfig clc = new CacheLoaderConfig();
- clc.setPassivation(XmlConfigHelper.readBooleanContents(element,
"passivation"));
- clc.setPreload(XmlConfigHelper.readStringContents(element, "preload"));
- clc.setShared(XmlConfigHelper.readBooleanContents(element, "shared"));
-
- NodeList cacheLoaderNodes = element.getElementsByTagName("cacheloader");
- for (int i = 0; i < cacheLoaderNodes.getLength(); i++)
- {
- Node node = cacheLoaderNodes.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE)
- {
- Element indivElement = (Element) node;
- CacheLoaderConfig.IndividualCacheLoaderConfig iclc = new
CacheLoaderConfig.IndividualCacheLoaderConfig();
- iclc.setAsync(XmlConfigHelper.readBooleanContents(indivElement,
"async", false));
- iclc.setIgnoreModifications(XmlConfigHelper.readBooleanContents(indivElement,
"ignoreModifications", false));
-
iclc.setFetchPersistentState(XmlConfigHelper.readBooleanContents(indivElement,
"fetchPersistentState", false));
- iclc.setPurgeOnStartup(XmlConfigHelper.readBooleanContents(indivElement,
"purgeOnStartup", false));
- iclc.setClassName(XmlConfigHelper.readStringContents(indivElement,
"class"));
- iclc.setProperties(XmlConfigHelper.readPropertiesContents(indivElement,
"properties"));
-
- SingletonStoreConfig ssc =
CacheLoadersElementParser.parseSingletonStoreConfig(indivElement);
- if (ssc != null)
- {
- iclc.setSingletonStoreConfig(ssc);
- }
-
- clc.addIndividualCacheLoaderConfig(iclc);
- }
- }
-
- return clc;
- }
-
- public static EvictionConfig parseEvictionConfig(Element element)
- {
- EvictionConfig ec = new EvictionConfig();
-
- if (element != null)
- {
- // If they set the default eviction policy in the element, use that
- // in preference to the external attribute
- String temp = XmlConfigHelper.getTagContents(element,
- EvictionConfig.EVICTION_POLICY_CLASS, ATTR, NAME);
- if (temp != null && temp.length() > 0)
- {
- ec.setDefaultEvictionPolicyClass(temp);
- }
-
- temp = XmlConfigHelper.getTagContents(element,
- EvictionConfig.WAKEUP_INTERVAL_SECONDS, ATTR, NAME);
-
- int wakeupIntervalSeconds = 0;
- if (temp != null)
- {
- wakeupIntervalSeconds = Integer.parseInt(temp);
- }
-
- if (wakeupIntervalSeconds <= 0)
- {
- wakeupIntervalSeconds = EvictionConfig.WAKEUP_DEFAULT;
- }
-
- ec.setWakeupIntervalSeconds(wakeupIntervalSeconds);
-
- int eventQueueSize = 0;
- temp = XmlConfigHelper.getTagContents(element,
- EvictionConfig.EVENT_QUEUE_SIZE, ATTR, NAME);
-
- if (temp != null)
- {
- eventQueueSize = Integer.parseInt(temp);
- }
-
- if (eventQueueSize <= 0)
- {
- eventQueueSize = EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT;
- }
-
- ec.setDefaultEventQueueSize(eventQueueSize);
-
- NodeList list = element.getElementsByTagName(EvictionRegionConfig.REGION);
- if (list != null && list.getLength() > 0)
- {
- List regionConfigs = new ArrayList(list.getLength());
- for (int i = 0; i < list.getLength(); i++)
- {
- org.w3c.dom.Node node = list.item(i);
- if (node.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE)
- {
- continue;
- }
- try
- {
- regionConfigs.add(parseEvictionRegionConfig((Element) node,
ec.getDefaultEvictionPolicyClass(), eventQueueSize));
- }
- catch (MissingPolicyException missingPolicy)
- {
-
LogFactory.getLog(EvictionConfig.class).warn(missingPolicy.getLocalizedMessage());
- throw missingPolicy;
- }
- }
-
- ec.setEvictionRegionConfigs(regionConfigs);
- }
- }
-
- return ec;
-
- }
-
- public static EvictionRegionConfig parseEvictionRegionConfig(Element element,
- String
defaultEvictionClass,
- int
defaultQueueCapacity)
- {
- EvictionRegionConfig erc = new EvictionRegionConfig();
-
- erc.setRegionName(element.getAttribute(EvictionRegionConfig.NAME));
-
- String temp = element.getAttribute(EvictionRegionConfig.EVENT_QUEUE_SIZE);
- if (temp != null && temp.length() > 0)
- {
- erc.setEventQueueSize(Integer.parseInt(temp));
- }
- else
- {
- erc.setEventQueueSize(defaultQueueCapacity);
- }
- String evictionClass =
element.getAttribute(EvictionRegionConfig.REGION_POLICY_CLASS);
-
- if (evictionClass == null || evictionClass.length() == 0)
- {
- evictionClass = defaultEvictionClass;
- // if it's still null... what do we setCache?
- if (evictionClass == null || evictionClass.length() == 0)
- {
- throw new MissingPolicyException(
- "There is no Eviction Policy Class specified on the region or for
the entire cache!");
- }
- }
-
- EvictionPolicy policy;
- try
- {
- policy = (EvictionPolicy) Util.loadClass(evictionClass).newInstance();
- }
- catch (RuntimeException e)
- {
- throw e;
- }
- catch (Exception e)
- {
- throw new RuntimeException("Eviction class is not properly loaded in
classloader", e);
- }
-
- EvictionPolicyConfig epc;
- try
- {
- epc = policy.getEvictionConfigurationClass().newInstance();
- }
- catch (RuntimeException e)
- {
- throw e;
- }
- catch (Exception e)
- {
- throw new RuntimeException("Failed to instantiate eviction configuration of
class " +
- policy.getEvictionConfigurationClass(), e);
- }
-
- EvictionElementParser.parseEvictionPolicyConfig(element, epc);
-
- erc.setEvictionPolicyConfig(epc);
- return erc;
-
- }
-
- /**
- * Parses the cluster config which is used to start a JGroups channel
- *
- * @param config an old-style JGroups protocol config String
- */
- public static String parseClusterConfigXml(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);
- return buffer.toString();
- }
-
-}
Copied:
core/trunk/src/main/java/org/jboss/cache/config/parsing/element/BuddyElementParser.java
(from rev 5995,
core/trunk/src/main/java/org/jboss/cache/config/parsing/BuddyReplicationElementParser.java)
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/config/parsing/element/BuddyElementParser.java
(rev 0)
+++
core/trunk/src/main/java/org/jboss/cache/config/parsing/element/BuddyElementParser.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -0,0 +1,73 @@
+package org.jboss.cache.config.parsing.element;
+
+import org.jboss.cache.config.BuddyReplicationConfig;
+import org.jboss.cache.config.parsing.XmlParserBase;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
+import org.jboss.cache.buddyreplication.NextMemberBuddyLocator;
+import org.w3c.dom.Element;
+
+import java.util.Properties;
+
+/**
+ * Utility class for parsing 'buddy' element in the .xml configuration file.
+ * <pre>
+ * Note: class does not rely on element position in the configuration file.
+ * It does not rely on element's name either.
+ * </pre>
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+public class BuddyElementParser extends XmlParserBase
+{
+ public BuddyReplicationConfig parseBuddyElement(Element element)
+ {
+ BuddyReplicationConfig brc = new BuddyReplicationConfig();
+ String enabled = element.getAttribute("enabled");
+ if (existsAttribute(enabled)) brc.setEnabled(getBoolean(enabled));
+ String buddyPoolName = element.getAttribute("poolName");
+ if (existsAttribute(buddyPoolName)) brc.setBuddyPoolName(buddyPoolName);
+ String buddyCommunicationTimeout =
element.getAttribute("communicationTimeout");
+ if (existsAttribute(buddyCommunicationTimeout))
+ brc.setBuddyCommunicationTimeout(getInt(buddyCommunicationTimeout));
+
+ parseDataGravitationElement(getSingleElement("dataGravitation", element),
brc);
+ BuddyReplicationConfig.BuddyLocatorConfig blc =
parseBuddyLocatorConfig(getSingleElement("locator", element));
+ brc.setBuddyLocatorConfig(blc);
+ return brc;
+ }
+
+ private BuddyReplicationConfig.BuddyLocatorConfig parseBuddyLocatorConfig(Element
element)
+ {
+ if (element == null) return defaultBuddyLocatorConfig();
+ BuddyReplicationConfig.BuddyLocatorConfig result = new
BuddyReplicationConfig.BuddyLocatorConfig();
+ String buddyLocatorClass = element.getAttribute("class");
+ if (existsAttribute(buddyLocatorClass))
result.setBuddyLocatorClass(buddyLocatorClass);
+ Properties existing = new Properties();
+ Properties configured = XmlConfigHelper.readPropertiesContents(element,
"properties");
+ existing.putAll(configured);
+ result.setBuddyLocatorClass(buddyLocatorClass);
+ result.setBuddyLocatorProperties(existing);
+ return result;
+ }
+
+ private BuddyReplicationConfig.BuddyLocatorConfig defaultBuddyLocatorConfig()
+ {
+ BuddyReplicationConfig.BuddyLocatorConfig result = new
BuddyReplicationConfig.BuddyLocatorConfig();
+ result.setBuddyLocatorClass(NextMemberBuddyLocator.class.getName());
+ Properties props = new Properties();
+ result.setBuddyLocatorProperties(props);
+ return result;
+ }
+
+ private void parseDataGravitationElement(Element element, BuddyReplicationConfig brc)
+ {
+ if (element == null) return;
+ String auto = element.getAttribute("auto");
+ if (existsAttribute(auto)) brc.setAutoDataGravitation(getBoolean(auto));
+ String removeOnFind = element.getAttribute("removeOnFind");
+ if (existsAttribute(removeOnFind))
brc.setDataGravitationRemoveOnFind(getBoolean(removeOnFind));
+ String searchBackupTrees = element.getAttribute("searchBackupTrees");
+ if (existsAttribute(searchBackupTrees))
brc.setDataGravitationSearchBackupTrees(getBoolean(searchBackupTrees));
+ }
+}
Copied:
core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java
(from rev 5995,
core/trunk/src/main/java/org/jboss/cache/config/parsing/EvictionElementParser.java)
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java
(rev 0)
+++
core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -0,0 +1,129 @@
+package org.jboss.cache.config.parsing.element;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.jboss.cache.config.EvictionConfig;
+import org.jboss.cache.config.EvictionRegionConfig;
+import org.jboss.cache.config.MissingPolicyException;
+import org.jboss.cache.config.EvictionPolicyConfig;
+import org.jboss.cache.config.parsing.XmlParserBase;
+import org.jboss.cache.config.parsing.ParsedAttributes;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
+import org.jboss.cache.eviction.EvictionPolicy;
+import org.jboss.cache.util.Util;
+import org.jboss.cache.RegionManager;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * Knows how to parse the <b>eviction</b> xml element.
+ * <pre>
+ * Note: class does not rely on element position in the configuration file.
+ * It does not rely on element's name either.
+ * </pre>
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+public class EvictionElementParser extends XmlParserBase
+{
+ public EvictionConfig parseEvictionElement(Element evictionElement)
+ {
+ EvictionConfig evictionConfig = new EvictionConfig();
+ String wakeUpInterval = evictionElement.getAttribute("wakeUpInterval");
+ if (existsAttribute(wakeUpInterval))
evictionConfig.setWakeupInterval(getInt(wakeUpInterval));
+
+ Element element = getSingleElement("defaults", evictionElement);
+ processDefaults(evictionConfig, element);
+
+ List<EvictionRegionConfig> evictionRegionConfigs = new
ArrayList<EvictionRegionConfig>(3);
+ Element rootRegion = getSingleElement("root", evictionElement);
+ String defaultPolicyClass = evictionConfig.getDefaultEvictionPolicyClass();
+ int defaultEvQueueSize = evictionConfig.getDefaultEventQueueSize();
+ if (rootRegion != null)
+ {
+ EvictionRegionConfig erc = getEvictionRegionConfig(rootRegion,
defaultPolicyClass, defaultEvQueueSize);
+ erc.setRegionName(RegionManager.DEFAULT_REGION.toString());
+ evictionRegionConfigs.add(erc);
+ }
+
+ NodeList regions = evictionElement.getElementsByTagName("region");
+ for (int i = 0; i < regions.getLength(); i++)
+ {
+ Element regionConfig = (Element) regions.item(i);
+ EvictionRegionConfig erc = getEvictionRegionConfig(regionConfig,
defaultPolicyClass, defaultEvQueueSize);
+ evictionRegionConfigs.add(erc);
+ }
+ evictionConfig.setEvictionRegionConfigs(evictionRegionConfigs);
+ return evictionConfig;
+ }
+
+ private void processDefaults(EvictionConfig evictionConfig, Element element)
+ {
+ if (element == null) return;
+ String policyClass = element.getAttribute("policyClass");
+ if (existsAttribute(policyClass))
evictionConfig.setDefaultEvictionPolicyClass(policyClass);
+ String eventQueueSize = element.getAttribute("eventQueueSize");
+ if (existsAttribute(eventQueueSize))
evictionConfig.setDefaultEventQueueSize(getInt(eventQueueSize));
+ }
+
+ private EvictionRegionConfig getEvictionRegionConfig(Element element, String
defaultPolicyClass, int defaultEventQueueSize)
+ {
+ EvictionRegionConfig erc = new EvictionRegionConfig();
+ erc.setRegionName(element.getAttribute("name"));
+ String queueSize = element.getAttribute("eventQueueSize");
+ if (existsAttribute(queueSize))
+ {
+ erc.setEventQueueSize(getInt(queueSize));
+ }
+ else
+ {
+ erc.setEventQueueSize(defaultEventQueueSize);
+ }
+ String policyClass = element.getAttribute("policyClass");
+ if (!existsAttribute(policyClass))
+ {
+ if (defaultPolicyClass == null)
+ {
+ throw new MissingPolicyException("There is no Eviction Policy Class
specified on the region or for the entire cache!");
+ }
+ else
+ {
+ policyClass = defaultPolicyClass;
+ }
+ }
+ EvictionPolicy policy;
+ try
+ {
+ policy = (EvictionPolicy) Util.loadClass(policyClass).newInstance();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Eviction class is not properly loaded in
classloader", e);
+ }
+
+ EvictionPolicyConfig epc;
+ try
+ {
+ epc = policy.getEvictionConfigurationClass().newInstance();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Failed to instantiate eviction configuration of
class " +
+ policy.getEvictionConfigurationClass(), e);
+ }
+ parseEvictionPolicyConfig(element, epc);
+ erc.setEvictionPolicyConfig(epc);
+ return erc;
+ }
+
+ public static void parseEvictionPolicyConfig(Element element, EvictionPolicyConfig
target)
+ {
+ target.reset();
+ ParsedAttributes attributes = XmlConfigHelper.extractAttributes(element);
+ XmlConfigHelper.setValues(target, attributes.stringAttribs, false);
+ XmlConfigHelper.setValues(target, attributes.xmlAttribs, true);
+ target.validate();
+ }
+}
Copied:
core/trunk/src/main/java/org/jboss/cache/config/parsing/element/LoadersElementParser.java
(from rev 5997,
core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheLoadersElementParser.java)
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/config/parsing/element/LoadersElementParser.java
(rev 0)
+++
core/trunk/src/main/java/org/jboss/cache/config/parsing/element/LoadersElementParser.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -0,0 +1,106 @@
+package org.jboss.cache.config.parsing.element;
+
+import org.jboss.cache.config.CacheLoaderConfig;
+import org.jboss.cache.config.ConfigurationException;
+import org.jboss.cache.config.parsing.XmlParserBase;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.util.Properties;
+
+/**
+ * Utility class for parsing the 'loaders' element in the .xml configuration
file.
+ * <pre>
+ * Note: class does not rely on element position in the configuration file.
+ * It does not rely on element's name either.
+ * </pre>
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+public class LoadersElementParser extends XmlParserBase
+{
+ public CacheLoaderConfig parseLoadersElement(Element element)
+ {
+ CacheLoaderConfig cacheLoaderConfig = new CacheLoaderConfig();
+ String passivation = element.getAttribute("passivation");
+ if (existsAttribute(passivation))
cacheLoaderConfig.setPassivation(getBoolean(passivation));
+ String shared = element.getAttribute("shared");
+ if (existsAttribute(shared)) cacheLoaderConfig.setShared(getBoolean(shared));
+ String preload = getPreloadString(getSingleElement("preload", element));
+ if (preload != null) cacheLoaderConfig.setPreload(preload);
+
+ NodeList cacheLoaderNodes = element.getElementsByTagName("loader");
+ for (int i = 0; i < cacheLoaderNodes.getLength(); i++)
+ {
+ Element indivElement = (Element) cacheLoaderNodes.item(i);
+ CacheLoaderConfig.IndividualCacheLoaderConfig iclc =
parseIndividualCacheLoaderConfig(indivElement);
+ cacheLoaderConfig.addIndividualCacheLoaderConfig(iclc);
+ }
+ return cacheLoaderConfig;
+ }
+
+ private CacheLoaderConfig.IndividualCacheLoaderConfig
parseIndividualCacheLoaderConfig(Element indivElement)
+ {
+ CacheLoaderConfig.IndividualCacheLoaderConfig iclc = new
CacheLoaderConfig.IndividualCacheLoaderConfig();
+
+ String async = indivElement.getAttribute("async");
+ if (existsAttribute(async)) iclc.setAsync(getBoolean(async));
+ String fetchPersistentState =
indivElement.getAttribute("fetchPersistentState");
+ if (existsAttribute(fetchPersistentState))
iclc.setFetchPersistentState(getBoolean(fetchPersistentState));
+ String ignoreModifications =
indivElement.getAttribute("ignoreModifications");
+ if (existsAttribute(ignoreModifications))
iclc.setIgnoreModifications(getBoolean(ignoreModifications));
+ String purgeOnStartup = indivElement.getAttribute("purgeOnStartup");
+ if (existsAttribute(purgeOnStartup))
iclc.setPurgeOnStartup(getBoolean(purgeOnStartup));
+ String clClass = indivElement.getAttribute("class");
+ if (!existsAttribute(clClass))
+ throw new ConfigurationException("Missing 'class' attribute for
cache loader configuration");
+ iclc.setClassName(clClass);
+ iclc.setProperties(XmlConfigHelper.readPropertiesContents(indivElement,
"properties"));
+ CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig ssc =
parseSingletonStoreConfig(getSingleElement("singletonStore", indivElement));
+ if (ssc != null)
+ {
+ iclc.setSingletonStoreConfig(ssc);
+ }
+ return iclc;
+ }
+
+ private String getPreloadString(Element preloadElement)
+ {
+ if (preloadElement == null) return null; //might be no preload
+ NodeList nodesToPreload = preloadElement.getElementsByTagName("node");
+ StringBuffer result = new StringBuffer();
+ for (int i = 0; i < nodesToPreload.getLength(); i++)
+ {
+ Element node = (Element) nodesToPreload.item(i);
+ String fqn2preload = node.getAttribute("fqn");
+ if (!existsAttribute(fqn2preload))
+ throw new ConfigurationException("Missing 'fqn' attribute in
'preload\\norde' tag");
+ if (i > 0) result.append(",");
+ result.append(fqn2preload);
+ }
+ //no elements defined for preload so by default load the root
+ if (nodesToPreload.getLength() == 0)
+ {
+ result.append("/");
+ }
+ return result.toString();
+ }
+
+ public CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig
parseSingletonStoreConfig(Element element)
+ {
+ if (element == null) return null; //might happen, this config option is not
mandatory
+ String enabled = element.getAttribute("enabled");
+ boolean singletonStoreEnabled =
getBoolean(element.getAttribute("enabled"));
+ String singletonStoreClass = element.getAttribute("class");
+ CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig ssc = new
CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig();
+ if (existsAttribute(singletonStoreClass))
ssc.setSingletonStoreClass(singletonStoreClass);
+ Properties singletonStoreproperties =
XmlConfigHelper.readPropertiesContents(element, "properties");
+ ssc.setSingletonStoreEnabled(singletonStoreEnabled);
+ ssc.setSingletonStoreClass(singletonStoreClass);
+ ssc.setSingletonStoreproperties(singletonStoreproperties);
+ return ssc;
+ }
+}
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicyConfigBase.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicyConfigBase.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicyConfigBase.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -76,6 +76,7 @@
public void setMinTimeToLive(long minTimeToLive)
{
this.minTimeToLive = minTimeToLive;
+ this.minTimeToLiveSeconds = (int)(minTimeToLive / 1000);
}
/**
@@ -94,7 +95,7 @@
public void setMinTimeToLiveSeconds(int minTimeToLiveSeconds)
{
this.minTimeToLiveSeconds = minTimeToLiveSeconds;
- setMinTimeToLive(minTimeToLive * 1000);
+ minTimeToLive = minTimeToLiveSeconds * 1000;
}
public void validate() throws ConfigurationException
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationConfiguration.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationConfiguration.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationConfiguration.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -80,6 +80,7 @@
public void setTimeToLive(long timeToLive)
{
this.timeToLive = timeToLive;
+ this.timeToLiveSeconds = (int) (timeToLive * 1000);
}
/**
@@ -98,7 +99,7 @@
public void setTimeToLiveSeconds(int timeToLiveSeconds)
{
this.timeToLiveSeconds = timeToLiveSeconds;
- setTimeToLive(timeToLiveSeconds * 1000);
+ timeToLive = timeToLiveSeconds * 1000;
}
@Override
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LRUConfiguration.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/LRUConfiguration.java 2008-06-25
15:57:45 UTC (rev 6041)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/LRUConfiguration.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -55,6 +55,13 @@
setTimeToLive(-1);
}
+ public LRUConfiguration(long timeToLive, long maxAge)
+ {
+ super();
+ setTimeToLive(timeToLive);
+ setMaxAge(maxAge);
+ }
+
@Override
protected void setEvictionPolicyClassName()
{
@@ -72,6 +79,7 @@
{
testImmutability("timeToLive");
this.timeToLive = timeToLive;
+ this.timeToLiveSeconds = (int)(timeToLive/1000);
}
/** value expressed in millis*/
@@ -85,6 +93,7 @@
{
testImmutability("maxAge");
this.maxAge = maxAge;
+ this.maxAgeSeconds = (int) (maxAge/1000);
}
/**
@@ -105,7 +114,7 @@
{
testImmutability("timeToLiveSeconds");
this.timeToLiveSeconds = timeToLiveSeconds;
- setTimeToLive(timeToLiveSeconds * 1000);
+ timeToLive = timeToLiveSeconds * 1000;
}
/**
@@ -126,7 +135,7 @@
{
testImmutability("maxAgeSeconds");
this.maxAgeSeconds = maxAgeSeconds;
- setMaxAge(maxAgeSeconds * 1000);
+ this.maxAge = maxAgeSeconds * 1000;
}
/**
@@ -162,7 +171,9 @@
LRUConfiguration that = (LRUConfiguration) o;
if (maxAge != that.maxAge) return false;
+ if (maxAgeSeconds != that.maxAgeSeconds) return false;
if (timeToLive != that.timeToLive) return false;
+ if (timeToLiveSeconds != that.timeToLiveSeconds) return false;
return true;
}
@@ -170,6 +181,8 @@
public int hashCode()
{
int result = super.hashCode();
+ result = 31 * result + timeToLiveSeconds;
+ result = 31 * result + maxAgeSeconds;
result = 31 * result + (int) (timeToLive ^ (timeToLive >>> 32));
result = 31 * result + (int) (maxAge ^ (maxAge >>> 32));
return result;
Modified: core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java 2008-06-25 15:57:45
UTC (rev 6041)
+++ core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java 2008-06-25 17:04:10
UTC (rev 6042)
@@ -23,19 +23,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Cache;
-import org.jboss.cache.CacheException;
-import org.jboss.cache.CacheFactory;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.CacheStatus;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.config.BuddyReplicationConfig;
-import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.EvictionConfig;
-import org.jboss.cache.config.RuntimeConfig;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.*;
+import org.jboss.cache.config.*;
+import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
+import org.jboss.cache.config.parsing.JGroupsStackParser;
+import org.jboss.cache.config.parsing.element.BuddyElementParser;
+import org.jboss.cache.config.parsing.element.LoadersElementParser;
+import org.jboss.cache.config.parsing.element.EvictionElementParser;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.util.CachePrinter;
import org.jgroups.Address;
@@ -61,6 +55,7 @@
extends NotificationBroadcasterSupport
implements CacheJmxWrapperMBean<K, V>, MBeanRegistration,
CacheNotificationBroadcaster
{
+
private Log log = LogFactory.getLog(getClass().getName());
private MBeanServer server;
@@ -85,6 +80,11 @@
private Element clusterConfig;
private JChannelFactoryMBean multiplexerService;
+ private BuddyElementParser buddyElementParser = new BuddyElementParser();
+ private LoadersElementParser loadersElementParser = new LoadersElementParser();
+ private EvictionElementParser evictionElementParser = new EvictionElementParser();
+ private JGroupsStackParser stackParser = new JGroupsStackParser();
+
// ----------------------------------------------------------- Constructors
public CacheJmxWrapper()
@@ -374,21 +374,21 @@
BuddyReplicationConfig brc = null;
if (config != null)
{
- brc = XmlConfigurationParserOld.parseBuddyReplicationConfig(config);
+ brc = buddyElementParser.parseBuddyElement(config);
}
getConfiguration().setBuddyReplicationConfig(brc);
this.buddyReplConfig = config;
}
- public void setCacheLoaderConfig(Element cache_loader_config)
+ public void setCacheLoaderConfig(Element cacheLoaderConfig)
{
CacheLoaderConfig clc = null;
- if (cache_loader_config != null)
+ if (cacheLoaderConfig != null)
{
- clc = XmlConfigurationParserOld.parseCacheLoaderConfig(cache_loader_config);
+ clc = loadersElementParser.parseLoadersElement(cacheLoaderConfig);
}
getConfiguration().setCacheLoaderConfig(clc);
- this.cacheLoaderConfig = cache_loader_config;
+ this.cacheLoaderConfig = cacheLoaderConfig;
}
public void setCacheLoaderConfiguration(Element config)
@@ -408,7 +408,7 @@
String props = null;
if (config != null)
{
- props = XmlConfigurationParserOld.parseClusterConfigXml(config);
+ stackParser.parseClusterConfigXml(config);
}
getConfiguration().setClusterConfig(props);
this.clusterConfig = config;
@@ -435,7 +435,7 @@
EvictionConfig ec = null;
if (config != null)
{
- ec = XmlConfigurationParserOld.parseEvictionConfig(config);
+ ec = evictionElementParser.parseEvictionElement(config);
}
getConfiguration().setEvictionConfig(ec);
this.evictionConfig = config;
Modified: core/trunk/src/main/java/org/jboss/cache/jmx/LegacyConfiguration.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/jmx/LegacyConfiguration.java 2008-06-25
15:57:45 UTC (rev 6041)
+++ core/trunk/src/main/java/org/jboss/cache/jmx/LegacyConfiguration.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -105,7 +105,7 @@
*/
Element getCacheLoaderConfig();
- void setCacheLoaderConfig(Element cache_loader_config);
+ void setCacheLoaderConfig(Element cacheLoaderConfig);
/**
* @deprecated use {@link #getCacheLoaderConfig()}
Modified: core/trunk/src/test/java/org/jboss/cache/CacheFactoryTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/CacheFactoryTest.java 2008-06-25 15:57:45 UTC
(rev 6041)
+++ core/trunk/src/test/java/org/jboss/cache/CacheFactoryTest.java 2008-06-25 17:04:10 UTC
(rev 6042)
@@ -7,7 +7,7 @@
package org.jboss.cache;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.transaction.DummyTransactionManagerLookup;
@@ -31,7 +31,7 @@
@BeforeMethod(alwaysRun = true)
public void setUp()
{
- XmlConfigurationParserOld parser = new XmlConfigurationParserOld();
+ XmlConfigurationParser2x parser = new XmlConfigurationParser2x();
expected = parser.parseFile(configFile);
}
Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java 2008-06-25 15:57:45
UTC (rev 6041)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java 2008-06-25 17:04:10
UTC (rev 6042)
@@ -9,7 +9,7 @@
import org.jboss.cache.NodeNotExistsException;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.parsing.CacheLoadersElementParser;
+import org.jboss.cache.config.parsing.element.LoadersElementParser;
import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.jboss.cache.loader.DummyInMemoryCacheLoader;
import org.jboss.cache.util.TestingUtil;
@@ -533,19 +533,19 @@
protected CacheLoaderConfig getSingleCacheLoaderConfig(boolean passivation, String
preload, String cacheloaderClass, String properties, boolean async, boolean
fetchPersistentState, boolean shared, boolean purgeOnStartup) throws Exception
{
String xml =
- " <cacheLoaders passivation=\"" + passivation +
"\" shared=\"" + shared + "\">\n" +
+ " <loaders passivation=\"" + passivation +
"\" shared=\"" + shared + "\">\n" +
" <preload>\n" +
" <node fqn=\"" + preload +
"\"/>\n" +
" </preload>\n" +
- " <cacheLoader class=\"" + cacheloaderClass +
"\" async=\"" + async + "\"
fetchPersistentState=\"" + fetchPersistentState + "\"\n" +
+ " <loader class=\"" + cacheloaderClass +
"\" async=\"" + async + "\"
fetchPersistentState=\"" + fetchPersistentState + "\"\n" +
" purgeOnStartup=\"" +
purgeOnStartup + "\">\n" +
" <properties>\n" +
- properties +
+ properties +
" </properties>\n" +
- " </cacheLoader>\n" +
- " </cacheLoaders>";
+ " </loader>\n" +
+ " </loaders>";
Element element = XmlConfigHelper.stringToElement(xml);
- CacheLoadersElementParser elementParser = new CacheLoadersElementParser();
- return elementParser.parseCacheLoadersElement(element);
+ LoadersElementParser elementParser = new LoadersElementParser();
+ return elementParser.parseLoadersElement(element);
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -12,9 +12,9 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.element.BuddyElementParser;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.jboss.cache.factories.CommandsFactory;
-import org.jboss.cache.config.parsing.XmlConfigHelper;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
@@ -31,7 +31,6 @@
public class BuddyManagerTest
{
private static final String DUMMY_LOCAL_ADDRESS = "myLocalAddress:12345";
- private BuddyFqnTransformer fqnTransformer;
/**
* Constructs a buddy manager using the default buddy locator but with some specific
properties.
@@ -40,11 +39,15 @@
*/
public void testConstruction1() throws Exception
{
- String xmlConfig =
"<config><buddyReplicationEnabled>true</buddyReplicationEnabled>\n"
+
- " <buddyLocatorProperties>numBuddies =
3</buddyLocatorProperties>\n" +
- "
<buddyPoolName>groupOne</buddyPoolName></config>";
- Element element = XmlConfigHelper.stringToElement(xmlConfig);
- BuddyReplicationConfig config =
XmlConfigurationParserOld.parseBuddyReplicationConfig(element);
+ String xmlConfig =
+ " <buddyReplication enabled=\"true\"
buddyPoolName=\"groupOne\">\n" +
+ " <buddyLocator>\n" +
+ " <properties>\n" +
+ " numBuddies = 3\n" +
+ " </properties>\n" +
+ " </buddyLocator>\n" +
+ " </buddyReplication>";
+ BuddyReplicationConfig config = getBuddyReplicationConfig(xmlConfig);
BuddyManager mgr = new BuddyManager(config);
assertTrue(mgr.isEnabled());
@@ -55,6 +58,14 @@
assertTrue(blc.isIgnoreColocatedBuddies());
}
+ private BuddyReplicationConfig getBuddyReplicationConfig(String xmlConfig)
+ throws Exception
+ {
+ Element element = XmlConfigHelper.stringToElement(xmlConfig);
+ BuddyElementParser replicationElementParser = new BuddyElementParser();
+ return replicationElementParser.parseBuddyElement(element);
+ }
+
/**
* Constructs a buddy manager using a nonexistent buddy locator but with some specific
properties.
*
@@ -62,12 +73,15 @@
*/
public void testConstruction2() throws Exception
{
- String xmlConfig =
"<config><buddyReplicationEnabled>true</buddyReplicationEnabled>\n"
+
- "
<buddyLocatorClass>org.i.dont.exist.PhantomBuddyLocator</buddyLocatorClass>\n"
+
- " <buddyLocatorProperties>numBuddies =
3</buddyLocatorProperties>\n" +
- "
<buddyPoolName>groupOne</buddyPoolName></config>";
- Element element = XmlConfigHelper.stringToElement(xmlConfig);
- BuddyReplicationConfig config =
XmlConfigurationParserOld.parseBuddyReplicationConfig(element);
+ String xmlConfig =
+ " <buddyReplication enabled=\"true\"
buddyPoolName=\"groupOne\">\n" +
+ " <buddyLocator
class=\"org.i.dont.exist.PhantomBuddyLocator\">\n" +
+ " <properties>\n" +
+ " numBuddies = 3\n" +
+ " </properties>\n" +
+ " </buddyLocator>\n" +
+ " </buddyReplication>";
+ BuddyReplicationConfig config = getBuddyReplicationConfig(xmlConfig);
BuddyManager mgr = new BuddyManager(config);
assertTrue(mgr.isEnabled());
@@ -87,12 +101,9 @@
*/
public void testConstruction3() throws Exception
{
- String xmlConfig =
"<config><buddyReplicationEnabled>false</buddyReplicationEnabled></config>";
-
- Element element = XmlConfigHelper.stringToElement(xmlConfig);
- BuddyReplicationConfig config =
XmlConfigurationParserOld.parseBuddyReplicationConfig(element);
+ String xmlConfig = "<buddyReplication
enabled=\"false\"/>";
+ BuddyReplicationConfig config = getBuddyReplicationConfig(xmlConfig);
BuddyManager mgr = new BuddyManager(config);
-
assertTrue(!mgr.isEnabled());
}
@@ -103,10 +114,9 @@
*/
public void testConstruction4() throws Exception
{
- String xmlConfig =
"<config><buddyReplicationEnabled>true</buddyReplicationEnabled></config>";
+ String xmlConfig = "<buddyReplication
enabled=\"true\"/>";
- Element element = XmlConfigHelper.stringToElement(xmlConfig);
- BuddyReplicationConfig config =
XmlConfigurationParserOld.parseBuddyReplicationConfig(element);
+ BuddyReplicationConfig config = getBuddyReplicationConfig(xmlConfig);
BuddyManager mgr = new BuddyManager(config);
assertTrue(mgr.isEnabled());
@@ -122,9 +132,9 @@
BuddyManager bm = null;
try
{
- Element element =
XmlConfigHelper.stringToElement("<config><buddyReplicationEnabled>true</buddyReplicationEnabled></config>");
- BuddyReplicationConfig cfg =
XmlConfigurationParserOld.parseBuddyReplicationConfig(element);
- bm = new BuddyManager(cfg);
+ String xmlConfig = "<buddyReplication
enabled=\"false\"/>";
+ BuddyReplicationConfig config = getBuddyReplicationConfig(xmlConfig);
+ bm = new BuddyManager(config);
bm.injectDependencies(null, null, null, null, null, null, null, null, new
BuddyFqnTransformer());
CommandsFactory commandsFactory = new CommandsFactory();
commandsFactory.initialize(null, null, null, null, null, null, null, new
Configuration(), null, new BuddyFqnTransformer());
@@ -208,7 +218,7 @@
public void testGetActualFqn()
{
- fqnTransformer = new BuddyFqnTransformer();
+ BuddyFqnTransformer fqnTransformer = new BuddyFqnTransformer();
Fqn<String> x = Fqn.fromString("/x");
Fqn backup = fqnTransformer.getBackupFqn("y", x);
assertEquals(x, fqnTransformer.getActualFqn(backup));
Modified:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationConfigTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationConfigTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationConfigTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -11,10 +11,11 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
import org.jboss.cache.interceptors.DataGravitatorInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.config.parsing.XmlConfigHelper;
+import org.jboss.cache.config.parsing.element.BuddyElementParser;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
@@ -46,9 +47,8 @@
public void testDisabledConfig() throws Exception
{
- String xmlConfig =
"<config><buddyReplicationEnabled>false</buddyReplicationEnabled></config>";
- Element element = XmlConfigHelper.stringToElement(xmlConfig);
- BuddyReplicationConfig config =
XmlConfigurationParserOld.parseBuddyReplicationConfig(element);
+ String xmlConfig = "<buddyReplication
enabled=\"false\"/>";
+ BuddyReplicationConfig config = getBuddyReplicationConfig(xmlConfig);
cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object,
Object>().createCache(false);
cache.getConfiguration().setBuddyReplicationConfig(config);
assertNull(cache.getBuddyManager());
@@ -56,9 +56,8 @@
public void testBasicConfig() throws Exception
{
- String xmlConfig =
"<config><buddyReplicationEnabled>true</buddyReplicationEnabled></config>";
- Element element = XmlConfigHelper.stringToElement(xmlConfig);
- BuddyReplicationConfig config =
XmlConfigurationParserOld.parseBuddyReplicationConfig(element);
+ String xmlConfig = "<buddyReplication
enabled=\"true\"/>";
+ BuddyReplicationConfig config = getBuddyReplicationConfig(xmlConfig);
cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object,
Object>().createCache(false);
cache.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
cache.getConfiguration().setBuddyReplicationConfig(config);
@@ -74,9 +73,18 @@
assertTrue(blc.isIgnoreColocatedBuddies());
}
+ private BuddyReplicationConfig getBuddyReplicationConfig(String xmlConfig)
+ throws Exception
+ {
+ Element element = XmlConfigHelper.stringToElement(xmlConfig);
+ BuddyElementParser elementParser = new BuddyElementParser();
+ BuddyReplicationConfig config = elementParser.parseBuddyElement(element);
+ return config;
+ }
+
public void testXmlConfig() throws Exception
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object,
Object>().createCache(new
XmlConfigurationParserOld().parseFile("META-INF/buddy-replication-cache-service.xml"),
false);
+ cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object,
Object>().createCache(new
XmlConfigurationParser2x().parseFile("META-INF/buddy-replication-cache-service.xml"),
false);
cache.create();
cache.start();
BuddyManager bm = cache.getBuddyManager();
@@ -104,9 +112,8 @@
public void testLocalModeConfig() throws Exception
{
- String xmlConfig =
"<config><buddyReplicationEnabled>true</buddyReplicationEnabled></config>";
- Element element = XmlConfigHelper.stringToElement(xmlConfig);
- BuddyReplicationConfig config =
XmlConfigurationParserOld.parseBuddyReplicationConfig(element);
+ String xmlConfig = "<buddyReplication
enabled=\"true\"/>";
+ BuddyReplicationConfig config = getBuddyReplicationConfig(xmlConfig);
cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object,
Object>().createCache(false);
cache.getConfiguration().setBuddyReplicationConfig(config);
cache.create();
Modified:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -20,8 +20,8 @@
import org.jboss.cache.loader.DummyInMemoryCacheLoader;
import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.config.parsing.XmlConfigHelper;
-import org.jboss.cache.config.parsing.CacheLoadersElementParser;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.element.LoadersElementParser;
+import org.jboss.cache.config.parsing.element.BuddyElementParser;
import org.jgroups.Address;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
@@ -130,18 +130,30 @@
{
CacheSPI<Object, Object> c = (CacheSPI<Object, Object>) new
DefaultCacheFactory<Object,
Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC,
false, false, true), false);
c.getConfiguration().setClusterName("BuddyReplicationTest");
- // basic config
- String xmlString =
"<config><buddyReplicationEnabled>true</buddyReplicationEnabled>\n"
+
-
"<buddyCommunicationTimeout>500000</buddyCommunicationTimeout>\n" +
- "
<buddyLocatorClass>org.jboss.cache.buddyreplication.NextMemberBuddyLocator</buddyLocatorClass>\n"
+
- " <autoDataGravitation>" + useDataGravitation +
"</autoDataGravitation>\n" +
- " <dataGravitationRemoveOnFind>" + removeOnFind +
"</dataGravitationRemoveOnFind>\n" +
- " <buddyLocatorProperties>numBuddies = " +
numBuddies + "</buddyLocatorProperties>\n";
-
- if (buddyPoolName != null) xmlString += "<buddyPoolName>" +
buddyPoolName + "</buddyPoolName>";
- xmlString += "</config>";
- Element element = XmlConfigHelper.stringToElement(xmlString);
- BuddyReplicationConfig config =
XmlConfigurationParserOld.parseBuddyReplicationConfig(element);
+ String buddyPoolNameStr = buddyPoolName != null ? "buddyPoolName=\""
+ buddyPoolName + "\"" : "";
+ String xmlStr =
+ " <buddyReplication enabled=\"true\" " +
buddyPoolNameStr + " buddyCommunicationTimeout=\"500000\">\n" +
+ " <dataGravitation auto=\"" + useDataGravitation +
"\" removeOnFind=\""+ removeOnFind + "\"
searchBackupTrees=\"true\"/>\n" +
+ " <buddyLocator
class=\"org.jboss.cache.buddyreplication.NextMemberBuddyLocator\">\n" +
+ " <properties>\n" +
+ " numBuddies = " + numBuddies +"\n" +
+ " </properties>\n" +
+ " </buddyLocator>\n" +
+ " </buddyReplication>";
+// // basic config
+// String xmlString =
"<config><buddyReplicationEnabled>true</buddyReplicationEnabled>\n"
+
+//
"<buddyCommunicationTimeout>500000</buddyCommunicationTimeout>\n" +
+// "
<buddyLocatorClass>org.jboss.cache.buddyreplication.NextMemberBuddyLocator</buddyLocatorClass>\n"
+
+// " <autoDataGravitation>" + useDataGravitation +
"</autoDataGravitation>\n" +
+// " <dataGravitationRemoveOnFind>" + removeOnFind +
"</dataGravitationRemoveOnFind>\n" +
+// " <buddyLocatorProperties>numBuddies = " +
numBuddies + "</buddyLocatorProperties>\n";
+//
+// if (buddyPoolName != null) xmlString += "<buddyPoolName>" +
buddyPoolName + "</buddyPoolName>";
+// xmlString += "</config>";
+ BuddyElementParser parser = new BuddyElementParser();
+ Element element = XmlConfigHelper.stringToElement(xmlStr);
+ BuddyReplicationConfig config = parser.parseBuddyElement(element);
+// BuddyReplicationConfig config =
XmlConfigurationParserOld.parseBuddyReplicationConfig(element);
c.getConfiguration().setBuddyReplicationConfig(config);
c.getConfiguration().setFetchInMemoryState(true);
@@ -226,14 +238,14 @@
CacheSPI cache = createCache(1, null, useDataGravitation, removeOnFind, false);
String xmlStr = " " +
- " <cacheLoaders passivation=\"" + passivation +
"\" shared=\"false\">\n" +
+ " <loaders passivation=\"" + passivation +
"\" shared=\"false\">\n" +
" <preload/>\n" +
- " <cacheLoader class=\"" +
DummyInMemoryCacheLoader.class.getName() + "\" async=\"false\"
fetchPersistentState=\""+ fetchPersistent + "\"/>\n" +
- " </cacheLoaders>";
+ " <loader class=\"" +
DummyInMemoryCacheLoader.class.getName() + "\" async=\"false\"
fetchPersistentState=\""+ fetchPersistent + "\"/>\n" +
+ " </loaders>";
System.out.println("xmlStr = +\n" + xmlStr);
Element xmlEl = XmlConfigHelper.stringToElement(xmlStr);
- CacheLoadersElementParser parser = new CacheLoadersElementParser();
- CacheLoaderConfig config = parser.parseCacheLoadersElement(xmlEl);
+ LoadersElementParser parser = new LoadersElementParser();
+ CacheLoaderConfig config = parser.parseLoadersElement(xmlEl);
cache.getConfiguration().setCacheLoaderConfig(config);
if (start)
{
Modified: core/trunk/src/test/java/org/jboss/cache/config/ConfigurationCloningTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/config/ConfigurationCloningTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/config/ConfigurationCloningTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -22,7 +22,7 @@
import
org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
import org.jboss.cache.eviction.LRUPolicy;
import org.testng.annotations.Test;
@@ -42,7 +42,7 @@
public void testClone() throws Exception
{
- XmlConfigurationParserOld parser = new XmlConfigurationParserOld();
+ XmlConfigurationParser2x parser = new XmlConfigurationParser2x();
Configuration c = parser.parseFile(DEFAULT_CONFIGURATION_FILE);
try {
Modified: core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++ core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -12,7 +12,7 @@
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.transaction.TransactionSetup;
import org.testng.annotations.Test;
@@ -47,7 +47,7 @@
public void testMultiplexerStack() throws Exception
{
- XmlConfigurationParserOld parser = new XmlConfigurationParserOld();
+ XmlConfigurationParser2x parser = new XmlConfigurationParser2x();
Configuration conf =
parser.parseFile("META-INF/conf-test/mux-service.xml");
// test that multiplexer settings have been read in properly.
Modified:
core/trunk/src/test/java/org/jboss/cache/config/StringPropertyReplacementTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/config/StringPropertyReplacementTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/config/StringPropertyReplacementTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -17,7 +17,7 @@
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.eviction.LRUConfiguration;
import org.jboss.cache.eviction.LRUPolicy;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -93,7 +93,7 @@
System.setProperty(MAX_NODES_PROP, "1000");
System.setProperty(BUDDY_POOL_PROP, "replaced");
- Configuration cfg = new
XmlConfigurationParserOld().parseFile(STRING_REPLACED_FILE);
+ Configuration cfg = new
XmlConfigurationParser2x().parseFile(STRING_REPLACED_FILE);
assertEquals(NodeLockingScheme.OPTIMISTIC, cfg.getNodeLockingScheme());
assertEquals(CacheMode.REPL_SYNC, cfg.getCacheMode());
Added:
core/trunk/src/test/java/org/jboss/cache/config/parsing/BuddyElementParserTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/BuddyElementParserTest.java
(rev 0)
+++
core/trunk/src/test/java/org/jboss/cache/config/parsing/BuddyElementParserTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -0,0 +1,75 @@
+package org.jboss.cache.config.parsing;
+
+import org.testng.annotations.Test;
+import org.w3c.dom.Element;
+import org.jboss.cache.config.BuddyReplicationConfig;
+import org.jboss.cache.config.parsing.element.BuddyElementParser;
+import org.jboss.cache.buddyreplication.NextMemberBuddyLocator;
+
+/**
+ * Tester class for {@link org.jboss.cache.config.parsing.element.BuddyElementParser}.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+@Test(groups = "unit")
+public class BuddyElementParserTest
+{
+
+ /** one instance per all tests as it is stateless */
+ BuddyElementParser parser = new BuddyElementParser();
+
+
+ /**
+ * Test default values for unspecified elements.
+ */
+ public void testDefaultValues() throws Exception
+ {
+ String xmlConfig = "<buddyReplication
enabled=\"true\"/>";
+ Element element = XmlConfigHelper.stringToElement(xmlConfig);
+ BuddyReplicationConfig brConfig = parser.parseBuddyElement(element);
+ assert
brConfig.getBuddyLocatorConfig().getClassName().equals(NextMemberBuddyLocator.class.getName())
: "default buddy locator class is NextMemberBuddyLocator";
+ assert brConfig.getBuddyLocatorConfig().getBuddyLocatorProperties().isEmpty();
+ assert brConfig.isDataGravitationRemoveOnFind() : "default to true";
+ assert brConfig.isDataGravitationSearchBackupTrees() : "default to
true";
+ assert brConfig.isAutoDataGravitation() : "default to false";
+ }
+
+ /**
+ * If NextMemberBuddyLocator is set as buddy locator, but no params are being
specified for it, make sure that
+ * default values for numBudies and ignoreColocatedBuddies are present.
+ */
+ public void testDefaultParamsForNextMemberBuddyLocator() throws Exception
+ {
+ String xmlConfig =
+ " <buddyReplication enabled=\"true\"
buddyPoolName=\"groupOne\">\n" +
+ " <buddyLocator>\n" +
+ " <properties>\n" +
+ " numBuddies = 3\n" +
+ " </properties>\n" +
+ " </buddyLocator>\n" +
+ " </buddyReplication>";
+ Element element = XmlConfigHelper.stringToElement(xmlConfig);
+ BuddyReplicationConfig brConfig = parser.parseBuddyElement(element);
+ assert
brConfig.getBuddyLocatorConfig().getClassName().equals(NextMemberBuddyLocator.class.getName())
: "default buddy locator class is NextMemberBuddyLocator";
+ assert
brConfig.getBuddyLocatorConfig().getBuddyLocatorProperties().get("numBuddies").equals("3");
+ assert brConfig.getBuddyLocatorConfig().getBuddyLocatorProperties().size() == 1;
+ }
+
+ public void testNormalConfig() throws Exception
+ {
+ String xmlConfig =
+ " <buddyReplication enabled=\"true\"
buddyPoolName=\"groupOne\">\n" +
+ " <buddyLocator>\n" +
+ " <properties>\n" +
+ " numBuddies = 3\n" +
+ " </properties>\n" +
+ " </buddyLocator>\n" +
+ " </buddyReplication>";
+ Element element = XmlConfigHelper.stringToElement(xmlConfig);
+ BuddyReplicationConfig brConfig = parser.parseBuddyElement(element);
+ assert brConfig.isEnabled();
+ assert brConfig.getBuddyPoolName().equals("groupOne");
+ assert
brConfig.getBuddyLocatorConfig().getBuddyLocatorProperties().get("numBuddies").equals("3");
+ }
+}
Modified:
core/trunk/src/test/java/org/jboss/cache/config/parsing/CacheLoadersElementParserTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/config/parsing/CacheLoadersElementParserTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/config/parsing/CacheLoadersElementParserTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -3,9 +3,12 @@
import org.testng.annotations.Test;
import org.w3c.dom.Element;
import org.jboss.cache.config.CacheLoaderConfig;
+import org.jboss.cache.config.parsing.element.LoadersElementParser;
+import java.util.List;
+
/**
- * Tester class for {@link CacheLoadersElementParser}
+ * Tester class for {@link org.jboss.cache.config.parsing.element.LoadersElementParser}
*
* @author Mircea.Markus(a)jboss.com
* @since 3.0
@@ -13,28 +16,26 @@
@Test(groups = "unit")
public class CacheLoadersElementParserTest
{
- CacheLoadersElementParser parser = new CacheLoadersElementParser();
+ LoadersElementParser parser = new LoadersElementParser();
public void simpleParse() throws Exception
{
-
String xmlStr = " " +
- " <cacheLoaders passivation=\"false\"
shared=\"false\">\n" +
+ " <loaders passivation=\"false\"
shared=\"false\">\n" +
" <preload>\n" +
" <node fqn=\"/\"/>\n" +
" </preload>\n" +
- " <cacheLoader
class=\"org.jboss.cache.loader.JDBCCacheLoader\" async=\"true\"
fetchPersistentState=\"false\"\n" +
+ " <loader
class=\"org.jboss.cache.loader.JDBCCacheLoader\" async=\"true\"
fetchPersistentState=\"false\"\n" +
" ignoreModifications=\"false\"
purgeOnStartup=\"false\">\n" +
" <properties>\n" +
" cache.jdbc.table.name=jbosscache\n" +
" cache.jdbc.table.create=true\n" +
" cache.jdbc.table.drop=true\n" +
" </properties>\n" +
- " </cacheLoader>\n" +
- " </cacheLoaders>";
- Element element = XmlConfigHelper.stringToElement(xmlStr);
- CacheLoaderConfig config = parser.parseCacheLoadersElement(element);
+ " </loader>\n" +
+ " </loaders>";
+ CacheLoaderConfig config = getCacheLoaderConfig(xmlStr);
assert !config.isPassivation();
assert !config.isShared();
assert config.getPreload().equals("/");
@@ -45,20 +46,100 @@
assert !config.getFirstCacheLoaderConfig().isPurgeOnStartup();
}
+
/**
- * If so an empty preload string should apear.
+ * Tests that if no values are specified the parser sets default config values.
*/
- public void testMissingPreloadNodes() throws Exception
+ public void testDefaultValues() throws Exception
{
+ String xmlStr =
+ " <loaders passivation=\"false\">\n" +
+ " <preload/>\n" +
+ " <loader
class=\"org.jboss.cache.loader.JDBCCacheLoader\">" +
+ " <singletonStore/>\n" +
+ " </loader>"+
+ " </loaders>";
+ CacheLoaderConfig config = getCacheLoaderConfig(xmlStr);
+ assert config.getPreload().equals("/") : "the default value for
preload is root";
+ assert !config.getFirstCacheLoaderConfig().isAsync() : "by default CL are
sync";
+ assert !config.isShared() : "by default the cl are not sared";
+ assert !config.getFirstCacheLoaderConfig().isIgnoreModifications();
+ assert !config.getFirstCacheLoaderConfig().isPurgeOnStartup();
+ assert
!config.getFirstCacheLoaderConfig().getSingletonStoreConfig().isSingletonStoreEnabled();
+ assert
config.getFirstCacheLoaderConfig().getSingletonStoreConfig().getSingletonStoreClass().equals("org.jboss.cache.loader.SingletonStoreCacheLoader");
+ assert
config.getFirstCacheLoaderConfig().getSingletonStoreConfig().getSingletonStoreClass().equals("org.jboss.cache.loader.SingletonStoreCacheLoader");
+ }
+
+ public void testMultiplePreloadNodes() throws Exception
+ {
String xmlStr = " " +
- " <cacheLoaders passivation=\"false\"
shared=\"false\">\n" +
- " <preload/>\n" +
- " <cacheLoader
class=\"org.jboss.cache.loader.JDBCCacheLoader\" async=\"true\"
fetchPersistentState=\"false\"\n" +
- " ignoreModifications=\"false\"
purgeOnStartup=\"false\"/>\n" +
- " </cacheLoaders>";
+ " <loaders passivation=\"false\"
shared=\"false\">\n" +
+ " <preload>\n" +
+ " <node fqn=\"/\"/>\n" +
+ " <node fqn=\"/a\"/>\n" +
+ " <node fqn=\"/a/b\"/>\n" +
+ " </preload>\n" +
+ " <loader
class=\"org.jboss.cache.loader.JDBCCacheLoader\" async=\"true\"
fetchPersistentState=\"false\"\n" +
+ " ignoreModifications=\"false\"
purgeOnStartup=\"false\">\n" +
+ " </loader>" +
+ "</loaders>";
+ CacheLoaderConfig config = getCacheLoaderConfig(xmlStr);
+ assert config.getPreload().equals("/,/a,/a/b");
+ assert config.getFirstCacheLoaderConfig().getSingletonStoreConfig() == null;
+ }
+
+ public void testMultipleCacheLoaders() throws Exception
+ {
+ String xml =
+ " <loaders passivation=\"false\"
shared=\"false\">\n" +
+ " <preload/>\n" +
+ " <loader
class=\"org.jboss.cache.loader.JDBCCacheLoader\" async=\"true\"
fetchPersistentState=\"true\"\n" +
+ " ignoreModifications=\"true\"
purgeOnStartup=\"true\"/>\n" +
+ " <loader
class=\"org.jboss.cache.loader.bdbje.BdbjeCacheLoader\" async=\"true\"
fetchPersistentState=\"true\"\n" +
+ " ignoreModifications=\"true\"
purgeOnStartup=\"true\"/>\n" +
+ " <loader
class=\"org.jboss.cache.loader.FileCacheLoader\" async=\"true\"
fetchPersistentState=\"true\"\n" +
+ " ignoreModifications=\"true\"
purgeOnStartup=\"true\"/>\n" +
+ " </loaders>";
+ CacheLoaderConfig clConfig = getCacheLoaderConfig(xml);
+ List<CacheLoaderConfig.IndividualCacheLoaderConfig> indClConfigs =
clConfig.getIndividualCacheLoaderConfigs();
+ assert indClConfigs.size() == 3;
+ assert
indClConfigs.get(0).getClassName().equals("org.jboss.cache.loader.JDBCCacheLoader");
+ assert
indClConfigs.get(1).getClassName().equals("org.jboss.cache.loader.bdbje.BdbjeCacheLoader");
+ assert
indClConfigs.get(2).getClassName().equals("org.jboss.cache.loader.FileCacheLoader");
+
+ }
+
+ public void testSingletonStoreDisaled() throws Exception
+ {
+ String xml =
+ " <loaders passivation=\"true\"
shared=\"true\">\n" +
+ " <preload/>\n" +
+ " <loader
class=\"org.jboss.cache.loader.JDBCCacheLoader\" async=\"true\"
fetchPersistentState=\"true\"\n" +
+ " ignoreModifications=\"true\"
purgeOnStartup=\"true\">\n" +
+ " <singletonStore enabled=\"false\"
class=\"org.jboss.cache.loader.SingletonStoreCacheLoader\">\n" +
+ " <properties>\n" +
+ " pushStateWhenCoordinator=some\n" +
+ " pushStateWhenCoordinatorTimeout=cus\n" +
+ " </properties>\n" +
+ " </singletonStore>\n" +
+ " </loader>\n" +
+ " </loaders>";
+ CacheLoaderConfig clc = getCacheLoaderConfig(xml);
+ CacheLoaderConfig.IndividualCacheLoaderConfig icl =
clc.getFirstCacheLoaderConfig();
+ CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig
singletonStoreConfig = icl.getSingletonStoreConfig();
+ assert singletonStoreConfig != null;
+ assert !singletonStoreConfig.isSingletonStoreEnabled();
+ assert
singletonStoreConfig.getSingletonStoreClass().equals("org.jboss.cache.loader.SingletonStoreCacheLoader");
+ assert singletonStoreConfig.getProperties().size() == 2;
+ assert
singletonStoreConfig.getProperties().get("pushStateWhenCoordinator").equals("some");
+ assert
singletonStoreConfig.getProperties().get("pushStateWhenCoordinatorTimeout").equals("cus");
+
+ }
+
+ private CacheLoaderConfig getCacheLoaderConfig(String xmlStr)
+ throws Exception
+ {
Element element = XmlConfigHelper.stringToElement(xmlStr);
- CacheLoaderConfig config = parser.parseCacheLoadersElement(element);
- assert config.getPreload().length() == 0;
+ return parser.parseLoadersElement(element);
}
-
}
Added:
core/trunk/src/test/java/org/jboss/cache/config/parsing/JGroupsStackParserTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/JGroupsStackParserTest.java
(rev 0)
+++
core/trunk/src/test/java/org/jboss/cache/config/parsing/JGroupsStackParserTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -0,0 +1,77 @@
+package org.jboss.cache.config.parsing;
+
+import org.testng.annotations.Test;
+import org.w3c.dom.Element;
+
+/**
+ * Tester class for {@link org.jboss.cache.config.parsing.JGroupsStackParser}
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+@Test(groups = "unit")
+public class JGroupsStackParserTest
+{
+ private JGroupsStackParser parser = new JGroupsStackParser();
+
+ public void testSimpleParse() throws Exception
+ {
+ String xml =
+ "<jgroupsConfig>\n" +
+ "<UDP mcast_addr=\"228.10.10.10\"\n" +
+ " mcast_port=\"45588\"\n" +
+ " tos=\"8\"\n" +
+ " ucast_recv_buf_size=\"20000000\"\n" +
+ " ucast_send_buf_size=\"640000\"\n" +
+ " mcast_recv_buf_size=\"25000000\"\n" +
+ " mcast_send_buf_size=\"640000\"\n" +
+ " loopback=\"false\"\n" +
+ " discard_incompatible_packets=\"true\"\n"
+
+ " max_bundle_size=\"64000\"\n" +
+ " max_bundle_timeout=\"30\"\n" +
+ " use_incoming_packet_handler=\"true\"\n"
+
+ " ip_ttl=\"2\"\n" +
+ " enable_bundling=\"false\"\n" +
+ " enable_diagnostics=\"true\"\n" +
+ " use_concurrent_stack=\"true\"\n" +
+ " thread_naming_pattern=\"pl\"\n" +
+ " thread_pool.enabled=\"true\"\n" +
+ " thread_pool.min_threads=\"1\"\n" +
+ " thread_pool.max_threads=\"25\"\n" +
+ " thread_pool.keep_alive_time=\"30000\"\n"
+
+ " thread_pool.queue_enabled=\"true\"\n" +
+ " thread_pool.queue_max_size=\"10\"\n" +
+ " thread_pool.rejection_policy=\"Run\"\n"
+
+ " oob_thread_pool.enabled=\"true\"\n" +
+ " oob_thread_pool.min_threads=\"1\"\n" +
+ " oob_thread_pool.max_threads=\"4\"\n" +
+ "
oob_thread_pool.keep_alive_time=\"10000\"\n" +
+ " oob_thread_pool.queue_enabled=\"true\"\n"
+
+ " oob_thread_pool.queue_max_size=\"10\"\n"
+
+ "
oob_thread_pool.rejection_policy=\"Run\"/>\n" +
+ " <PING timeout=\"2000\"
num_initial_members=\"3\"/>\n" +
+ " <MERGE2 max_interval=\"30000\"
min_interval=\"10000\"/>\n" +
+ " <FD_SOCK/>\n" +
+ " <FD timeout=\"10000\" max_tries=\"5\"
shun=\"true\"/>\n" +
+ " <VERIFY_SUSPECT timeout=\"1500\"/>\n" +
+ " <pbcast.NAKACK max_xmit_size=\"60000\"\n"
+
+ " use_mcast_xmit=\"false\"
gc_lag=\"0\"\n" +
+ "
retransmit_timeout=\"300,600,1200,2400,4800\"\n" +
+ "
discard_delivered_msgs=\"true\"/>\n" +
+ " <UNICAST
timeout=\"300,600,1200,2400,3600\"/>\n" +
+ " <pbcast.STABLE stability_delay=\"1000\"
desired_avg_gossip=\"50000\"\n" +
+ " max_bytes=\"400000\"/>\n" +
+ " <pbcast.GMS print_local_addr=\"true\"
join_timeout=\"5000\"\n" +
+ " join_retry_timeout=\"2000\"
shun=\"false\"\n" +
+ " view_bundling=\"true\"
view_ack_collection_timeout=\"5000\"/>\n" +
+ " <FRAG2 frag_size=\"60000\"/>\n" +
+ " <pbcast.STREAMING_STATE_TRANSFER
use_reading_thread=\"true\"/>\n" +
+ " <pbcast.FLUSH timeout=\"0\"/>\n" +
+ "</jgroupsConfig>";
+ Element element = XmlConfigHelper.stringToElement(xml);
+ String result = parser.parseClusterConfigXml(element);
+ assert result.indexOf("ucast_recv_buf_size=20000000") > 0;
+ assert result.indexOf("num_initial_members=3") > 0;
+ assert result.indexOf("min_interval=10000") > 0;
+ }
+}
Modified:
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -224,4 +224,18 @@
assert
interceptorConfigs.get(3).getBeforeClass().equals("org.jboss.cache.interceptors.CallInterceptor");
assert
interceptorConfigs.get(4).getAfterClass().equals("org.jboss.cache.interceptors.CallInterceptor");
}
+
+ public void testSingletonStore()
+ {
+ CacheLoaderConfig.IndividualCacheLoaderConfig clc =
config.getCacheLoaderConfig().getFirstCacheLoaderConfig();
+ assert clc != null;
+ CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig singlStoreConf =
clc.getSingletonStoreConfig();
+ assert singlStoreConf != null;
+ assert singlStoreConf.isSingletonStoreEnabled();
+ assert
singlStoreConf.getSingletonStoreClass().equals("org.jboss.cache.loader.SingletonStoreCacheLoader");
+ assert singlStoreConf.getProperties().size() == 2;
+ assert
singlStoreConf.getProperties().get("pushStateWhenCoordinator").equals("true");
+ assert
singlStoreConf.getProperties().get("pushStateWhenCoordinatorTimeout").equals("20000");
+
+ }
}
Modified:
core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeConfigurationTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeConfigurationTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeConfigurationTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -11,7 +11,7 @@
import static org.testng.AssertJUnit.fail;
import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.parsing.EvictionElementParser;
+import org.jboss.cache.config.parsing.element.EvictionElementParser;
import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/FIFOConfigurationTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/eviction/FIFOConfigurationTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/eviction/FIFOConfigurationTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -11,7 +11,7 @@
import static org.testng.AssertJUnit.fail;
import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.parsing.EvictionElementParser;
+import org.jboss.cache.config.parsing.element.EvictionElementParser;
import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LFUConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LFUConfigurationTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LFUConfigurationTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -8,7 +8,7 @@
import static org.testng.AssertJUnit.assertEquals;
-import org.jboss.cache.config.parsing.EvictionElementParser;
+import org.jboss.cache.config.parsing.element.EvictionElementParser;
import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfigurationTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfigurationTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -10,7 +10,7 @@
import static org.testng.AssertJUnit.assertTrue;
import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.parsing.EvictionElementParser;
+import org.jboss.cache.config.parsing.element.EvictionElementParser;
import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfigurationTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfigurationTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -10,7 +10,7 @@
import static org.testng.AssertJUnit.assertTrue;
import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.parsing.EvictionElementParser;
+import org.jboss.cache.config.parsing.element.EvictionElementParser;
import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -8,7 +8,7 @@
import static org.testng.AssertJUnit.fail;
-import org.jboss.cache.config.parsing.EvictionElementParser;
+import org.jboss.cache.config.parsing.element.EvictionElementParser;
import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -3,9 +3,12 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.RegionManager;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.EvictionConfig;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.EvictionPolicyConfig;
+import org.jboss.cache.config.EvictionRegionConfig;
+import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.interceptors.EvictionInterceptor;
import org.jboss.cache.util.TestingUtil;
@@ -55,30 +58,31 @@
private EvictionConfig buildEvictionConfig() throws Exception
{
- String xml = " <attribute
name=\"EvictionPolicyConfig\">\n" +
- " <config>\n" +
- " <attribute
name=\"wakeUpIntervalSeconds\">1</attribute>\n" +
- " <!-- Name of the DEFAULT eviction policy
class.-->\n" +
- " <attribute
name=\"policyClass\">org.jboss.cache.eviction.LRUPolicy</attribute>\n"
+
- " <region name=\"/_default_\">\n" +
- " <attribute
name=\"maxNodes\">10</attribute>\n" +
- " <attribute
name=\"timeToLiveSeconds\">0</attribute>\n" +
- " <attribute
name=\"maxAgeSeconds\">0</attribute>\n" +
- " </region>\n" +
- " <region name=\"/testingRegion\">\n" +
- " <attribute
name=\"maxNodes\">10</attribute>\n" +
- " <attribute
name=\"timeToLiveSeconds\">0</attribute>\n" +
- " <attribute
name=\"maxAgeSeconds\">0</attribute>\n" +
- " </region>\n" +
- " <region name=\"/timeBased\">\n" +
- " <attribute
name=\"maxNodes\">10</attribute>\n" +
- " <attribute
name=\"timeToLiveSeconds\">1</attribute>\n" +
- " <attribute
name=\"maxAgeSeconds\">1</attribute>\n" +
- " </region>\n" +
- " </config>\n" +
- " </attribute>";
- Element element = XmlConfigHelper.stringToElement(xml);
- return XmlConfigurationParserOld.parseEvictionConfig(element);
+ EvictionConfig result = new
EvictionConfig("org.jboss.cache.eviction.LRUPolicy");
+ result.setWakeupInterval(1000);
+
+ LRUConfiguration lruConfiguration = new LRUConfiguration();
+ lruConfiguration.setMaxNodes(10);
+ lruConfiguration.setTimeToLive(0);
+ lruConfiguration.setMaxAge(0);
+ EvictionRegionConfig erConfig1 = new
EvictionRegionConfig(RegionManager.DEFAULT_REGION, lruConfiguration);
+
+ LRUConfiguration lruConfiguration2 = new LRUConfiguration();
+ lruConfiguration2.setMaxNodes(10);
+ lruConfiguration2.setTimeToLive(0);
+ lruConfiguration2.setMaxAge(0);
+ EvictionRegionConfig erConfig2 = new
EvictionRegionConfig(Fqn.fromString("/testingRegion"), lruConfiguration2);
+
+ LRUConfiguration lruConfiguration3 = new LRUConfiguration();
+ lruConfiguration3.setMaxNodes(10);
+ lruConfiguration3.setTimeToLive(1000);
+ lruConfiguration3.setMaxAge(1000);
+ EvictionRegionConfig erConfig3 = new
EvictionRegionConfig(Fqn.fromString("/timeBased"), lruConfiguration3);
+
+ result.getEvictionRegionConfigs().add(erConfig1);
+ result.getEvictionRegionConfigs().add(erConfig2);
+ result.getEvictionRegionConfigs().add(erConfig3);
+ return result;
}
@AfterMethod(alwaysRun = true)
Modified:
core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -31,7 +31,7 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.lock.IsolationLevel;
@@ -51,18 +51,18 @@
@Test(groups = {"functional"})
public class ProgrammaticLRUPolicyTest
{
- CacheSPI<Object, Object> cache_;
- int wakeupIntervalMillis_ = 0;
+ CacheSPI<Object, Object> cache;
+ int wakeupIntervalMillis = 0;
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
initCaches();
- wakeupIntervalMillis_ =
cache_.getConfiguration().getEvictionConfig().getWakeupIntervalSeconds() * 1000;
- log("wakeupInterval is " + wakeupIntervalMillis_);
- if (wakeupIntervalMillis_ < 0)
+ wakeupIntervalMillis =
cache.getConfiguration().getEvictionConfig().getWakeupIntervalSeconds() * 1000;
+ log("wakeupInterval is " + wakeupIntervalMillis);
+ if (wakeupIntervalMillis < 0)
{
- fail("testEviction(): eviction thread wake up interval is illegal " +
wakeupIntervalMillis_);
+ fail("testEviction(): eviction thread wake up interval is illegal " +
wakeupIntervalMillis);
}
}
@@ -71,35 +71,33 @@
{
Configuration conf =
UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL,
true);
CacheFactory<Object, Integer> instance = new DefaultCacheFactory();
- cache_ = (CacheSPI) instance.createCache(conf, false);
+ cache = (CacheSPI) instance.createCache(conf, false);
conf.getEvictionConfig().setWakeupIntervalSeconds(5);
-
cache_.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- cache_.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
+
cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
- cache_.create();
- cache_.start();
+ cache.create();
+ cache.start();
}
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- cache_.stop();
+ cache.stop();
}
private void addStringBasedRegion() throws Exception
{
- // region name is ignored here.
- String xml = "<region name=\"/dummy\">" +
- "<attribute
name=\"maxNodes\">10000</attribute>" +
- "<attribute
name=\"timeToLiveSeconds\">4</attribute>" +
- "</region>";
- Element element = XmlConfigHelper.stringToElement(xml);
- RegionManager regionManager = cache_.getRegionManager();
- EvictionConfig topConfig = cache_.getConfiguration().getEvictionConfig();
- EvictionRegionConfig erc =
XmlConfigurationParserOld.parseEvictionRegionConfig(element,
topConfig.getDefaultEvictionPolicyClass(), topConfig.getDefaultEventQueueSize());
+ LRUConfiguration lruConfig = new LRUConfiguration();
+ lruConfig.setMaxNodes(1000);
+ lruConfig.setTimeToLive(4000);
+ EvictionRegionConfig regConfig = new
EvictionRegionConfig(Fqn.fromString("/dummy"), lruConfig);
+
+ RegionManager regionManager = cache.getRegionManager();
+ EvictionConfig topConfig = cache.getConfiguration().getEvictionConfig();
regionManager.setEvictionConfig(topConfig);
// Fqn is the region name
- regionManager.getRegion("/programmatic",
true).setEvictionPolicy(erc.getEvictionPolicyConfig());
+ regionManager.getRegion("/programmatic",
true).setEvictionPolicy(regConfig.getEvictionPolicyConfig());
}
public void testStringBasedFqnEviction() throws Exception
@@ -111,36 +109,24 @@
{
String str = rootStr + i;
Fqn<String> fqn = Fqn.fromString(str);
- cache_.put(fqn, str, str);
+ cache.put(fqn, str, str);
}
- String val = (String) cache_.get(rootStr + "3", rootStr +
"3");
+ String val = (String) cache.get(rootStr + "3", rootStr + "3");
assertNotNull("DataNode should be empty ", val);
- System.out.println(cache_.toString());
- TestingUtil.sleepThread(2 * wakeupIntervalMillis_ + 500);
- System.out.println(cache_.toString());
- val = (String) cache_.get(rootStr + "3", rootStr + "3");
+ System.out.println(cache.toString());
+ TestingUtil.sleepThread(2 * wakeupIntervalMillis + 500);
+ System.out.println(cache.toString());
+ val = (String) cache.get(rootStr + "3", rootStr + "3");
assertNull("DataNode should be empty ", val);
}
private void addObjectBasedRegion() throws Exception
{
- // region name is ignored here.
- String xml = "<region name=\"/dummy\">" +
- "<attribute
name=\"maxNodes\">10000</attribute>" +
- "<attribute
name=\"timeToLiveSeconds\">4</attribute>" +
- "</region>";
- Element element = XmlConfigHelper.stringToElement(xml);
- RegionManager regionManager = cache_.getRegionManager();
- EvictionConfig topEC = cache_.getConfiguration().getEvictionConfig();
- EvictionRegionConfig erc =
XmlConfigurationParserOld.parseEvictionRegionConfig(element,
- topEC.getDefaultEvictionPolicyClass(),
- topEC.getDefaultEventQueueSize());
- // Fqn is the region name
- Integer ii = 1;
- Fqn fqn = Fqn.fromElements(ii);
- regionManager.getRegion(fqn,
true).setEvictionPolicy(erc.getEvictionPolicyConfig());
+ LRUConfiguration lruConfig = new LRUConfiguration(4000, 1000);
+ RegionManager regionManager = cache.getRegionManager();
+ regionManager.getRegion(Fqn.fromElements(1), true).setEvictionPolicy(lruConfig);
}
public void testObjectBasedFqnEviction1() throws Exception
@@ -155,7 +141,7 @@
Fqn fqn = Fqn.fromElements(rootStr, in);
try
{
- cache_.put(fqn, str, str);
+ cache.put(fqn, str, str);
}
catch (Exception e)
{
@@ -168,7 +154,7 @@
Fqn fqn = Fqn.fromElements(rootStr, in);
try
{
- String val = (String) cache_.get(fqn, in);
+ String val = (String) cache.get(fqn, in);
assertNull("DataNode should be empty ", val);
}
catch (Exception e)
@@ -177,13 +163,13 @@
fail("Failed to get" + e);
}
- System.out.println(cache_.toString());
- TestingUtil.sleepThread(2 * wakeupIntervalMillis_ + 500);
- System.out.println(cache_.toString());
+ System.out.println(cache.toString());
+ TestingUtil.sleepThread(2 * wakeupIntervalMillis + 500);
+ System.out.println(cache.toString());
try
{
- String val = (String) cache_.get(fqn, in);
+ String val = (String) cache.get(fqn, in);
assertNull("DataNode should be empty ", val);
}
catch (Exception e)
@@ -205,7 +191,7 @@
Fqn<Object> fqn = Fqn.fromRelativeElements(rootfqn, in);
try
{
- cache_.put(fqn, in, in);
+ cache.put(fqn, in, in);
}
catch (Exception e)
{
@@ -218,7 +204,7 @@
{
Integer in = 3;
Fqn<Object> fqn = Fqn.fromRelativeElements(rootfqn, in);
- Object val = cache_.get(fqn, in);
+ Object val = cache.get(fqn, in);
assertNotNull("DataNode should be empty ", val);
}
catch (Exception e)
@@ -227,14 +213,14 @@
fail("Failed to get" + e);
}
- System.out.println(cache_.toString());
- TestingUtil.sleepThread(2 * wakeupIntervalMillis_ + 500);
- System.out.println(cache_.toString());
+ System.out.println(cache.toString());
+ TestingUtil.sleepThread(2 * wakeupIntervalMillis + 500);
+ System.out.println(cache.toString());
try
{
Integer in = 3;
Fqn<Object> fqn = Fqn.fromRelativeElements(rootfqn, in);
- Object val = cache_.get(fqn, in);
+ Object val = cache.get(fqn, in);
assertNull("DataNode should be empty ", val);
}
catch (Exception e)
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/RegionManagerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/RegionManagerTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/RegionManagerTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -6,7 +6,7 @@
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionPolicyConfig;
import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
import org.jboss.cache.config.parsing.XmlConfigHelper;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.BeforeMethod;
@@ -103,47 +103,6 @@
assertNotSame("Region ", DEFAULT_REGION, region.getFqn());
}
- public void testConfigureWithXML() throws Exception
- {
- // test the new style configuration
- String xml = "<region name=\"/test/\"
policyClass=\"org.jboss.cache.eviction.LFUPolicy\">" +
- "<attribute name=\"minNodes\">10</attribute>"
+
- "<attribute name=\"maxNodes\">20</attribute>"
+
- "</region>";
- Element element = XmlConfigHelper.stringToElement(xml);
- RegionManager regionManager = new RegionManager();
- regionManager.setUsingEvictions(true);
- EvictionRegionConfig erc =
XmlConfigurationParserOld.parseEvictionRegionConfig(element, null,
EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT);
- Region region = regionManager.getRegion(erc.getRegionFqn(), true);
- region.setEvictionPolicy(erc.getEvictionPolicyConfig());
-
- assertTrue(region.getEvictionPolicy() instanceof LFUPolicy);
- assertTrue(region.getEvictionPolicyConfig() instanceof LFUConfiguration);
- LFUConfiguration config = (LFUConfiguration) region.getEvictionPolicyConfig();
- assertEquals(20, config.getMaxNodes());
- assertEquals(10, config.getMinNodes());
- assertEquals(Fqn.fromString("/test/"), region.getFqn());
-
- // test the 1.2.x style configuration
- xml = "<region name=\"abc\">" +
- "<attribute name=\"minNodes\">10</attribute>"
+
- "<attribute name=\"maxNodes\">20</attribute>"
+
- "</region>";
- element = XmlConfigHelper.stringToElement(xml);
- erc = XmlConfigurationParserOld.parseEvictionRegionConfig(element,
"org.jboss.cache.eviction.LFUPolicy", EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT);
- regionManager = new RegionManager();
- regionManager.setUsingEvictions(true);
- region = regionManager.getRegion(erc.getRegionFqn(), true);
- region.setEvictionPolicy(erc.getEvictionPolicyConfig());
-
- assertTrue(region.getEvictionPolicy() instanceof LFUPolicy);
- assertTrue(region.getEvictionPolicyConfig() instanceof LFUConfiguration);
- config = (LFUConfiguration) region.getEvictionPolicyConfig();
- assertEquals(20, config.getMaxNodes());
- assertEquals(10, config.getMinNodes());
- assertEquals(Fqn.fromString("/abc/"), region.getFqn());
- }
-
public void testRegionOrdering() throws Exception
{
Fqn A_B_C_D_E = Fqn.fromString("/a/b/c/d/e/");
Modified:
core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -6,8 +6,9 @@
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.EvictionConfig;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
import org.jboss.cache.config.parsing.XmlConfigHelper;
+import org.jboss.cache.config.parsing.element.BuddyElementParser;
+import org.jboss.cache.config.parsing.element.LoadersElementParser;
import org.jboss.cache.interceptors.*;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.util.TestingUtil;
@@ -89,24 +90,20 @@
protected CacheLoaderConfig getCacheLoaderConfig(boolean pasv, boolean
fetchPersistentState) throws Exception
{
- String xml = " <config>\n" +
- " \n" +
- " <passivation>" + pasv +
"</passivation>\n" +
- " <preload></preload>\n" +
- "\n" +
- " <cacheloader>\n" +
- "
<class>org.jboss.cache.loader.FileCacheLoader</class>\n" +
- " <properties>\n" +
- " location=/tmp\n" +
- " </properties>\n" +
- " <async>false</async>\n" +
- " <fetchPersistentState>" +
fetchPersistentState + "</fetchPersistentState>\n" +
- "
<ignoreModifications>false</ignoreModifications>\n" +
- " </cacheloader>\n" +
- " \n" +
- " </config>";
- Element element = XmlConfigHelper.stringToElement(xml);
- return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
+ String xmlStr =
+ " <loaders passivation=\"" + pasv +
"\">\n" +
+ " <preload/>\n" +
+ " <loader
class=\"org.jboss.cache.loader.FileCacheLoader\"
fetchPersistentState=\"" + fetchPersistentState + "\"\n" +
+ " ignoreModifications=\"false\">\n"
+
+ " <properties>\n" +
+ " location=/tmp\n" +
+ " </properties>\n" +
+ " </loader>\n" +
+ " </loaders>";
+
+ Element element = XmlConfigHelper.stringToElement(xmlStr);
+ LoadersElementParser parser = new LoadersElementParser();
+ return parser.parseLoadersElement(element);
}
public void testSharedCacheLoaderConfig() throws Exception
@@ -386,15 +383,13 @@
public void testBuddyReplicationOptLocking() throws Exception
{
- String xmlString =
"<config><buddyReplicationEnabled>true</buddyReplicationEnabled>\n"
+
-
"<buddyCommunicationTimeout>600000</buddyCommunicationTimeout>\n" +
- "
<buddyLocatorClass>org.jboss.cache.buddyreplication.NextMemberBuddyLocator</buddyLocatorClass>\n"
+
- " <buddyLocatorProperties>numBuddies =
1</buddyLocatorProperties>\n";
-
- xmlString += "<buddyPoolName>buddyPoolName</buddyPoolName>";
- xmlString += "</config>";
- Element element = XmlConfigHelper.stringToElement(xmlString);
- BuddyReplicationConfig brc =
XmlConfigurationParserOld.parseBuddyReplicationConfig(element);
+ String xmlStr =
+ " <buddy enabled=\"true\"
buddyPoolName=\"buddyPoolName\"
buddyCommunicationTimeout=\"600000\">\n" +
+ " <dataGravitation auto=\"true\"
removeOnFind=\"true\" searchBackupTrees=\"true\"/>\n" +
+ " </buddy>";
+ Element element = XmlConfigHelper.stringToElement(xmlStr);
+ BuddyElementParser parser = new BuddyElementParser();
+ BuddyReplicationConfig brc = parser.parseBuddyElement(element);
cache.getConfiguration().setBuddyReplicationConfig(brc);
cache.getConfiguration().setCacheMode("REPL_SYNC");
@@ -425,17 +420,11 @@
public void testBuddyReplicationPessLocking() throws Exception
{
- String xmlString =
"<config><buddyReplicationEnabled>true</buddyReplicationEnabled>\n"
+
-
"<buddyCommunicationTimeout>600000</buddyCommunicationTimeout>\n" +
- "
<buddyLocatorClass>org.jboss.cache.buddyreplication.NextMemberBuddyLocator</buddyLocatorClass>\n"
+
- " <buddyLocatorProperties>numBuddies =
1</buddyLocatorProperties>\n";
-
- xmlString += "<buddyPoolName>buddyPoolName</buddyPoolName>";
- xmlString += "</config>";
- Element element = XmlConfigHelper.stringToElement(xmlString);
- BuddyReplicationConfig brc =
XmlConfigurationParserOld.parseBuddyReplicationConfig(element);
+ String xmlStr = "<buddy enabled=\"true\"
buddyPoolName=\"buddyPoolName\"
buddyCommunicationTimeout=\"600000\"/>";
+ Element element = XmlConfigHelper.stringToElement(xmlStr);
+ BuddyElementParser parser = new BuddyElementParser();
+ BuddyReplicationConfig brc = parser.parseBuddyElement(element);
cache.getConfiguration().setBuddyReplicationConfig(brc);
-
cache.getConfiguration().setCacheMode("REPL_SYNC");
cache.create();// initialise various subsystems such as BRManager
InterceptorChain chain =
getInterceptorChainFactory(cache).buildInterceptorChain();
Modified:
core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -11,9 +11,10 @@
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.config.ConfigurationException;
import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
import org.jboss.cache.config.parsing.ParsedAttributes;
import org.jboss.cache.config.parsing.XmlConfigHelper;
+import org.jboss.cache.config.parsing.element.LoadersElementParser;
import org.jboss.cache.eviction.LRUConfiguration;
import org.jboss.cache.transaction.TransactionSetup;
import org.jgroups.conf.XmlConfigurator;
@@ -78,34 +79,29 @@
return c;
}
- public static CacheLoaderConfig getSingleCacheLoaderConfig(String preload, String
cacheloaderClass, String properties, boolean async, boolean fetchPersistentState, boolean
shared) throws Exception
+ public static CacheLoaderConfig buildSingleCacheLoaderConfig(boolean passivation,
String preload, String cacheloaderClass,
+ String properties,
boolean async, boolean fetchPersistentState,
+ boolean shared, boolean
purgeOnStartup, boolean ignoreModifications) throws Exception
{
- return getSingleCacheLoaderConfig(preload, cacheloaderClass, properties, async,
fetchPersistentState, shared, false);
+ String xmlStr =
+ " <loaders passivation=\"" + passivation + "\"
shared=\"" + shared + "\">\n" +
+ " <loader class=\""+ cacheloaderClass + "\"
async=\"" + async + "\" fetchPersistentState=\"" +
fetchPersistentState + "\"\n" +
+ " purgeOnStartup=\"" + purgeOnStartup +
"\" ignoreModifications=\"" + ignoreModifications +
"\">\n" +
+ " <properties>" + properties +
"</properties>\n" +
+ " </loader>\n" +
+ " </loaders>";
+ Element xmlElement = XmlConfigHelper.stringToElement(xmlStr);
+ LoadersElementParser parser = new LoadersElementParser();
+ CacheLoaderConfig clConfig = parser.parseLoadersElement(xmlElement);
+ clConfig.setPreload(preload);
+ return clConfig;
}
- public static CacheLoaderConfig getSingleCacheLoaderConfig(String preload, String
cacheloaderClass, String properties, boolean async, boolean fetchPersistentState, boolean
shared, boolean purgeOnStartup) throws Exception
+ public static CacheLoaderConfig.IndividualCacheLoaderConfig
buildIndividualCacheLoaderConfig(String preload, String cacheloaderClass, String
properties, boolean async, boolean fetchPersistentState, boolean purgeOnStartup, boolean
ignoreModifications) throws Exception
{
- return getSingleCacheLoaderConfig(false, preload, cacheloaderClass, properties,
async, fetchPersistentState, shared, purgeOnStartup);
+ return buildSingleCacheLoaderConfig(false, preload, cacheloaderClass, properties,
async, fetchPersistentState, false, purgeOnStartup,
ignoreModifications).getFirstCacheLoaderConfig();
}
- protected static CacheLoaderConfig getSingleCacheLoaderConfig(boolean passivation,
String preload, String cacheloaderClass, String properties, boolean async, boolean
fetchPersistentState, boolean shared, boolean purgeOnStartup) throws Exception
- {
- String xml = "<config>\n" +
- "<passivation>" + passivation +
"</passivation>\n" +
- "<preload>" + preload + "</preload>\n" +
- "<cacheloader>\n" +
- "<class>" + cacheloaderClass + "</class>\n"
+
- "<properties>" + properties +
"</properties>\n" +
- "<async>" + async + "</async>\n" +
- "<shared>" + shared + "</shared>\n" +
- "<fetchPersistentState>" + fetchPersistentState +
"</fetchPersistentState>\n" +
- "<purgeOnStartup>" + purgeOnStartup +
"</purgeOnStartup>\n" +
- "</cacheloader>\n" +
- "</config>";
- Element element = XmlConfigHelper.stringToElement(xml);
- return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
- }
-
/**
* Helper method that takes a <b>JGroups</b> configuration file and
creates an old-style JGroups config {@link String} that can be used
* in {@link org.jboss.cache.config.Configuration#setClusterConfig(String)}. Note
that expressions
@@ -127,7 +123,6 @@
tmp = tmp.replace("${jgroups.udp.ip_ttl:2}", "2");
System.out.println("config string: " + tmp);
return tmp;
-
}
catch (Exception e)
{
@@ -176,7 +171,7 @@
return erc;
}
- private static class UnitTestXmlConfigurationParser extends XmlConfigurationParserOld
+ private static class UnitTestXmlConfigurationParser extends XmlConfigurationParser2x
{
public Configuration parseFile(String filename, CacheMode mode)
Modified:
core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -13,17 +13,15 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.util.internals.ReplicationListener;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
import org.jboss.cache.optimistic.DefaultDataVersion;
-import org.jboss.cache.config.parsing.XmlConfigHelper;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
-import org.w3c.dom.Element;
import javax.transaction.RollbackException;
import javax.transaction.Transaction;
@@ -907,20 +905,8 @@
protected CacheLoaderConfig getCacheLoaderConfig() throws Exception
{
- String xml = " <config>\n" +
- " <shared>shared</shared>\n" +
- " <passivation>false</passivation>\n" +
- " <preload></preload>\n" +
- " <cacheloader>\n" +
- "
<class>org.jboss.cache.loader.DummySharedInMemoryCacheLoader</class>\n"
+
- " <async>false</async>\n" +
- "
<fetchPersistentState>false</fetchPersistentState>\n" +
- "
<ignoreModifications>false</ignoreModifications>\n" +
- " </cacheloader>\n" +
- " \n" +
- " </config>";
- Element element = XmlConfigHelper.stringToElement(xml);
- return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
+ return UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"",
+ "org.jboss.cache.loader.DummySharedInMemoryCacheLoader",
"", false, false, false, false, false);
}
protected void assertHasBeenInvalidated(Node n, String message)
Modified: core/trunk/src/test/java/org/jboss/cache/jmx/LegacyConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/jmx/LegacyConfigurationTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++ core/trunk/src/test/java/org/jboss/cache/jmx/LegacyConfigurationTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -40,6 +40,7 @@
import org.jgroups.JChannelFactory;
import org.jgroups.jmx.JChannelFactoryMBean;
import static org.testng.AssertJUnit.*;
+import org.testng.annotations.Test;
import org.w3c.dom.Element;
import javax.management.MBeanServerInvocationHandler;
@@ -57,6 +58,7 @@
* @author <a href="brian.stansberry(a)jboss.com">Brian
Stansberry</a>
* @version $Revision$
*/
+@Test(groups = "functional")
public class LegacyConfigurationTest extends CacheJmxWrapperTestBase
{
@SuppressWarnings({"deprecation", "unchecked"})
@@ -253,133 +255,123 @@
protected static Element getBuddyReplicationConfig() throws Exception
{
- String xmlString =
"<config><buddyReplicationEnabled>true</buddyReplicationEnabled>\n"
+
- "
<buddyCommunicationTimeout>600000</buddyCommunicationTimeout>\n" +
- "
<buddyLocatorClass>org.jboss.cache.buddyreplication.TestBuddyLocator</buddyLocatorClass>\n"
+
- " <buddyLocatorProperties>numBuddies =
2</buddyLocatorProperties>\n" +
- "
<buddyPoolName>testpool</buddyPoolName>" +
- "
<autoDataGravitation>false</autoDataGravitation>\n" +
- "
<dataGravitationRemoveOnFind>false</dataGravitationRemoveOnFind>\n" +
- "
<dataGravitationSearchBackupTrees>false</dataGravitationSearchBackupTrees>"
+
- "</config>";
- return XmlConfigHelper.stringToElement(xmlString);
+
+ String xmlStr =
+ " <buddy enabled=\"true\"
buddyPoolName=\"testpool\"
buddyCommunicationTimeout=\"600000\">\n" +
+ " <dataGravitation auto=\"false\"
removeOnFind=\"false\" searchBackupTrees=\"false\"/>\n" +
+ " <buddyLocator
class=\"org.jboss.cache.buddyreplication.TestBuddyLocator\">\n" +
+ " <properties>\n" +
+ " numBuddies = 2\n" +
+ " </properties>\n" +
+ " </buddyLocator>\n" +
+ " </buddy>";
+ return XmlConfigHelper.stringToElement(xmlStr);
}
protected static Element getCacheLoaderConfig() throws Exception
{
- String xml = "<config>\n" +
- "<passivation>false</passivation>\n" +
- "<preload>/foo</preload>\n" +
- "<shared>true</shared>\n" +
- "<cacheloader>\n" +
-
"<class>org.jboss.cache.loader.FileCacheLoader</class>\n" +
- "<properties>" +
- " location=/tmp\n" +
- "</properties>\n" +
- "<async>false</async>\n" +
-
"<fetchPersistentState>true</fetchPersistentState>\n" +
-
"<ignoreModifications>true</ignoreModifications>\n" +
- "<purgeOnStartup>true</purgeOnStartup>\n" +
- "<singletonStore>" +
- "<enabled>true</enabled>" +
- "</singletonStore>" +
- "</cacheloader>\n" +
- "<cacheloader>\n" +
-
"<class>org.jboss.cache.loader.jdbm.JdbmCacheLoader</class>\n" +
- "<properties>" +
- " location=/home/bstansberry\n" +
- "</properties>\n" +
- "<async>true</async>\n" +
-
"<fetchPersistentState>false</fetchPersistentState>\n" +
-
"<ignoreModifications>false</ignoreModifications>\n" +
- "<purgeOnStartup>false</purgeOnStartup>\n" +
- "<singletonStore>" +
- "<enabled>false</enabled>" +
- "</singletonStore>" +
- "</cacheloader>\n" +
- "</config>";
- return XmlConfigHelper.stringToElement(xml);
+ String xmlStr =
+ " <loaders passivation=\"false\"
shared=\"true\">\n" +
+ " <preload>\n" +
+ " <node fqn=\"/foo\"/>\n" +
+ " </preload>\n" +
+ " <loader
class=\"org.jboss.cache.loader.FileCacheLoader\" async=\"false\"
fetchPersistentState=\"true\"\n" +
+ " ignoreModifications=\"true\"
purgeOnStartup=\"true\">\n" +
+ " <properties>\n" +
+ " location=/tmp\n " +
+ " </properties>\n" +
+ " <singletonStore enabled=\"true\" /> \n"
+
+ " </loader>\n" +
+ " <loader
class=\"org.jboss.cache.loader.jdbm.JdbmCacheLoader\" async=\"true\"
fetchPersistentState=\"false\"\n" +
+ " ignoreModifications=\"false\"
purgeOnStartup=\"false\">\n" +
+ " <properties>\n" +
+ " location=/home/bstansberry\n" +
+ " </properties>\n" +
+ " <singletonStore enabled=\"false\" /> \n"
+
+ " </loader>\n" +
+ " </loaders>";
+ return XmlConfigHelper.stringToElement(xmlStr);
}
protected static Element getEvictionPolicyConfig() throws Exception
{
- String xml = "<config>\n" +
- "<attribute
name=\"wakeUpIntervalSeconds\">5</attribute>\n" +
- "<attribute
name=\"eventQueueSize\">20000</attribute>\n" +
- "<attribute
name=\"policyClass\">org.jboss.cache.eviction.LRUPolicy</attribute>\n"
+
- "<region name=\"/_default_\"
eventQueueSize=\"1000\">\n" +
- " <attribute
name=\"maxNodes\">5000</attribute>\n" +
- " <attribute
name=\"timeToLiveSeconds\">1000</attribute>\n" +
- "</region>\n" +
- "<region name=\"/org/jboss/data\"
policyClass=\"org.jboss.cache.eviction.FIFOPolicy\">\n" +
- " <attribute
name=\"maxNodes\">5000</attribute>\n" +
- "</region>\n" +
- "<region name=\"/test/\"
policyClass=\"org.jboss.cache.eviction.MRUPolicy\">\n" +
- " <attribute
name=\"maxNodes\">10000</attribute>\n" +
- "</region>\n" +
- "<region name=\"/maxAgeTest/\">\n" +
- " <attribute
name=\"maxNodes\">10000</attribute>\n" +
- " <attribute
name=\"timeToLiveSeconds\">8</attribute>\n" +
- " <attribute
name=\"maxAgeSeconds\">10</attribute>\n" +
- "</region>\n" +
- " </config>\n";
- return XmlConfigHelper.stringToElement(xml);
+
+ String xmlStr =
+ " <eviction wakeUpInterval=\"5000\">\n" +
+ " <defaults
policyClass=\"org.jboss.cache.eviction.LRUPolicy\"
eventQueueSize=\"20000\"/>\n" +
+ " <root eventQueueSize=\"1000\">\n" +
+ " <attribute
name=\"maxNodes\">5000</attribute>\n" +
+ " <attribute
name=\"timeToLive\">1000000</attribute>\n" +
+ " </root>\n" +
+ "<region name=\"/org/jboss/data\"
policyClass=\"org.jboss.cache.eviction.FIFOPolicy\">\n" +
+ " <attribute
name=\"maxNodes\">5000</attribute>\n" +
+ "</region>\n" +
+ "<region name=\"/test/\"
policyClass=\"org.jboss.cache.eviction.MRUPolicy\">\n" +
+ " <attribute
name=\"maxNodes\">10000</attribute>\n" +
+ "</region>\n" +
+ "<region name=\"/maxAgeTest/\">\n" +
+ " <attribute
name=\"maxNodes\">10000</attribute>\n" +
+ " <attribute
name=\"timeToLiveSeconds\">8</attribute>\n" +
+ " <attribute
name=\"maxAgeSeconds\">10</attribute>\n" +
+ "</region>\n" +
+ " </eviction>";
+ return XmlConfigHelper.stringToElement(xmlStr);
}
protected static Element getClusterConfig() throws Exception
{
String xml =
- "<config>\n" +
- " <UDP mcast_addr=\"228.10.10.10\"\n" +
- " mcast_port=\"45588\"\n" +
- " tos=\"8\"\n" +
- " ucast_recv_buf_size=\"20000000\"\n" +
- " ucast_send_buf_size=\"640000\"\n" +
- " mcast_recv_buf_size=\"25000000\"\n" +
- " mcast_send_buf_size=\"640000\"\n" +
- " loopback=\"false\"\n" +
- " discard_incompatible_packets=\"true\"\n" +
- " max_bundle_size=\"64000\"\n" +
- " max_bundle_timeout=\"30\"\n" +
- " use_incoming_packet_handler=\"true\"\n" +
- " ip_ttl=\"2\"\n" +
- " enable_bundling=\"false\"\n" +
- " enable_diagnostics=\"true\"\n" +
- " use_concurrent_stack=\"true\"\n" +
- " thread_naming_pattern=\"pl\"\n" +
- " thread_pool.enabled=\"true\"\n" +
- " thread_pool.min_threads=\"1\"\n" +
- " thread_pool.max_threads=\"25\"\n" +
- " thread_pool.keep_alive_time=\"30000\"\n" +
- " thread_pool.queue_enabled=\"true\"\n" +
- " thread_pool.queue_max_size=\"10\"\n" +
- " thread_pool.rejection_policy=\"Run\"\n" +
- " oob_thread_pool.enabled=\"true\"\n" +
- " oob_thread_pool.min_threads=\"1\"\n" +
- " oob_thread_pool.max_threads=\"4\"\n" +
- " oob_thread_pool.keep_alive_time=\"10000\"\n"
+
- " oob_thread_pool.queue_enabled=\"true\"\n" +
- " oob_thread_pool.queue_max_size=\"10\"\n" +
- "
oob_thread_pool.rejection_policy=\"Run\"/>\n" +
- " <PING timeout=\"2000\"
num_initial_members=\"3\"/>\n" +
- " <MERGE2 max_interval=\"30000\"
min_interval=\"10000\"/>\n" +
- " <FD_SOCK/>\n" +
- " <FD timeout=\"10000\" max_tries=\"5\"
shun=\"true\"/>\n" +
- " <VERIFY_SUSPECT timeout=\"1500\"/>\n" +
- " <pbcast.NAKACK max_xmit_size=\"60000\"\n" +
- " use_mcast_xmit=\"false\"
gc_lag=\"0\"\n" +
- "
retransmit_timeout=\"300,600,1200,2400,4800\"\n" +
- "
discard_delivered_msgs=\"true\"/>\n" +
- " <UNICAST
timeout=\"300,600,1200,2400,3600\"/>\n" +
- " <pbcast.STABLE stability_delay=\"1000\"
desired_avg_gossip=\"50000\"\n" +
- " max_bytes=\"400000\"/>\n" +
- " <pbcast.GMS print_local_addr=\"true\"
join_timeout=\"5000\"\n" +
- " join_retry_timeout=\"2000\"
shun=\"false\"\n" +
- " view_bundling=\"true\"
view_ack_collection_timeout=\"5000\"/>\n" +
- " <FRAG2 frag_size=\"60000\"/>\n" +
- " <pbcast.STREAMING_STATE_TRANSFER
use_reading_thread=\"true\"/>\n" +
- " <pbcast.FLUSH timeout=\"0\"/>\n" +
- "</config>";
+ "<jgroupsConfig>\n" +
+ "<UDP mcast_addr=\"228.10.10.10\"\n" +
+ " mcast_port=\"45588\"\n" +
+ " tos=\"8\"\n" +
+ " ucast_recv_buf_size=\"20000000\"\n" +
+ " ucast_send_buf_size=\"640000\"\n" +
+ " mcast_recv_buf_size=\"25000000\"\n" +
+ " mcast_send_buf_size=\"640000\"\n" +
+ " loopback=\"false\"\n" +
+ " discard_incompatible_packets=\"true\"\n"
+
+ " max_bundle_size=\"64000\"\n" +
+ " max_bundle_timeout=\"30\"\n" +
+ " use_incoming_packet_handler=\"true\"\n"
+
+ " ip_ttl=\"2\"\n" +
+ " enable_bundling=\"false\"\n" +
+ " enable_diagnostics=\"true\"\n" +
+ " use_concurrent_stack=\"true\"\n" +
+ " thread_naming_pattern=\"pl\"\n" +
+ " thread_pool.enabled=\"true\"\n" +
+ " thread_pool.min_threads=\"1\"\n" +
+ " thread_pool.max_threads=\"25\"\n" +
+ " thread_pool.keep_alive_time=\"30000\"\n"
+
+ " thread_pool.queue_enabled=\"true\"\n" +
+ " thread_pool.queue_max_size=\"10\"\n" +
+ " thread_pool.rejection_policy=\"Run\"\n"
+
+ " oob_thread_pool.enabled=\"true\"\n" +
+ " oob_thread_pool.min_threads=\"1\"\n" +
+ " oob_thread_pool.max_threads=\"4\"\n" +
+ "
oob_thread_pool.keep_alive_time=\"10000\"\n" +
+ " oob_thread_pool.queue_enabled=\"true\"\n"
+
+ " oob_thread_pool.queue_max_size=\"10\"\n"
+
+ "
oob_thread_pool.rejection_policy=\"Run\"/>\n" +
+ " <PING timeout=\"2000\"
num_initial_members=\"3\"/>\n" +
+ " <MERGE2 max_interval=\"30000\"
min_interval=\"10000\"/>\n" +
+ " <FD_SOCK/>\n" +
+ " <FD timeout=\"10000\" max_tries=\"5\"
shun=\"true\"/>\n" +
+ " <VERIFY_SUSPECT timeout=\"1500\"/>\n" +
+ " <pbcast.NAKACK max_xmit_size=\"60000\"\n"
+
+ " use_mcast_xmit=\"false\"
gc_lag=\"0\"\n" +
+ "
retransmit_timeout=\"300,600,1200,2400,4800\"\n" +
+ "
discard_delivered_msgs=\"true\"/>\n" +
+ " <UNICAST
timeout=\"300,600,1200,2400,3600\"/>\n" +
+ " <pbcast.STABLE stability_delay=\"1000\"
desired_avg_gossip=\"50000\"\n" +
+ " max_bytes=\"400000\"/>\n" +
+ " <pbcast.GMS print_local_addr=\"true\"
join_timeout=\"5000\"\n" +
+ " join_retry_timeout=\"2000\"
shun=\"false\"\n" +
+ " view_bundling=\"true\"
view_ack_collection_timeout=\"5000\"/>\n" +
+ " <FRAG2 frag_size=\"60000\"/>\n" +
+ " <pbcast.STREAMING_STATE_TRANSFER
use_reading_thread=\"true\"/>\n" +
+ " <pbcast.FLUSH timeout=\"0\"/>\n" +
+ "</jgroupsConfig>";
return XmlConfigHelper.stringToElement(xml);
}
Modified: core/trunk/src/test/java/org/jboss/cache/jmx/NotificationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/jmx/NotificationTest.java 2008-06-25 15:57:45
UTC (rev 6041)
+++ core/trunk/src/test/java/org/jboss/cache/jmx/NotificationTest.java 2008-06-25 17:04:10
UTC (rev 6042)
@@ -6,8 +6,6 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
-import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.loader.CacheLoader;
@@ -15,7 +13,6 @@
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import org.w3c.dom.Element;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
@@ -321,20 +318,8 @@
protected static CacheLoaderConfig getCacheLoaderConfig(String properties) throws
Exception
{
- String xml = "<config>\n" +
- "<passivation>true</passivation>\n" +
- "<preload></preload>\n" +
- "<shared>true</shared>\n" +
- "<cacheloader>\n" +
-
"<class>org.jboss.cache.loader.FileCacheLoader</class>\n" +
- "<properties>" + properties +
"</properties>\n" +
- "<async>false</async>\n" +
- "<fetchPersistentState>false</fetchPersistentState>\n"
+
- "<ignoreModifications>false</ignoreModifications>\n" +
- "</cacheloader>\n" +
- "</config>";
- Element element = XmlConfigHelper.stringToElement(xml);
- return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
+ return UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(true,
"",
+ "org.jboss.cache.loader.FileCacheLoader", properties, false, false,
true, false, false);
}
private static void validateHealthyListener(MyListener listener)
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/AbstractCacheLoaderTestBase.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/AbstractCacheLoaderTestBase.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/loader/AbstractCacheLoaderTestBase.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -9,10 +9,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
-import org.jboss.cache.config.parsing.XmlConfigHelper;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.testng.annotations.Test;
-import org.w3c.dom.Element;
/**
* Very basic test case that provides methods to create a cache loader config.
@@ -37,19 +35,7 @@
protected CacheLoaderConfig getSingleCacheLoaderConfig(boolean passivation, String
preload, String cacheloaderClass, String properties, boolean async, boolean
fetchPersistentState, boolean shared, boolean purgeOnStartup) throws Exception
{
- String xml = "<config>\n" +
- "<passivation>" + passivation +
"</passivation>\n" +
- "<preload>" + preload + "</preload>\n" +
- "<cacheloader>\n" +
- "<class>" + cacheloaderClass + "</class>\n"
+
- "<properties>" + properties +
"</properties>\n" +
- "<async>" + async + "</async>\n" +
- "<shared>" + shared + "</shared>\n" +
- "<fetchPersistentState>" + fetchPersistentState +
"</fetchPersistentState>\n" +
- "<purgeOnStartup>" + purgeOnStartup +
"</purgeOnStartup>\n" +
- "</cacheloader>\n" +
- "</config>";
- Element element = XmlConfigHelper.stringToElement(xml);
- return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
+ return UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(passivation,
preload, cacheloaderClass,
+ properties, async, fetchPersistentState, shared, purgeOnStartup, false);
}
}
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderCompatibilityTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderCompatibilityTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderCompatibilityTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -3,19 +3,17 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
import org.jboss.cache.marshall.NodeData;
import org.jboss.cache.statetransfer.StateTransferManager;
-import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.jboss.util.stream.MarshalledValueInputStream;
import org.jboss.util.stream.MarshalledValueOutputStream;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import org.w3c.dom.Element;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -204,20 +202,7 @@
protected CacheLoaderConfig getSingleCacheLoaderConfig(String preload, String
cacheloaderClass, String properties) throws Exception
{
- String xml = "<config>\n" +
- "<passivation>false</passivation>\n" +
- "<preload>" + preload + "</preload>\n" +
- "<cacheloader>\n" +
- "<class>" + cacheloaderClass + "</class>\n"
+
- "<properties>" + properties +
"</properties>\n" +
- "<async>false</async>\n" +
- "<shared>false</shared>\n" +
- "<fetchPersistentState>true</fetchPersistentState>\n"
+
- "<purgeOnStartup>false</purgeOnStartup>\n" +
- "</cacheloader>\n" +
- "</config>";
- Element element = XmlConfigHelper.stringToElement(xml);
- return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
+ return UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
preload, cacheloaderClass, properties, false, true, false, false, false);
}
protected Properties getProperties() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/loader/AsyncFileCacheLoaderTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/AsyncFileCacheLoaderTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/loader/AsyncFileCacheLoaderTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -31,7 +31,7 @@
{
cache = (CacheSPI<Object, Object>) new
DefaultCacheFactory().createCache(false);
cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
- // cache.setCacheLoaderConfiguration(getSingleCacheLoaderConfig("",
"org.jboss.cache.loader.jdbm.JdbmCacheLoader",
+ // cache.setCacheLoaderConfiguration(buildSingleCacheLoaderConfig("",
"org.jboss.cache.loader.jdbm.JdbmCacheLoader",
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("",
"org.jboss.cache.loader.FileCacheLoader", props, true, false, true));
cache.create();
cache.start();
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderManagerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderManagerTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderManagerTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -7,9 +7,10 @@
package org.jboss.cache.loader;
import org.jboss.cache.CacheSPI;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
import org.jboss.cache.config.parsing.XmlConfigHelper;
+import org.jboss.cache.config.parsing.element.LoadersElementParser;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
@@ -26,6 +27,8 @@
@Test(groups = "functional")
public class CacheLoaderManagerTest extends AbstractCacheLoaderTestBase
{
+ private LoadersElementParser loadersElementParser = new LoadersElementParser();;
+
private CacheLoaderConfig createCacheLoaderCfg(boolean passivation)
{
CacheLoaderConfig cfg = new CacheLoaderConfig();
@@ -128,73 +131,22 @@
public void testSingleCacheLoaderPassivationFromXml() throws Exception
{
- // without async
- String conf = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>" +
- "<config><passivation>true</passivation>" +
- "<cacheloader>" +
- "
<class>org.jboss.cache.loader.FileCacheLoader</class>" +
- " <async>false</async>" +
- "
<fetchPersistentState>false</fetchPersistentState>" +
- " <ignoreModifications>false</ignoreModifications>"
+
- " <properties>" +
- " location=" + getTempDir() +
- " </properties>" +
- "</cacheloader>" +
- "<cacheloader>" +
- "
<class>org.jboss.cache.loader.bdbje.BdbjeCacheLoader</class>" +
- " <async>false</async>" +
- "
<fetchPersistentState>false</fetchPersistentState>" +
- " <ignoreModifications>false</ignoreModifications>"
+
- " <properties>" +
- " location=" + getTempDir() +
- " </properties>" +
- "</cacheloader>" +
- "<cacheloader>" +
- "
<class>org.jboss.cache.loader.JDBCCacheLoader</class>" +
- " <async>false</async>" +
- "
<fetchPersistentState>false</fetchPersistentState>" +
- " <ignoreModifications>false</ignoreModifications>"
+
- " <properties>" +
- " location=" + getTempDir() +
- " </properties>" +
- "</cacheloader></config>";
- CacheLoaderConfig clc =
XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
+ CacheLoaderConfig clc =
UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(true, "",
"org.jboss.cache.loader.FileCacheLoader", "location=" + getTempDir(),
false, false, false, false, false);
+ CacheLoaderConfig bdbjeCl =
UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(true, "",
"org.jboss.cache.loader.bdbje.BdbjeCacheLoader", "location=" +
getTempDir(), false, false, false, false, false);
+ CacheLoaderConfig jdbCl =
UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(true, "",
"org.jboss.cache.loader.JDBCCacheLoader", "location=" + getTempDir(),
false, false, false, false, false);
+ clc.getIndividualCacheLoaderConfigs().add(bdbjeCl.getFirstCacheLoaderConfig());
+ clc.getIndividualCacheLoaderConfigs().add(jdbCl.getFirstCacheLoaderConfig());
CacheLoaderManager mgr = new CacheLoaderManager();
mgr.setConfig(clc, null, null);
CacheLoader cl = mgr.getCacheLoader();
-
assertEquals(FileCacheLoader.class, cl.getClass());
- // with async
- conf = "<config><passivation>true</passivation>" +
- "<cacheloader>" +
- "
<class>org.jboss.cache.loader.FileCacheLoader</class>" +
- " <async>true</async>" +
- "
<fetchPersistentState>false</fetchPersistentState>" +
- " <ignoreModifications>false</ignoreModifications>"
+
- " <properties>" +
- " location=" + getTempDir() +
- " </properties>" +
- "</cacheloader>" +
- "<cacheloader>" +
- "
<class>org.jboss.cache.loader.bdbje.BdbjeCacheLoader</class>" +
- " <async>true</async>" +
- "
<fetchPersistentState>false</fetchPersistentState>" +
- " <ignoreModifications>false</ignoreModifications>"
+
- " <properties>" +
- " location=" + getTempDir() +
- " </properties>" +
- "</cacheloader>" +
- "<cacheloader>" +
- "
<class>org.jboss.cache.loader.JDBCCacheLoader</class>" +
- " <async>true</async>" +
- "
<fetchPersistentState>false</fetchPersistentState>" +
- " <ignoreModifications>false</ignoreModifications>"
+
- " <properties>" +
- " location=" + getTempDir() +
- " </properties>" +
- "</cacheloader></config>";
- clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
+ clc = UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(true,
"", "org.jboss.cache.loader.FileCacheLoader", "location=" +
getTempDir(), true, false, false, false, false);
+ bdbjeCl = UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(true,
"", "org.jboss.cache.loader.bdbje.BdbjeCacheLoader",
"location=" + getTempDir(), true, false, false, false, false);
+ jdbCl = UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(true,
"", "org.jboss.cache.loader.JDBCCacheLoader", "location=" +
getTempDir(), true, false, false, false, false);
+ clc.getIndividualCacheLoaderConfigs().add(bdbjeCl.getFirstCacheLoaderConfig());
+ clc.getIndividualCacheLoaderConfigs().add(jdbCl.getFirstCacheLoaderConfig());
+
mgr.setConfig(clc, null, null);
cl = mgr.getCacheLoader();
@@ -235,28 +187,10 @@
public void testChainingCacheLoaderFromXml() throws Exception
{
- // async = false
- String conf =
"<config><passivation>false</passivation>" +
- "<cacheloader>" +
- "
<class>org.jboss.cache.loader.FileCacheLoader</class>" +
- " <async>false</async>" +
- "
<fetchPersistentState>false</fetchPersistentState>" +
- " <ignoreModifications>false</ignoreModifications>"
+
- " <properties>" +
- " location=" + getTempDir() +
- " </properties>" +
- "</cacheloader>" +
- "<cacheloader>" +
- "
<class>org.jboss.cache.loader.JDBCCacheLoader</class>" +
- " <async>false</async>" +
- "
<fetchPersistentState>false</fetchPersistentState>" +
- " <ignoreModifications>false</ignoreModifications>"
+
- " <properties>" +
-
"cache.jdbc.driver=com.mysql.jdbc.Driver\ncache.jdbc.url=jdbc:mysql://localhost/test\ncache.jdbc.user=user\ncache.jdbc.password=pwd"
+
- " </properties>" +
- "</cacheloader></config>";
-
- CacheLoaderConfig clc =
XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
+ CacheLoaderConfig clc =
UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false, "",
+ "org.jboss.cache.loader.FileCacheLoader", "a=b", false,
false, false, false, false);
+
clc.addIndividualCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildIndividualCacheLoaderConfig("",
+ "org.jboss.cache.loader.JDBCCacheLoader",
"cache.jdbc.driver=com.mysql.jdbc.Driver\ncache.jdbc.url=jdbc:mysql://localhost/test\ncache.jdbc.user=user\ncache.jdbc.password=pwd",
false, false, false, false));
CacheLoaderManager mgr = new CacheLoaderManager();
mgr.setConfig(clc, null, null);
CacheLoader cl = mgr.getCacheLoader();
@@ -269,29 +203,13 @@
assertEquals(JDBCCacheLoader.class, loaders.get(1).getClass());
// async = true
- conf = "<config>" +
- "<passivation>false</passivation>" +
- "<cacheloader>" +
- "
<class>org.jboss.cache.loader.FileCacheLoader</class>" +
- " <async>false</async>" +
- "
<fetchPersistentState>false</fetchPersistentState>" +
- " <ignoreModifications>false</ignoreModifications>"
+
- " <properties>" +
- " location=" + getTempDir() +
- " </properties>" +
- "</cacheloader>" +
- "<cacheloader>" +
- "
<class>org.jboss.cache.loader.JDBCCacheLoader</class>" +
- " <async>true</async>" +
- "
<fetchPersistentState>false</fetchPersistentState>" +
- " <ignoreModifications>false</ignoreModifications>"
+
- " <properties>" +
-
"cache.jdbc.driver=com.mysql.jdbc.Driver\ncache.jdbc.url=jdbc:mysql://localhost/test\ncache.jdbc.user=user\ncache.jdbc.password=pwd"
+
- " </properties>" +
- "</cacheloader></config>";
- clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
- mgr.setConfig(clc, null, null);
- cl = mgr.getCacheLoader();
+ clc = UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"",
+ "org.jboss.cache.loader.FileCacheLoader", "a=b", false,
false, false, false, false);
+
clc.addIndividualCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildIndividualCacheLoaderConfig("",
+ "org.jboss.cache.loader.JDBCCacheLoader",
"cache.jdbc.driver=com.mysql.jdbc.Driver\ncache.jdbc.url=jdbc:mysql://localhost/test\ncache.jdbc.user=user\ncache.jdbc.password=pwd",
true, false, false, false));
+ mgr = new CacheLoaderManager();
+ mgr.setConfig(clc, null, null);
+ cl = mgr.getCacheLoader();
assertEquals(ChainingCacheLoader.class, cl.getClass());
assertEquals(2, ((ChainingCacheLoader) cl).getSize());
@@ -364,160 +282,27 @@
mgr.setConfig(cfg, null, null);
}
- public void testConfigurationParsing() throws Exception
- {
-
- String conf = "<config>" +
- "<passivation>false</passivation>" +
- "<preload>/, /blah, /blah2</preload>" +
- "<cacheloader>" +
- "
<class>org.jboss.cache.loader.FileCacheLoader</class>" +
- " <async>false</async>" +
- "
<fetchPersistentState>false</fetchPersistentState>" +
- " <ignoreModifications>true</ignoreModifications>"
+
- " <properties>" +
- " location=" + getTempDir() +
- " </properties>" +
- "</cacheloader>" +
- "<cacheloader>" +
- "
<class>org.jboss.cache.loader.JDBCCacheLoader</class>" +
- " <async>true</async>" +
- " <fetchPersistentState>true</fetchPersistentState>"
+
- " <ignoreModifications>false</ignoreModifications>"
+
- " <properties>" +
-
"cache.jdbc.driver=com.mysql.jdbc.Driver\ncache.jdbc.url=jdbc:mysql://localhost/test\ncache.jdbc.user=user\ncache.jdbc.password=pwd"
+
- " </properties>" +
- "</cacheloader></config>";
- CacheLoaderConfig clc =
XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
- CacheLoaderManager mgr = new CacheLoaderManager();
- mgr.setConfig(clc, null, null);
-
- assertEquals(ChainingCacheLoader.class, mgr.getCacheLoader().getClass());
- assertTrue("Should be true", mgr.isFetchPersistentState());
- assertTrue("Passivation shuld be false", !mgr.isPassivation());
- CacheLoaderConfig c = mgr.getCacheLoaderConfig();
- assertTrue("Should be using a chaining cache loader",
c.useChainingCacheLoader());
- assertEquals("/, /blah, /blah2", c.getPreload());
- assertEquals(2, c.getIndividualCacheLoaderConfigs().size());
-
- CacheLoaderConfig.IndividualCacheLoaderConfig icfg =
c.getIndividualCacheLoaderConfigs().get(0);
- assertEquals("org.jboss.cache.loader.FileCacheLoader",
icfg.getClassName());
- assertTrue("Async shld be false", !icfg.isAsync());
- assertTrue("fetchPersistentState shld be false",
!icfg.isFetchPersistentState());
- assertTrue("IgnoreMods should be true", icfg.isIgnoreModifications());
- assertEquals(1, icfg.getProperties().size());
-
- icfg = c.getIndividualCacheLoaderConfigs().get(1);
- assertEquals("org.jboss.cache.loader.JDBCCacheLoader",
icfg.getClassName());
- assertTrue("Async shld be true", icfg.isAsync());
- assertTrue("fetchPersistentState shld be true",
icfg.isFetchPersistentState());
- assertTrue("IgnoreMods should be false", !icfg.isIgnoreModifications());
- assertEquals(4, icfg.getProperties().size());
-
- // fetch PersistentState shld be false now
- conf = "<config>" +
- "<passivation>false</passivation>" +
- "<preload>/, /blah, /blah2</preload>" +
- "<cacheloader>" +
- "
<class>org.jboss.cache.loader.FileCacheLoader</class>" +
- " <async>false</async>" +
- "
<fetchPersistentState>false</fetchPersistentState>" +
- " <ignoreModifications>true</ignoreModifications>"
+
- " <properties>" +
- " location=" + getTempDir() +
- " </properties>" +
- "</cacheloader>" +
- "<cacheloader>" +
- "
<class>org.jboss.cache.loader.JDBCCacheLoader</class>" +
- " <async>true</async>" +
- "
<fetchPersistentState>false</fetchPersistentState>" +
- " <ignoreModifications>false</ignoreModifications>"
+
- " <properties>" +
-
"cache.jdbc.driver=com.mysql.jdbc.Driver\ncache.jdbc.url=jdbc:mysql://localhost/test\ncache.jdbc.user=user\ncache.jdbc.password=pwd"
+
- " </properties>" +
- "</cacheloader></config>";
- clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
-
- mgr = new CacheLoaderManager();
- mgr.setConfig(clc, null, null);
-
- assertTrue("Should be false", !mgr.isFetchPersistentState());
-
-
- }
-
public void testSingletonConfiguration() throws Exception
{
- String conf = "<config>" +
- "<passivation>false</passivation>" +
- "<preload>/, /blah, /blah2</preload>" +
- "<cacheloader>" +
- "
<class>org.jboss.cache.loader.FileCacheLoader</class>" +
- " <async>false</async>" +
- "
<fetchPersistentState>false</fetchPersistentState>" +
- " <ignoreModifications>true</ignoreModifications>"
+
- " <properties>" +
- " location=" + getTempDir() +
- " </properties>" +
- "</cacheloader>" +
- "</config>";
- CacheLoaderConfig clc =
XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
- CacheLoaderManager mgr = new CacheLoaderManager();
- mgr.setConfig(clc, null, null);
-
- CacheLoaderConfig.IndividualCacheLoaderConfig iclc =
mgr.getCacheLoaderConfig().getFirstCacheLoaderConfig();
- assertNull("Singleton has not been configured",
iclc.getSingletonStoreConfig());
-
/************************************************************************************************************/
+ String conf ;
+ CacheLoaderConfig clc;
+ CacheLoaderManager mgr;
+ CacheLoaderConfig.IndividualCacheLoaderConfig iclc;
+ conf =
+ "<loaders passivation=\"false\">\n" +
+ " <preload/>\n" +
+ " <loader
class=\"org.jboss.cache.loader.DummyInMemoryCacheLoader\">" +
+ " <singletonStore enabled=\"true\"/>\n" +
+ " </loader>"+
+ "</loaders>";
- conf = "<config>" +
- "<passivation>false</passivation>" +
- "<preload>/, /blah, /blah2</preload>" +
- "<cacheloader>" +
- "
<class>org.jboss.cache.loader.FileCacheLoader</class>" +
- " <async>false</async>" +
- "
<fetchPersistentState>false</fetchPersistentState>" +
- " <ignoreModifications>true</ignoreModifications>"
+
- " <properties>" +
- " location=" + getTempDir() +
- " </properties>" +
- " <singletonStore>" +
- " <enabled>false</enabled>" +
- " </singletonStore>" +
- "</cacheloader>" +
- "</config>";
- clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
+ clc = loadersElementParser.parseLoadersElement(strToElement(conf));
mgr = new MockCacheLoaderManager();
mgr.setConfig(clc, null, null);
iclc = mgr.getCacheLoaderConfig().getFirstCacheLoaderConfig();
assertNotNull("Singleton has been configured",
iclc.getSingletonStoreConfig());
- assertFalse("Singleton is not enabled",
iclc.getSingletonStoreConfig().isSingletonStoreEnabled());
-
-
/************************************************************************************************************/
-
- conf = "<config>" +
- "<passivation>false</passivation>" +
- "<preload>/, /blah, /blah2</preload>" +
- "<cacheloader>" +
- "
<class>org.jboss.cache.loader.FileCacheLoader</class>" +
- " <async>false</async>" +
- "
<fetchPersistentState>false</fetchPersistentState>" +
- " <ignoreModifications>true</ignoreModifications>"
+
- " <properties>" +
- " location=" + getTempDir() +
- " </properties>" +
- " <singletonStore>" +
- " <enabled>true</enabled>" +
- " </singletonStore>" +
- "</cacheloader>" +
- "</config>";
- clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
- mgr = new MockCacheLoaderManager();
- mgr.setConfig(clc, null, null);
-
- iclc = mgr.getCacheLoaderConfig().getFirstCacheLoaderConfig();
- assertNotNull("Singleton has been configured",
iclc.getSingletonStoreConfig());
assertTrue("Singleton should enabled",
iclc.getSingletonStoreConfig().isSingletonStoreEnabled());
assertEquals("Singleton class should be default",
SingletonStoreCacheLoader.class.getName(),
iclc.getSingletonStoreConfig().getSingletonStoreClass());
assertNotNull("Singleton properties should be not null",
iclc.getSingletonStoreConfig().getSingletonStoreproperties());
@@ -527,25 +312,14 @@
assertEquals("Singleton pushStateWhenCoordinatorTimeout should be default
value", 20000, ssdc.getPushStateWhenCoordinatorTimeout());
/************************************************************************************************************/
-
- conf = "<config>" +
- "<passivation>false</passivation>" +
- "<preload>/, /blah, /blah2</preload>" +
- "<cacheloader>" +
- "
<class>org.jboss.cache.loader.FileCacheLoader</class>" +
- " <async>false</async>" +
- "
<fetchPersistentState>false</fetchPersistentState>" +
- " <ignoreModifications>true</ignoreModifications>"
+
- " <properties>" +
- " location=" + getTempDir() +
- " </properties>" +
- " <singletonStore>" +
- " <enabled>true</enabled>" +
- "
<class>org.jboss.cache.loader.CacheLoaderManagerTest$MockSingletonStoreCacheLoader</class>"
+
- " </singletonStore>" +
- "</cacheloader>" +
- "</config>";
- clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
+ conf =
+ "<loaders passivation=\"false\">\n" +
+ " <preload/>\n" +
+ " <loader
class=\"org.jboss.cache.loader.DummyInMemoryCacheLoader\">" +
+ " <singletonStore enabled=\"true\"
class=\"org.jboss.cache.loader.CacheLoaderManagerTest$MockSingletonStoreCacheLoader\"
/>\n" +
+ " </loader>"+
+ "</loaders>";
+ clc = loadersElementParser.parseLoadersElement(strToElement(conf));
mgr = new CacheLoaderManager();
mgr.setConfig(clc, null, null);
@@ -559,119 +333,45 @@
/************************************************************************************************************/
- conf = "<config>" +
- "<passivation>false</passivation>" +
- "<preload>/, /blah, /blah2</preload>" +
- "<cacheloader>" +
- "
<class>org.jboss.cache.loader.FileCacheLoader</class>" +
- " <async>false</async>" +
- "
<fetchPersistentState>false</fetchPersistentState>" +
- " <ignoreModifications>true</ignoreModifications>"
+
- " <properties>" +
- " location=" + getTempDir() +
- " </properties>" +
- " <singletonStore>" +
- " <enabled>false</enabled>" +
- "
<class>org.jboss.cache.loader.FileCacheLoader</class>" +
- " </singletonStore>" +
- "</cacheloader>" +
- "</config>";
- clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
+ conf =
+ " <loaders passivation=\"true\">\n" +
+ " <preload/>\n" +
+ " <loader
class=\"org.jboss.cache.loader.DummyInMemoryCacheLoader\">\n" +
+ " <singletonStore enabled=\"true\">\n" +
+ " <properties>\n" +
+ " pushStateWhenCoordinator=false\n" +
+ " </properties>\n" +
+ " </singletonStore>\n" +
+ " </loader>\n" +
+ " </loaders>";
+ clc = loadersElementParser.parseLoadersElement(strToElement(conf));
mgr = new CacheLoaderManager();
mgr.setConfig(clc, null, null);
-
+
iclc = mgr.getCacheLoaderConfig().getFirstCacheLoaderConfig();
assertNotNull("Singleton has been configured",
iclc.getSingletonStoreConfig());
- assertFalse("Singleton is not enabled",
iclc.getSingletonStoreConfig().isSingletonStoreEnabled());
-
-
/************************************************************************************************************/
-
- conf = "<config>" +
- "<passivation>false</passivation>" +
- "<preload>/, /blah, /blah2</preload>" +
- "<cacheloader>" +
- "
<class>org.jboss.cache.loader.FileCacheLoader</class>" +
- " <async>false</async>" +
- "
<fetchPersistentState>false</fetchPersistentState>" +
- " <ignoreModifications>true</ignoreModifications>"
+
- " <properties>" +
- " location=" + getTempDir() +
- " </properties>" +
- " <singletonStore>" +
- " <enabled>true</enabled>" +
- " <properties></properties>" +
- " </singletonStore>" +
- "</cacheloader>" +
- "</config>";
- clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
- mgr = new MockCacheLoaderManager();
- mgr.setConfig(clc, null, null);
-
- iclc = mgr.getCacheLoaderConfig().getFirstCacheLoaderConfig();
- assertNotNull("Singleton has been configured",
iclc.getSingletonStoreConfig());
assertTrue("Singleton should enabled",
iclc.getSingletonStoreConfig().isSingletonStoreEnabled());
assertEquals("Singleton class should be default",
SingletonStoreCacheLoader.class.getName(),
iclc.getSingletonStoreConfig().getSingletonStoreClass());
- assertNotNull("Singleton properties should be defined, but empty",
iclc.getSingletonStoreConfig().getSingletonStoreproperties());
- ssdc = ((SingletonStoreCacheLoader)
mgr.getCacheLoader()).getSingletonStoreDefaultConfig();
- assertTrue("Singleton pushStateWhenCoordinator should be true",
ssdc.isPushStateWhenCoordinator());
-
-
/************************************************************************************************************/
-
- conf = "<config>" +
- "<passivation>false</passivation>" +
- "<preload>/, /blah, /blah2</preload>" +
- "<cacheloader>" +
- "
<class>org.jboss.cache.loader.FileCacheLoader</class>" +
- " <async>false</async>" +
- "
<fetchPersistentState>false</fetchPersistentState>" +
- " <ignoreModifications>true</ignoreModifications>"
+
- " <properties>" +
- " location=" + getTempDir() +
- " </properties>" +
- " <singletonStore>" +
- " <enabled>true</enabled>" +
- " <properties>" +
- " pushStateWhenCoordinator = false" +
- " </properties>" +
- " </singletonStore>" +
- "</cacheloader>" +
- "</config>";
- clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
- mgr = new MockCacheLoaderManager();
- mgr.setConfig(clc, null, null);
-
- iclc = mgr.getCacheLoaderConfig().getFirstCacheLoaderConfig();
- assertNotNull("Singleton has been configured",
iclc.getSingletonStoreConfig());
- assertTrue("Singleton should enabled",
iclc.getSingletonStoreConfig().isSingletonStoreEnabled());
- assertEquals("Singleton class should be default",
SingletonStoreCacheLoader.class.getName(),
iclc.getSingletonStoreConfig().getSingletonStoreClass());
assertNotNull("Singleton properties should be defined",
iclc.getSingletonStoreConfig().getSingletonStoreproperties());
ssdc = ((SingletonStoreCacheLoader)
mgr.getCacheLoader()).getSingletonStoreDefaultConfig();
assertFalse("Singleton pushStateWhenCoordinator should be false",
ssdc.isPushStateWhenCoordinator());
/************************************************************************************************************/
- conf = "<config>" +
- "<passivation>false</passivation>" +
- "<preload>/, /blah, /blah2</preload>" +
- "<cacheloader>" +
- "
<class>org.jboss.cache.loader.FileCacheLoader</class>" +
- " <async>false</async>" +
- "
<fetchPersistentState>false</fetchPersistentState>" +
- " <ignoreModifications>true</ignoreModifications>"
+
- " <properties>" +
- " location=" + getTempDir() +
- " </properties>" +
- " <singletonStore>" +
- " <enabled>true</enabled>" +
- " <properties>" +
- " pushStateWhenCoordinator = true\n" +
- " pushStateWhenCoordinatorTimeout = 5000\n" +
- " </properties>" +
- " </singletonStore>" +
- "</cacheloader>" +
- "</config>";
- clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
- mgr = new MockCacheLoaderManager();
+ conf =
+ " <loaders passivation=\"true\">\n" +
+ " <preload/>\n" +
+ " <loader
class=\"org.jboss.cache.loader.DummyInMemoryCacheLoader\">\n" +
+ " <singletonStore enabled=\"true\">\n" +
+ " <properties>\n" +
+ " pushStateWhenCoordinator = true\n" +
+ " pushStateWhenCoordinatorTimeout = 5000\n" +
+ " </properties>\n" +
+ " </singletonStore>\n" +
+ " </loader>\n" +
+ " </loaders>";
+ clc = loadersElementParser.parseLoadersElement(strToElement(conf));
+ mgr = new CacheLoaderManager();
mgr.setConfig(clc, null, null);
iclc = mgr.getCacheLoaderConfig().getFirstCacheLoaderConfig();
@@ -684,25 +384,19 @@
assertEquals("Singleton pushStateWhenCoordinatorTimeout should be default
value", 5000, ssdc.getPushStateWhenCoordinatorTimeout());
/************************************************************************************************************/
-
- conf = "<config>" +
- "<passivation>false</passivation>" +
- "<shared>true</shared>" +
- "<preload>/, /blah, /blah2</preload>" +
- "<cacheloader>" +
- "
<class>org.jboss.cache.loader.FileCacheLoader</class>" +
- " <async>false</async>" +
- "
<fetchPersistentState>false</fetchPersistentState>" +
- " <ignoreModifications>true</ignoreModifications>"
+
- " <properties>" +
- " location=" + getTempDir() +
- " </properties>" +
- " <singletonStore>" +
- " <enabled>true</enabled>" +
- " </singletonStore>" +
- "</cacheloader>" +
- "</config>";
- clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
+ conf =
+ " <loaders passivation=\"false\"
shared=\"true\">\n" +
+ " <preload/>\n" +
+ " <loader
class=\"org.jboss.cache.loader.DummyInMemoryCacheLoader\">\n" +
+ " <singletonStore enabled=\"true\">\n" +
+ " <properties>\n" +
+ " pushStateWhenCoordinator = true\n" +
+ " pushStateWhenCoordinatorTimeout = 5000\n" +
+ " </properties>\n" +
+ " </singletonStore>\n" +
+ " </loader>\n" +
+ " </loaders>";
+ clc = loadersElementParser.parseLoadersElement(strToElement(conf));
mgr = new CacheLoaderManager();
try
{
@@ -715,26 +409,16 @@
/************************************************************************************************************/
- conf = "<config>" +
- "<passivation>false</passivation>" +
- "<preload>/, /blah, /blah2</preload>" +
- "<cacheloader>" +
- "
<class>org.jboss.cache.loader.FileCacheLoader</class>" +
- " <async>false</async>" +
- "
<fetchPersistentState>false</fetchPersistentState>" +
- " <ignoreModifications>true</ignoreModifications>"
+
- " <properties>" +
- " location=" + getTempDir() +
- " </properties>" +
- " <singletonStore>" +
- " <enabled>true</enabled>" +
- "
<class>org.jboss.cache.loader.DummyInMemoryCacheLoader</class>" +
- " </singletonStore>" +
- "</cacheloader>" +
- "</config>";
- clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
+ conf =
+ " <loaders passivation=\"true\">\n" +
+ " <preload/>\n" +
+ " <loader
class=\"org.jboss.cache.loader.DummyInMemoryCacheLoader\">\n" +
+ " <singletonStore enabled=\"true\"
class=\"org.jboss.cache.loader.DummyInMemoryCacheLoader\">\n" +
+ " </singletonStore>\n" +
+ " </loader>\n" +
+ " </loaders>";
+ clc = loadersElementParser.parseLoadersElement(strToElement(conf));
mgr = new CacheLoaderManager();
-
try
{
mgr.setConfig(clc, null, null);
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderPurgingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderPurgingTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderPurgingTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -11,12 +11,12 @@
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.parsing.XmlConfigHelper;
+import org.jboss.cache.config.parsing.element.LoadersElementParser;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
-import org.w3c.dom.Element;
/**
* @author <a href="mailto:manik@jboss.org">Manik Surtani
(manik(a)jboss.org)</a>
@@ -92,33 +92,21 @@
public void testTwoLoadersPurge() throws Exception
{
cache = (CacheSPI<Object, Object>) new
DefaultCacheFactory().createCache(false);
-
- String xml = "<config>\n" +
- "<passivation>false</passivation>\n" +
- "<preload></preload>\n" +
- "<cacheloader>\n" +
- "<class>" + DummySharedInMemoryCacheLoader.class.getName() +
"</class>\n" +
- "<properties>" +
- " bin=bin1\n" +
- "</properties>\n" +
- "<async>false</async>\n" +
- "<fetchPersistentState>true</fetchPersistentState>\n"
+
- "<purgeOnStartup>" + true +
"</purgeOnStartup>\n" +
- "</cacheloader>\n" +
- "<cacheloader>\n" +
- "<class>" + DummySharedInMemoryCacheLoader.class.getName() +
"</class>\n" +
- "<properties>" +
- " bin=bin2\n" +
- "</properties>\n" +
- "<async>false</async>\n" +
- "<fetchPersistentState>false</fetchPersistentState>\n"
+
- "<purgeOnStartup>" + false +
"</purgeOnStartup>\n" +
- "</cacheloader>\n" +
- "</config>";
-
+ String xml =
+ " <loaders passivation=\"false\">\n" +
+ " <loader
class=\"org.jboss.cache.loader.DummySharedInMemoryCacheLoader\"
fetchPersistentState=\"true\"\n" +
+ " purgeOnStartup=\"true\">\n" +
+ " <properties>bin=bin1</properties>\n" +
+ " </loader>" +
+ " <loader
class=\"org.jboss.cache.loader.DummySharedInMemoryCacheLoader\"
fetchPersistentState=\"false\"\n" +
+ " purgeOnStartup=\"false\">\n" +
+ " <properties>bin=bin2</properties>\n" +
+ " </loader>" +
+ " </loaders>";
+ LoadersElementParser parser = new LoadersElementParser();
+ CacheLoaderConfig cacheLoaderConfig =
parser.parseLoadersElement(XmlConfigHelper.stringToElement(xml));
Configuration c = cache.getConfiguration();
- Element element = XmlConfigHelper.stringToElement(xml);
- c.setCacheLoaderConfig(XmlConfigurationParserOld.parseCacheLoaderConfig(element));
+ c.setCacheLoaderConfig(cacheLoaderConfig);
cache.start();
cache.put(fqn, key, value);
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderBasicTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderBasicTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderBasicTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -7,8 +7,8 @@
package org.jboss.cache.loader;
import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
import org.jboss.cache.config.parsing.XmlConfigHelper;
+import org.jboss.cache.config.parsing.element.LoadersElementParser;
import org.jboss.cache.util.TestingUtil;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
@@ -45,27 +45,23 @@
protected CacheLoaderConfig getCacheLoaderConfig(String loc1, String loc2) throws
Exception
{
- String xml = "<config>\n" +
- "<passivation>false</passivation>\n" +
- "<preload></preload>\n" +
- "<cacheloader>\n" +
-
"<class>org.jboss.cache.loader.FileCacheLoader</class>\n" +
- "<properties>" +
- " location=" + loc1 + "\n" +
- "</properties>\n" +
- "<async>false</async>\n" +
-
"<fetchPersistentState>true</fetchPersistentState>\n" +
- "</cacheloader>\n" +
- "<cacheloader>\n" +
-
"<class>org.jboss.cache.loader.FileCacheLoader</class>\n" +
- "<properties>" +
- " location=" + loc2 + "\n" +
- "</properties>\n" +
- "<async>false</async>\n" +
-
"<fetchPersistentState>false</fetchPersistentState>\n" +
- "</cacheloader>\n" +
- "</config>";
- Element element = XmlConfigHelper.stringToElement(xml);
- return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
+ String xmlStr =
+ " <loaders passivation=\"false\">\n" +
+ " <loader
class=\"org.jboss.cache.loader.FileCacheLoader\" async=\"false\"
fetchPersistentState=\"true\"\n" +
+ " ignoreModifications=\"false\"
purgeOnStartup=\"false\">\n" +
+ " <properties>\n" +
+ " location=" + loc1+ "\n" +
+ " </properties>\n" +
+ " </loader>\n" +
+ " <loader
class=\"org.jboss.cache.loader.FileCacheLoader\" async=\"false\"
fetchPersistentState=\"false\"\n" +
+ " ignoreModifications=\"false\"
purgeOnStartup=\"false\">\n" +
+ " <properties>\n" +
+ " location=" + loc2+ "\n" +
+ " </properties>\n" +
+ " </loader>\n" +
+ " </loaders>";
+ Element element = XmlConfigHelper.stringToElement(xmlStr);
+ LoadersElementParser parser = new LoadersElementParser();
+ return parser.parseLoadersElement(element);
}
}
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderFullTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderFullTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderFullTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -9,9 +9,10 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
import org.jboss.cache.transaction.DummyTransactionManagerLookup;
import org.jboss.cache.config.parsing.XmlConfigHelper;
import static org.testng.AssertJUnit.assertEquals;
@@ -66,28 +67,10 @@
protected CacheLoaderConfig getCacheLoaderConfig(boolean ignoreMods1, boolean
ignoreMods2) throws Exception
{
- String xml = "<config>\n" +
- "<passivation>false</passivation>\n" +
- "<preload></preload>\n" +
- "<cacheloader>\n" +
- "<class>" + DummyInMemoryCacheLoader.class.getName() +
"</class>\n" +
- "<properties>" +
- "</properties>\n" +
- "<async>false</async>\n" +
- "<fetchPersistentState>true</fetchPersistentState>\n"
+
- "<ignoreModifications>" + ignoreMods1 +
"</ignoreModifications>\n" +
- "</cacheloader>\n" +
- "<cacheloader>\n" +
- "<class>" + DummyInMemoryCacheLoader.class.getName() +
"</class>\n" +
- "<properties>" +
- "</properties>\n" +
- "<async>false</async>\n" +
- "<fetchPersistentState>false</fetchPersistentState>\n"
+
- "<ignoreModifications>" + ignoreMods2 +
"</ignoreModifications>\n" +
- "</cacheloader>\n" +
- "</config>";
- Element element = XmlConfigHelper.stringToElement(xml);
- return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
+ CacheLoaderConfig clc =
UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false, null,
DummyInMemoryCacheLoader.class.getName(), "", false, true, false, false,
ignoreMods1);
+ CacheLoaderConfig.IndividualCacheLoaderConfig ic =
UnitTestCacheConfigurationFactory.buildIndividualCacheLoaderConfig(null,DummyInMemoryCacheLoader.class.getName(),
"", false, false, false , ignoreMods2);
+ clc.addIndividualCacheLoaderConfig(ic);
+ return clc;
}
public void testCruds() throws Exception
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCacheLoaderTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCacheLoaderTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCacheLoaderTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -13,7 +13,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.util.internals.ViewChangeListener;
import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
@@ -277,23 +277,12 @@
protected CacheLoaderConfig getSingletonStoreCacheLoaderConfig(String
cacheloaderClass) throws Exception
{
- String xml = "<config>\n" +
- "<passivation>false</passivation>\n" +
- "<preload></preload>\n" +
- "<cacheloader>\n" +
- " <class>" + cacheloaderClass + "</class>\n"
+
- " <properties></properties>\n" +
- " <singletonStore>" +
- " <enabled>true</enabled>" +
- " <properties>" +
- " pushStateWhenCoordinator = true\n" +
- " pushStateWhenCoordinatorTimeout = 5000\n" +
- " </properties>" +
- " </singletonStore>" +
- "</cacheloader>\n" +
- "</config>";
- Element element = XmlConfigHelper.stringToElement(xml);
- return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
+ CacheLoaderConfig clc =
UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false, null,
cacheloaderClass, "", false, false, false, false, false);
+ CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig sc = new
CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig();
+ sc.setSingletonStoreEnabled(true);
+ sc.setProperties("pushStateWhenCoordinator = true\n
pushStateWhenCoordinatorTimeout = 5000\n");
+ clc.getFirstCacheLoaderConfig().setSingletonStoreConfig(sc);
+ return clc;
}
private void initSingletonNonPushCache(CacheSPI cache) throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheServerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheServerTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++ core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheServerTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -1,5 +1,6 @@
package org.jboss.cache.loader;
+import static org.jboss.cache.factories.UnitTestCacheConfigurationFactory.*;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
@@ -7,7 +8,7 @@
import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.jmx.CacheJmxWrapper;
@@ -62,20 +63,8 @@
protected CacheLoaderConfig getCacheLoaderConfig() throws Exception
{
- String xml = "<config>\n" +
- "<passivation>false</passivation>\n" +
- "<preload></preload>\n" +
- "<cacheloader>\n" +
-
"<class>org.jboss.cache.loader.TcpDelegatingCacheLoader</class>\n"
+
- "<properties>host=127.0.0.1\nport=12121</properties>\n"
+
- "<async>false</async>\n" +
- "<shared>true</shared>\n" +
- "<fetchPersistentState>true</fetchPersistentState>\n"
+
- "<purgeOnStartup>false</purgeOnStartup>\n" +
- "</cacheloader>\n" +
- "</config>";
- Element element = XmlConfigHelper.stringToElement(xml);
- return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
+ return buildSingleCacheLoaderConfig(false, null,
"org.jboss.cache.loader.TcpDelegatingCacheLoader",
+ "host=127.0.0.1\nport=12121", false, true, true, false, false);
}
@AfterMethod(alwaysRun = true)
Modified: core/trunk/src/test/java/org/jboss/cache/mgmt/MgmtTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/mgmt/MgmtTestBase.java 2008-06-25 15:57:45
UTC (rev 6041)
+++ core/trunk/src/test/java/org/jboss/cache/mgmt/MgmtTestBase.java 2008-06-25 17:04:10
UTC (rev 6042)
@@ -6,7 +6,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.DummyInMemoryCacheLoader;
import org.jboss.cache.config.parsing.XmlConfigHelper;
@@ -14,6 +14,7 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
+import static org.jboss.cache.factories.UnitTestCacheConfigurationFactory.*;
import java.util.HashMap;
import java.util.Map;
@@ -107,19 +108,7 @@
private CacheLoaderConfig getCacheLoaderConfig() throws Exception
{
- String xml = "<config>\n" +
- "<passivation>" + passivation +
"</passivation>\n" +
- "<preload></preload>\n" +
- "<shared>false</shared>\n" +
- "<cacheloader>\n" +
- "<class>" + DummyInMemoryCacheLoader.class.getName() +
"</class>\n" +
- "<properties>debug=true</properties>\n" +
- "<async>false</async>\n" +
- "<fetchPersistentState>false</fetchPersistentState>\n"
+
- "<ignoreModifications>false</ignoreModifications>\n" +
- "</cacheloader>\n" +
- "</config>";
- Element element = XmlConfigHelper.stringToElement(xml);
- return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
+ return buildSingleCacheLoaderConfig(passivation, null,
DummyInMemoryCacheLoader.class.getName(),
+ "debug=true", false, false, false, false, false);
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/mgmt/PassivationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/mgmt/PassivationTest.java 2008-06-25 15:57:45
UTC (rev 6041)
+++ core/trunk/src/test/java/org/jboss/cache/mgmt/PassivationTest.java 2008-06-25 17:04:10
UTC (rev 6042)
@@ -4,6 +4,7 @@
import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertNull;
+import org.testng.annotations.Test;
import java.util.HashMap;
@@ -17,6 +18,7 @@
* @author Jerry Gauthier
* @version $Id$
*/
+@Test(groups = "functional")
public class PassivationTest extends MgmtTestBase
{
public PassivationTest()
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -11,15 +11,8 @@
import org.jboss.cache.commands.VersionedDataCommand;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.parsing.XmlConfigHelper;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
-import org.jboss.cache.interceptors.CacheMgmtInterceptor;
-import org.jboss.cache.interceptors.CallInterceptor;
-import org.jboss.cache.interceptors.NotificationInterceptor;
-import org.jboss.cache.interceptors.OptimisticLockingInterceptor;
-import org.jboss.cache.interceptors.OptimisticNodeInterceptor;
-import org.jboss.cache.interceptors.OptimisticValidatorInterceptor;
+import org.jboss.cache.interceptors.*;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.loader.DummyInMemoryCacheLoader;
import org.jboss.cache.loader.DummySharedInMemoryCacheLoader;
@@ -28,11 +21,10 @@
import org.jboss.cache.transaction.DummyTransactionManagerLookup;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionSetup;
-import org.jboss.cache.util.TestingUtil;
import org.jgroups.Address;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
-import org.w3c.dom.Element;
+import org.jboss.cache.util.TestingUtil;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
@@ -100,21 +92,8 @@
protected CacheLoaderConfig getCacheLoaderConfig(boolean shared, boolean passivation)
throws Exception
{
- String xml = " <config>\n" +
- " <passivation>" + passivation +
"</passivation>\n" +
- " <preload></preload>\n" +
- " <shared>" + shared +
"</shared>\n" +
- " <cacheloader>\n" +
- " <class>" + (shared ?
DummySharedInMemoryCacheLoader.class.getName() : DummyInMemoryCacheLoader.class.getName())
+ "</class>\n" +
- " <properties>\n" +
- " </properties>\n" +
- " <async>false</async>\n" +
- " <fetchPersistentState>" + (!shared) +
"</fetchPersistentState>\n" +
- "
<ignoreModifications>false</ignoreModifications>\n" +
- " </cacheloader>\n" +
- " </config>";
- Element element = XmlConfigHelper.stringToElement(xml);
- return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
+ String cacheLoaderClass = shared ? DummySharedInMemoryCacheLoader.class.getName() :
DummyInMemoryCacheLoader.class.getName();
+ return UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(passivation,
null, cacheLoaderClass, "", false, (!shared), shared, false, false);
}
protected CacheSPI<Object, Object> createCacheWithLoader(boolean
passivationEnabled) throws Exception
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithPassivationTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithPassivationTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithPassivationTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -8,12 +8,13 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.transaction.DummyTransactionManager;
import org.jboss.cache.config.parsing.XmlConfigHelper;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNull;
+import static org.jboss.cache.factories.UnitTestCacheConfigurationFactory.*;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
@@ -27,21 +28,8 @@
{
protected CacheLoaderConfig getCacheLoaderConfig() throws Exception
{
- String xml = " <config>\n" +
- " \n" +
- " <passivation>true</passivation>\n" +
- " <preload></preload>\n" +
- "\n" +
- " <cacheloader>\n" +
- "
<class>org.jboss.cache.loader.DummyInMemoryCacheLoader</class>\n" +
- " <async>false</async>\n" +
- "
<fetchPersistentState>false</fetchPersistentState>\n" +
- "
<ignoreModifications>false</ignoreModifications>\n" +
- " </cacheloader>\n" +
- " \n" +
- " </config>";
- Element element = XmlConfigHelper.stringToElement(xml);
- return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
+ return buildSingleCacheLoaderConfig(true, null,
"org.jboss.cache.loader.DummyInMemoryCacheLoader",
+ "", false, false, false, false, false);
}
private CacheSPI createLocalCache() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/BasicPassivationTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/passivation/BasicPassivationTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/passivation/BasicPassivationTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -11,7 +11,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
import org.jboss.cache.loader.DummyInMemoryCacheLoader;
import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.notifications.annotation.CacheListener;
@@ -59,7 +59,7 @@
private void initCaches()
{
CacheFactory<String, String> instance = new DefaultCacheFactory<String,
String>();
- cache = (CacheSPI) instance.createCache(new
XmlConfigurationParserOld().parseFile("META-INF/conf-test/local-passivation-service.xml"),
false);
+ cache = (CacheSPI) instance.createCache(new
XmlConfigurationParser2x().parseFile("META-INF/conf-test/local-passivation-service.xml"),
false);
cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
Object listener = new TestCacheListener();
cache.getConfiguration().getCacheLoaderConfig().getFirstCacheLoaderConfig().setClassName(DummyInMemoryCacheLoader.class.getName());
Modified:
core/trunk/src/test/java/org/jboss/cache/passivation/ConcurrentPassivationTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/passivation/ConcurrentPassivationTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/passivation/ConcurrentPassivationTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -11,7 +11,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
import org.jboss.cache.loader.DummyInMemoryCacheLoader;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.fail;
@@ -47,7 +47,7 @@
private void initCaches()
{
CacheFactory<Integer, String> instance = new DefaultCacheFactory();
- cache = (CacheSPI) instance.createCache(new
XmlConfigurationParserOld().parseFile("META-INF/conf-test/local-passivation-service.xml"),
false);
+ cache = (CacheSPI) instance.createCache(new
XmlConfigurationParser2x().parseFile("META-INF/conf-test/local-passivation-service.xml"),
false);
cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
cache.getConfiguration().getCacheLoaderConfig().getFirstCacheLoaderConfig().setClassName(DummyInMemoryCacheLoader.class.getName());
cache.start();
Modified:
core/trunk/src/test/java/org/jboss/cache/passivation/LocalPassivationIntegrationTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/passivation/LocalPassivationIntegrationTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/passivation/LocalPassivationIntegrationTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -13,7 +13,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
import org.jboss.cache.loader.DummyInMemoryCacheLoader;
import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.notifications.annotation.CacheListener;
@@ -44,7 +44,7 @@
public void setUp() throws Exception
{
CacheFactory<String, String> instance = new DefaultCacheFactory();
- cache = (CacheSPI<String, String>) instance.createCache(new
XmlConfigurationParserOld().parseFile("META-INF/conf-test/local-passivation-service.xml"),
false);
+ cache = (CacheSPI<String, String>) instance.createCache(new
XmlConfigurationParser2x().parseFile("META-INF/conf-test/local-passivation-service.xml"),
false);
cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
cache.getConfiguration().getCacheLoaderConfig().getFirstCacheLoaderConfig().setClassName(DummyInMemoryCacheLoader.class.getName());
cache.getConfiguration().setUseRegionBasedMarshalling(true);
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -10,7 +10,7 @@
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.SamplePojo;
import org.jboss.cache.lock.IsolationLevel;
@@ -21,6 +21,7 @@
import org.jboss.util.stream.MarshalledValueInputStream;
import org.jboss.util.stream.MarshalledValueOutputStream;
import static org.testng.AssertJUnit.*;
+import static org.jboss.cache.factories.UnitTestCacheConfigurationFactory.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -53,23 +54,6 @@
CacheLoader loader = null;
static final Fqn<String> FQN = Fqn.fromString("/key");
-
- protected CacheLoaderConfig getCacheLoaderConfig(String preload, String
cacheloaderClass, String properties, boolean async, boolean fetchPersistentState) throws
Exception
- {
- String xml = "<config>\n" +
- "<passivation>true</passivation>\n" +
- "<preload>" + preload + "</preload>\n" +
- "<cacheloader>\n" +
- "<class>" + cacheloaderClass + "</class>\n"
+
- "<properties>" + properties +
"</properties>\n" +
- "<async>" + async + "</async>\n" +
- "<fetchPersistentState>" + fetchPersistentState +
"</fetchPersistentState>\n" +
- "</cacheloader>\n" +
- "</config>";
- Element element = XmlConfigHelper.stringToElement(xml);
- return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
- }
-
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
Modified:
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToBdbjeCacheLoaderTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToBdbjeCacheLoaderTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToBdbjeCacheLoaderTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -1,10 +1,7 @@
package org.jboss.cache.passivation;
-import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
-import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.testng.annotations.Test;
-import org.w3c.dom.Element;
+import static org.jboss.cache.factories.UnitTestCacheConfigurationFactory.*;
import java.io.File;
import java.io.FileFilter;
@@ -54,28 +51,6 @@
}
}
- cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(tmp_location));
+ cache.getConfiguration().setCacheLoaderConfig(buildSingleCacheLoaderConfig(true,
null, "org.jboss.cache.loader.bdbje.BdbjeCacheLoader", "", false,
false, false, false, false));
}
-
-
- protected CacheLoaderConfig getCacheLoaderConfig(String loc) throws Exception
- {
- String xml = " <config>\n" +
- " \n" +
- " <passivation>true</passivation>\n" +
- " <preload></preload>\n" +
- "\n" +
- " <cacheloader>\n" +
- "
<class>org.jboss.cache.loader.bdbje.BdbjeCacheLoader</class>\n" +
- " <properties>\n" +
- " </properties>\n" +
- " <async>false</async>\n" +
- "
<fetchPersistentState>false</fetchPersistentState>\n" +
- "
<ignoreModifications>false</ignoreModifications>\n" +
- " </cacheloader>\n" +
- " \n" +
- " </config>";
- Element element = XmlConfigHelper.stringToElement(xml);
- return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
- }
}
Modified:
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToFileCacheLoaderTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToFileCacheLoaderTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToFileCacheLoaderTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -1,9 +1,7 @@
package org.jboss.cache.passivation;
-import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
-import org.jboss.cache.config.parsing.XmlConfigHelper;
-import org.w3c.dom.Element;
+import static
org.jboss.cache.factories.UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig;
+import org.testng.annotations.Test;
/**
* tests passivation using file cache loader
@@ -11,46 +9,23 @@
* @author <a href="mailto:{hmesha@novell.com}">{Hany Mesha}</a>
* @version $Id$
*/
+@Test(groups ="funtional")
public class PassivationToFileCacheLoaderTest extends PassivationTestsBase
{
-
-
protected void configureCache() throws Exception
{
- String tmp_location = null;
+ String tmpLocation = null;
String OS = System.getProperty("os.name").toLowerCase();
if (OS.contains("win") || OS.contains("nt"))
{
- tmp_location = System.getProperty("java.io.tmpdir",
"c:\\tmp");
+ tmpLocation = System.getProperty("java.io.tmpdir",
"c:\\tmp");
}
else
{
- tmp_location = System.getProperty("jva.io.tmpdir", "/tmp");
+ tmpLocation = System.getProperty("jva.io.tmpdir", "/tmp");
}
- cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(tmp_location));
+ cache.getConfiguration().setCacheLoaderConfig(buildSingleCacheLoaderConfig(true,
null, "org.jboss.cache.loader.FileCacheLoader", "", false, false,
false, false, false));
}
-
- protected CacheLoaderConfig getCacheLoaderConfig(String loc) throws Exception
- {
- String xml = " <config>\n" +
- " \n" +
- " <passivation>true</passivation>\n"
+
- " <preload></preload>\n" +
- "\n" +
- " <cacheloader>\n" +
- "
<class>org.jboss.cache.loader.FileCacheLoader</class>\n" +
- " <properties>\n" +
- " </properties>\n" +
- " <async>false</async>\n" +
- "
<fetchPersistentState>false</fetchPersistentState>\n" +
- "
<ignoreModifications>false</ignoreModifications>\n" +
- " </cacheloader>\n" +
- " \n" +
- " </config>";
- Element element = XmlConfigHelper.stringToElement(xml);
- return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
- }
-
}
Modified:
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToJDBCCacheLoaderTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToJDBCCacheLoaderTest.java 2008-06-25
15:57:45 UTC (rev 6041)
+++
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToJDBCCacheLoaderTest.java 2008-06-25
17:04:10 UTC (rev 6042)
@@ -6,47 +6,21 @@
*/
package org.jboss.cache.passivation;
+import java.util.Properties;
+import static org.jboss.cache.factories.UnitTestCacheConfigurationFactory.*;
import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
-import org.jboss.cache.config.parsing.XmlConfigHelper;
-import org.w3c.dom.Element;
+import org.testng.annotations.Test;
-import java.util.Properties;
-
/**
* Tests passivation using JDBC Cache Loader.
* This test has MySQL hard-coded. To run it, run MySQL first: mysqld -u=root
*
* @author <a href="mailto:{hmesha@novell.com}">{Hany Mesha}</a>
- * @version $Id$
+ * @version $Id$
*/
+@Test(groups = "functional")
public class PassivationToJDBCCacheLoaderTest extends PassivationTestsBase
{
-
-
- protected CacheLoaderConfig getCacheLoaderConfig() throws Exception
- {
- String xml = " <config>\n" +
- " \n" +
- " <passivation>true</passivation>\n" +
- " <preload></preload>\n" +
- "\n" +
- " <cacheloader>\n" +
- "
<class>org.jboss.cache.loader.JDBCCacheLoader</class>\n" +
- " <properties>\n" +
- getJDBCProps() +
- " </properties>\n" +
- " <async>false</async>\n" +
- "
<fetchPersistentState>false</fetchPersistentState>\n" +
- "
<ignoreModifications>false</ignoreModifications>\n" +
- " </cacheloader>\n" +
- " \n" +
- " </config>";
- Element element = XmlConfigHelper.stringToElement(xml);
- return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
- }
-
-
protected String getJDBCProps()
{
Properties prop = new Properties();
@@ -68,6 +42,8 @@
protected void configureCache() throws Exception
{
- cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig());
+ CacheLoaderConfig loaderConfig = buildSingleCacheLoaderConfig(true, null,
"org.jboss.cache.loader.JDBCCacheLoader",
+ getJDBCProps(), false, false, false, false, false);
+ cache.getConfiguration().setCacheLoaderConfig(loaderConfig);
}
}
Modified: core/trunk/src/test/resources/META-INF/conf-test/all-elements-file-3.x.xml
===================================================================
--- core/trunk/src/test/resources/META-INF/conf-test/all-elements-file-3.x.xml 2008-06-25
15:57:45 UTC (rev 6041)
+++ core/trunk/src/test/resources/META-INF/conf-test/all-elements-file-3.x.xml 2008-06-25
17:04:10 UTC (rev 6042)
@@ -13,9 +13,16 @@
<!-- either replication or invalidation tags will be present, not both -->
<replication>
- <!-- either sync or async will be present, not both -->
- <async useReplQueue="false" replQueueInterval="12"
replQueueMaxElements="12345"/>
<sync replTimeout="15421"/>
+ <buddy enabled="true" poolName="myBuddyPoolReplicationGroup"
communicationTimeout="2000">
+ <dataGravitation auto="true" removeOnFind="true"
searchBackupTrees="true"/>
+ <locator
class="org.jboss.cache.buddyreplication.NextMemberBuddyLocator">
+ <properties>
+ numBuddies = 1
+ ignoreColocatedBuddies = true
+ </properties>
+ </locator>
+ </buddy>
</replication>
<!-- either replication or invalidation tags will be present, not both -->
@@ -28,10 +35,10 @@
<startup fetchInMemoryState="true" stateRetrievalTimeout="1524"
inactiveOnStartup="true"/>
<shutdown hookBehavior="REGISTER"/>
- <transport clusterName="JBossCache-Cluster">
- <clusterName>JBossCache-Cluster</clusterName>
- <multiplexer stack="file_name"/>
- <clusterConfig>
+ <jmxStatistics enabled="false"/>
+
+ <transport clusterName="JBossCache-Cluster"
multiplexerStack="file_name">
+ <jgroupsConfig>
<PING timeout="2000" num_initial_members="3"/>
<MERGE2 max_interval="30000" min_interval="10000"/>
<FD_SOCK/>
@@ -48,17 +55,15 @@
<FRAG2 frag_size="60000"/>
<pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
<pbcast.FLUSH timeout="0"/>
- </clusterConfig>
+ </jgroupsConfig>
</transport>
-
- <jmxStatistics enabled="false"/>
-
- <eviction wakeUpInterval="5"
defaultPolicyClass="org.jboss.cache.eviction.LRUPolicy"
defaultEventQueueSize="200000">
- <default>
+ <eviction wakeUpInterval="5">
+ <defaults policyClass="org.jboss.cache.eviction.LRUPolicy"
eventQueueSize="200000"/>
+ <root>
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLive">1000</attribute>
- </default>
+ </root>
<region name="/org/jboss/data">
<attribute name="timeToLive">1002</attribute>
</region>
@@ -68,34 +73,29 @@
</region>
</eviction>
- <!-- this should be deprecated in 3.0 and should be replaced with
CacheLoaderConfig-->
- <cacheLoaders passivation="false" shared="false">
+ <loaders passivation="false" shared="false">
<preload>
<node fqn="/a/b/c"/>
<node fqn="/f/r/s"/>
</preload>
<!-- we can now have multiple cache loaders, which get chained -->
- <cacheLoader class="org.jboss.cache.loader.JDBCCacheLoader"
async="true" fetchPersistentState="true"
- ignoreModifications="true"
purgeOnStartup="true">
+ <loader class="org.jboss.cache.loader.JDBCCacheLoader"
async="true" fetchPersistentState="true"
+ ignoreModifications="true" purgeOnStartup="true">
<properties>
cache.jdbc.table.name=jbosscache
cache.jdbc.table.create=true
cache.jdbc.table.drop=true
</properties>
- </cacheLoader>
- </cacheLoaders>
+ <singletonStore enabled="false"
class="org.jboss.cache.loader.SingletonStoreCacheLoader">
+ <properties>
+ pushStateWhenCoordinator=true
+ pushStateWhenCoordinatorTimeout=20000
+ </properties>
+ </singletonStore>
+ </loader>
+ </loaders>
- <buddyReplication enabled="true"
buddyPoolName="myBuddyPoolReplicationGroup"
buddyCommunicationTimeout="2000">
- <dataGravitation auto="true" removeOnFind="true"
searchBackupTrees="true"/>
- <buddyLocator
class="org.jboss.cache.buddyreplication.NextMemberBuddyLocator">
- <properties>
- numBuddies = 1
- ignoreColocatedBuddies = true
- </properties>
- </buddyLocator>
- </buddyReplication>
-
<!-- this is new behavior added within 3.x only. it support configuring custom
interceptors through configurations -->
<customInterceptors>
<interceptor class="com.myCompany.MyInterceptor1">
Modified: core/trunk/src/test/resources/META-INF/conf-test/parser-test-file-2.x.xml
===================================================================
--- core/trunk/src/test/resources/META-INF/conf-test/parser-test-file-2.x.xml 2008-06-25
15:57:45 UTC (rev 6041)
+++ core/trunk/src/test/resources/META-INF/conf-test/parser-test-file-2.x.xml 2008-06-25
17:04:10 UTC (rev 6042)
@@ -10,7 +10,7 @@
<attribute
name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
</attribute>
<attribute name="IsolationLevel">REPEATABLE_READ</attribute>
- <attribute name="CacheMode">REPL_SYNC</attribute>
+ <attribute name="CacheMode">REPL_ASYNC</attribute>
<attribute name="UseReplQueue">false</attribute>
<attribute name="ReplQueueInterval">12</attribute>
@@ -118,7 +118,24 @@
<fetchPersistentState>true</fetchPersistentState>
<ignoreModifications>true</ignoreModifications>
<purgeOnStartup>true</purgeOnStartup>
+ <singletonStore>
+ <enabled>false</enabled>
+ <properties>
+ pushStateWhenCoordinator=true
+ pushStateWhenCoordinatorTimeout=5000
+ </properties>
+ </singletonStore>
</cacheloader>
+ <cacheloader>
+ <class>org.jboss.cache.loader.bdbje.BdbjeCacheLoader</class>
+ <properties>
+ location=/tmp/BdbjeCacheLoader
+ </properties>
+ <async>false</async>
+ <!-- only one cache loader in the chain may set fetchPersistentState to
true.-->
+ <fetchPersistentState>false</fetchPersistentState>
+ <ignoreModifications>false</ignoreModifications>
+ </cacheloader>
</config>
</attribute>
Modified: core/trunk/src/test/resources/META-INF/conf-test/parser-test-file-3.x.xml
===================================================================
--- core/trunk/src/test/resources/META-INF/conf-test/parser-test-file-3.x.xml 2008-06-25
15:57:45 UTC (rev 6041)
+++ core/trunk/src/test/resources/META-INF/conf-test/parser-test-file-3.x.xml 2008-06-25
17:04:10 UTC (rev 6042)
@@ -13,14 +13,21 @@
<replication>
<sync replTimeout="15421"/>
+ <buddy enabled="true" poolName="myBuddyPoolReplicationGroup"
communicationTimeout="2000">
+ <dataGravitation auto="true" removeOnFind="true"
searchBackupTrees="true"/>
+ <locator
class="org.jboss.cache.buddyreplication.NextMemberBuddyLocator">
+ <properties>
+ numBuddies = 1
+ ignoreColocatedBuddies = true
+ </properties>
+ </locator>
+ </buddy>
</replication>
<startup fetchInMemoryState="true"
stateRetrievalTimeout="15124" inactiveOnStartup="true"/>
<shutdown hookBehavior="REGISTER"/>
- <transport clusterName="JBossCache-Cluster">
- <clusterName>JBossCache-Cluster</clusterName>
- <multiplexer stack="file_name"/>
+ <transport clusterName="JBossCache-Cluster"
multiplexerStack="file_name">
<jgroupsConfig>
<PING timeout="2000" num_initial_members="3"/>
<MERGE2 max_interval="30000" min_interval="10000"/>
@@ -45,11 +52,12 @@
<jmxStatistics enabled="false"/>
- <eviction wakeUpInterval="5"
defaultPolicyClass="org.jboss.cache.eviction.LRUPolicy"
defaultEventQueueSize="200000">
- <default>
+ <eviction wakeUpInterval="5">
+ <defaults policyClass="org.jboss.cache.eviction.LRUPolicy"
eventQueueSize="200000"/>
+ <root>
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLive">1000</attribute>
- </default>
+ </root>
<region name="/org/jboss/data">
<attribute name="timeToLive">1002</attribute>
</region>
@@ -60,33 +68,29 @@
</eviction>
<!-- this should be deprecated in 3.0 and should be replaced with
CacheLoaderConfig-->
- <cacheLoaders passivation="true" shared="true">
+ <loaders passivation="true" shared="true">
<preload>
<node fqn="/a/b/c"/>
<node fqn="/f/r/s"/>
</preload>
<!-- we can now have multiple cache loaders, which get chained -->
- <cacheLoader class="org.jboss.cache.loader.JDBCCacheLoader"
async="true" fetchPersistentState="true"
+ <loader class="org.jboss.cache.loader.JDBCCacheLoader"
async="true" fetchPersistentState="true"
ignoreModifications="true"
purgeOnStartup="true">
<properties>
cache.jdbc.table.name=jbosscache
cache.jdbc.table.create=true
cache.jdbc.table.drop=true
</properties>
- </cacheLoader>
- </cacheLoaders>
+ <singletonStore enabled="true"
class="org.jboss.cache.loader.SingletonStoreCacheLoader">
+ <properties>
+ pushStateWhenCoordinator=true
+ pushStateWhenCoordinatorTimeout=20000
+ </properties>
+ </singletonStore>
+ </loader>
+ </loaders>
- <buddyReplication enabled="true"
buddyPoolName="myBuddyPoolReplicationGroup"
buddyCommunicationTimeout="2000">
- <dataGravitation auto="true" removeOnFind="true"
searchBackupTrees="true"/>
- <buddyLocator
class="org.jboss.cache.buddyreplication.NextMemberBuddyLocator">
- <properties>
- numBuddies = 1
- ignoreColocatedBuddies = true
- </properties>
- </buddyLocator>
- </buddyReplication>
-
<!-- this is new behavior added within 3.x only. it support configuring custom
interceptors through configurations -->
<customInterceptors>
<interceptor class="com.myCompany.MyInterceptor1">