This is an automated email from the ASF dual-hosted git repository. tv pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-jcs.git
commit fb913e45371e34dde819c6de9a714276daa9f8c0 Author: Thomas Vandahl <[email protected]> AuthorDate: Thu Feb 12 12:10:04 2026 +0100 Unify, simplify and extend auxiliary configuration --- .../jcs4/auxiliary/AuxiliaryCacheConfigurator.java | 13 +- .../jcs4/auxiliary/AuxiliaryCacheFactory.java | 9 +- .../disk/block/BlockDiskCacheFactory.java | 14 +- .../disk/indexed/IndexedDiskCacheFactory.java | 14 +- .../auxiliary/disk/jdbc/JDBCDiskCacheFactory.java | 21 ++- .../disk/jdbc/hsql/HSQLDiskCacheFactory.java | 25 +-- .../disk/jdbc/mysql/MySQLDiskCacheFactory.java | 21 ++- .../lateral/socket/tcp/LateralTCPCacheFactory.java | 16 +- .../socket/tcp/LateralTCPDiscoveryListener.java | 2 +- .../jcs4/auxiliary/remote/RemoteCacheFactory.java | 56 +++--- .../jcs4/auxiliary/remote/RemoteCacheManager.java | 21 ++- .../remote/http/client/RemoteHttpCacheFactory.java | 22 ++- .../engine/control/CompositeCacheConfigurator.java | 80 +++++---- .../jcs4/engine/control/CompositeCacheManager.java | 36 +--- .../commons/jcs4/utils/config/OptionConverter.java | 196 ++------------------- .../commons/jcs4/utils/config/PropertySetter.java | 5 +- .../jcs4/auxiliary/MockAuxiliaryCacheFactory.java | 12 +- .../auxiliary/disk/jdbc/JDBCDiskCacheUnitTest.java | 4 +- .../tcp/LateralTCPDiscoveryListenerUnitTest.java | 13 +- .../remote/RemoteCacheNoWaitFacadeUnitTest.java | 2 +- .../jcs4/auxiliary/remote/TestRemoteCache.java | 4 +- .../auxiliary/remote/TestRemoteCacheFactory.java | 23 ++- .../client/RemoteHttpCacheFactoryUnitTest.java | 5 +- .../BasicRemoteCacheClientServerUnitTest.java | 16 +- .../CompositeCacheConfiguratorUnitTest.java | 12 +- .../jcs4/engine/control/MockKeyMatcher.java | 36 ++++ .../src/test/test-conf/TestBlockDiskCache.ccf | 2 - .../src/test/test-conf/TestBlockDiskCacheCon.ccf | 1 - .../src/test/test-conf/TestBlockDiskCacheHuge.ccf | 1 - .../test-conf/TestBlockDiskCacheSteadyLoad.ccf | 1 - .../src/test/test-conf/TestDiskCache.ccf | 2 - .../src/test/test-conf/TestDiskCacheCon.ccf | 1 - .../test-conf/TestDiskCacheDefragPerformance.ccf | 1 - .../src/test/test-conf/TestDiskCacheHuge.ccf | 1 - .../src/test/test-conf/TestDiskCacheNoMemory.ccf | 2 - .../src/test/test-conf/TestDiskCacheSteadyLoad.ccf | 1 - .../test/test-conf/TestDiskCacheUsagePattern.ccf | 1 - .../src/test/test-conf/TestElementSerializer.ccf | 3 - .../src/test/test-conf/TestHSQLDiskCache.ccf | 2 - .../test/test-conf/TestHSQLDiskCacheConcurrent.ccf | 2 - .../src/test/test-conf/TestJCS-73.ccf | 1 - .../src/test/test-conf/TestJDBCDiskCache.ccf | 1 - .../test/test-conf/TestJDBCDiskCacheRemoval.ccf | 1 - .../test/test-conf/TestJDBCDiskCacheSharedPool.ccf | 2 - .../src/test/test-conf/TestJDBCDiskCacheShrink.ccf | 1 - .../src/test/test-conf/TestMySQLDiskCache.ccf | 1 - .../src/test/test-conf/TestRemoteClient.ccf | 1 - .../src/test/test-conf/TestRemoteHttpCache.ccf | 1 - .../src/test/test-conf/TestSimpleEventHandling.ccf | 1 - .../src/test/test-conf/TestSystemProperties.ccf | 1 - .../src/test/test-conf/TestTCPLateralCache.ccf | 1 - .../test-conf/TestTCPLateralCacheConcurrent.ccf | 1 - .../test-conf/TestTCPLateralIssueRemoveCache.ccf | 1 - .../test/test-conf/TestTCPLateralRemoveFilter.ccf | 1 - 54 files changed, 314 insertions(+), 400 deletions(-) diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/AuxiliaryCacheConfigurator.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/AuxiliaryCacheConfigurator.java index 91dc5c40..0801789b 100644 --- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/AuxiliaryCacheConfigurator.java +++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/AuxiliaryCacheConfigurator.java @@ -61,16 +61,14 @@ public class AuxiliaryCacheConfigurator * @param auxPrefix For example, AUXILIARY_PREFIX + auxName * @return cacheEventLogger */ - public static ICacheEventLogger parseCacheEventLogger( final Properties props, final String auxPrefix ) + public static ICacheEventLogger parseCacheEventLogger(final Properties props, final String auxPrefix) { - - // auxFactory was not previously initialized. final String eventLoggerClassName = auxPrefix + CACHE_EVENT_LOGGER_PREFIX; final ICacheEventLogger cacheEventLogger = OptionConverter.instantiateByKey( props, eventLoggerClassName, null ); if ( cacheEventLogger != null ) { - final String cacheEventLoggerAttributePrefix = auxPrefix + CACHE_EVENT_LOGGER_PREFIX + ATTRIBUTE_PREFIX; - PropertySetter.setProperties( cacheEventLogger, props, cacheEventLoggerAttributePrefix + "." ); + final String cacheEventLoggerAttributePrefix = auxPrefix + CACHE_EVENT_LOGGER_PREFIX + ATTRIBUTE_PREFIX + "."; + PropertySetter.setProperties( cacheEventLogger, props, cacheEventLoggerAttributePrefix); log.info( "Using custom cache event logger [{0}] for auxiliary [{1}]", cacheEventLogger, auxPrefix ); } @@ -91,13 +89,12 @@ public class AuxiliaryCacheConfigurator public static IElementSerializer parseElementSerializer( final Properties props, final String auxPrefix ) { // TODO take in the entire prop key - // auxFactory was not previously initialized. final String elementSerializerClassName = auxPrefix + SERIALIZER_PREFIX; IElementSerializer elementSerializer = OptionConverter.instantiateByKey( props, elementSerializerClassName, null ); if ( elementSerializer != null ) { - final String attributePrefix = auxPrefix + SERIALIZER_PREFIX + ATTRIBUTE_PREFIX; - PropertySetter.setProperties( elementSerializer, props, attributePrefix + "." ); + final String attributePrefix = auxPrefix + SERIALIZER_PREFIX + ATTRIBUTE_PREFIX + "."; + PropertySetter.setProperties(elementSerializer, props, attributePrefix); log.info( "Using custom element serializer [{0}] for auxiliary [{1}]", elementSerializer, auxPrefix ); } diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/AuxiliaryCacheFactory.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/AuxiliaryCacheFactory.java index cd1caa49..c55071a1 100644 --- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/AuxiliaryCacheFactory.java +++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/AuxiliaryCacheFactory.java @@ -22,6 +22,7 @@ package org.apache.commons.jcs4.auxiliary; import org.apache.commons.jcs4.engine.behavior.ICompositeCacheManager; import org.apache.commons.jcs4.engine.behavior.IElementSerializer; import org.apache.commons.jcs4.engine.logging.behavior.ICacheEventLogger; +import org.apache.commons.jcs4.engine.match.behavior.IKeyMatcher; /** * All auxiliary caches must have a factory that the cache configurator can use to create instances. @@ -35,14 +36,16 @@ public interface AuxiliaryCacheFactory * @param cacheMgr This allows auxiliaries to reference the manager without assuming that it is * a singleton. This will allow JCS to be a non-singleton. Also, it makes it easier to * test. - * @param cacheEventLogger - * @param elementSerializer + * @param cacheEventLogger the cache event logger + * @param elementSerializer the serializer for cache elements + * @param keyMatcher the key matcher for getMatching() calls * @return AuxiliaryCache * @throws Exception if cache instance could not be created */ <K, V> AuxiliaryCache<K, V> createCache( AuxiliaryCacheAttributes attr, ICompositeCacheManager cacheMgr, - ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer ) + ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer, + IKeyMatcher<K> keyMatcher) throws Exception; /** diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/block/BlockDiskCacheFactory.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/block/BlockDiskCacheFactory.java index 867070c2..034bb1b0 100644 --- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/block/BlockDiskCacheFactory.java +++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/block/BlockDiskCacheFactory.java @@ -24,6 +24,7 @@ import org.apache.commons.jcs4.auxiliary.AuxiliaryCacheAttributes; import org.apache.commons.jcs4.engine.behavior.ICompositeCacheManager; import org.apache.commons.jcs4.engine.behavior.IElementSerializer; import org.apache.commons.jcs4.engine.logging.behavior.ICacheEventLogger; +import org.apache.commons.jcs4.engine.match.behavior.IKeyMatcher; import org.apache.commons.jcs4.log.Log; /** @@ -42,19 +43,22 @@ public class BlockDiskCacheFactory * @param cacheMgr This allows auxiliaries to reference the manager without assuming that it is * a singleton. This will allow JCS to be a non-singleton. Also, it makes it easier * to test. - * @param cacheEventLogger - * @param elementSerializer + * @param cacheEventLogger the cache event logger + * @param elementSerializer the serializer for cache elements + * @param keyMatcher the key matcher for getMatching() calls * @return BlockDiskCache */ @Override - public <K, V> BlockDiskCache<K, V> createCache( final AuxiliaryCacheAttributes iaca, final ICompositeCacheManager cacheMgr, - final ICacheEventLogger cacheEventLogger, final IElementSerializer elementSerializer ) + public <K, V> BlockDiskCache<K, V> createCache(final AuxiliaryCacheAttributes iaca, + final ICompositeCacheManager cacheMgr, final ICacheEventLogger cacheEventLogger, + final IElementSerializer elementSerializer, final IKeyMatcher<K> keyMatcher) { final BlockDiskCacheAttributes idca = (BlockDiskCacheAttributes) iaca; log.debug("Creating DiskCache for attributes = {0}", idca); final BlockDiskCache<K, V> cache = new BlockDiskCache<>( idca, elementSerializer ); - cache.setCacheEventLogger( cacheEventLogger ); + cache.setCacheEventLogger(cacheEventLogger); + cache.setKeyMatcher(keyMatcher); return cache; } diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/indexed/IndexedDiskCacheFactory.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/indexed/IndexedDiskCacheFactory.java index d3249a1c..9eec5051 100644 --- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/indexed/IndexedDiskCacheFactory.java +++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/indexed/IndexedDiskCacheFactory.java @@ -24,6 +24,7 @@ import org.apache.commons.jcs4.auxiliary.AuxiliaryCacheAttributes; import org.apache.commons.jcs4.engine.behavior.ICompositeCacheManager; import org.apache.commons.jcs4.engine.behavior.IElementSerializer; import org.apache.commons.jcs4.engine.logging.behavior.ICacheEventLogger; +import org.apache.commons.jcs4.engine.match.behavior.IKeyMatcher; import org.apache.commons.jcs4.log.Log; /** @@ -42,19 +43,22 @@ public class IndexedDiskCacheFactory * @param cacheMgr This allows auxiliaries to reference the manager without assuming that it is * a singleton. This will allow JCS to be a non-singleton. Also, it makes it easier to * test. - * @param cacheEventLogger - * @param elementSerializer + * @param cacheEventLogger the cache event logger + * @param elementSerializer the serializer for cache elements + * @param keyMatcher the key matcher for getMatching() calls * @return IndexedDiskCache */ @Override - public <K, V> IndexedDiskCache<K, V> createCache( final AuxiliaryCacheAttributes iaca, final ICompositeCacheManager cacheMgr, - final ICacheEventLogger cacheEventLogger, final IElementSerializer elementSerializer ) + public <K, V> IndexedDiskCache<K, V> createCache(final AuxiliaryCacheAttributes iaca, + final ICompositeCacheManager cacheMgr, final ICacheEventLogger cacheEventLogger, + final IElementSerializer elementSerializer, final IKeyMatcher<K> keyMatcher) { final IndexedDiskCacheAttributes idca = (IndexedDiskCacheAttributes) iaca; log.debug( "Creating DiskCache for attributes = {0}", idca ); final IndexedDiskCache<K, V> cache = new IndexedDiskCache<>( idca, elementSerializer ); - cache.setCacheEventLogger( cacheEventLogger ); + cache.setCacheEventLogger(cacheEventLogger); + cache.setKeyMatcher(keyMatcher); return cache; } diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCacheFactory.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCacheFactory.java index 95aa9963..688062c9 100644 --- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCacheFactory.java +++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCacheFactory.java @@ -35,6 +35,7 @@ import org.apache.commons.jcs4.engine.behavior.ICompositeCacheManager; import org.apache.commons.jcs4.engine.behavior.IElementSerializer; import org.apache.commons.jcs4.engine.behavior.IRequireScheduler; import org.apache.commons.jcs4.engine.logging.behavior.ICacheEventLogger; +import org.apache.commons.jcs4.engine.match.behavior.IKeyMatcher; import org.apache.commons.jcs4.log.Log; import org.apache.commons.jcs4.utils.config.PropertySetter; @@ -76,25 +77,27 @@ public class JDBCDiskCacheFactory * This factory method should create an instance of the jdbc cache. * * @param rawAttr specific cache configuration attributes - * @param compositeCacheManager the global cache manager - * @param cacheEventLogger a specific logger for cache events - * @param elementSerializer a serializer for cache elements + * @param cacheMgr the global cache manager + * @param cacheEventLogger the cache event logger + * @param elementSerializer the serializer for cache elements + * @param keyMatcher the key matcher for getMatching() calls * @return JDBCDiskCache the cache instance * @throws SQLException if the cache instance could not be created */ @Override public <K, V> JDBCDiskCache<K, V> createCache( final AuxiliaryCacheAttributes rawAttr, - final ICompositeCacheManager compositeCacheManager, - final ICacheEventLogger cacheEventLogger, final IElementSerializer elementSerializer ) + final ICompositeCacheManager cacheMgr, final ICacheEventLogger cacheEventLogger, + final IElementSerializer elementSerializer, IKeyMatcher<K> keyMatcher) throws SQLException { final JDBCDiskCacheAttributes cattr = (JDBCDiskCacheAttributes) rawAttr; final TableState tableState = getTableState( cattr.getTableName() ); - final DataSourceFactory dsFactory = getDataSourceFactory(cattr, compositeCacheManager.getConfigurationProperties()); + final DataSourceFactory dsFactory = getDataSourceFactory(cattr, cacheMgr.getConfigurationProperties()); final JDBCDiskCache<K, V> cache = new JDBCDiskCache<>(cattr, dsFactory, tableState); - cache.setCacheEventLogger( cacheEventLogger ); - cache.setElementSerializer( elementSerializer ); + cache.setCacheEventLogger(cacheEventLogger); + cache.setElementSerializer(elementSerializer); + cache.setKeyMatcher(keyMatcher); // create a shrinker if we need it. createShrinkerWhenNeeded( cattr, cache ); @@ -255,7 +258,7 @@ public class JDBCDiskCacheFactory * @return The class value */ @Override - public Class<JDBCDiskCacheAttributes> getAttributeClass() + public Class<? extends JDBCDiskCacheAttributes> getAttributeClass() { return JDBCDiskCacheAttributes.class; } diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/hsql/HSQLDiskCacheFactory.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/hsql/HSQLDiskCacheFactory.java index 776621c1..039e57c1 100644 --- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/hsql/HSQLDiskCacheFactory.java +++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/hsql/HSQLDiskCacheFactory.java @@ -34,6 +34,7 @@ import org.apache.commons.jcs4.auxiliary.disk.jdbc.JDBCDiskCacheFactory; import org.apache.commons.jcs4.engine.behavior.ICompositeCacheManager; import org.apache.commons.jcs4.engine.behavior.IElementSerializer; import org.apache.commons.jcs4.engine.logging.behavior.ICacheEventLogger; +import org.apache.commons.jcs4.engine.match.behavior.IKeyMatcher; import org.apache.commons.jcs4.log.Log; /** @@ -48,26 +49,28 @@ public class HSQLDiskCacheFactory /** * This factory method should create an instance of the hsqlcache. * - * @param rawAttr - * @param compositeCacheManager - * @param cacheEventLogger - * @param elementSerializer + * @param iaca the cache attributes for this cache + * @param cacheMgr This allows auxiliaries to reference the manager without assuming that it is + * a singleton. This will allow JCS to be a non-singleton. Also, it makes it easier + * to test. + * @param cacheEventLogger the cache event logger + * @param elementSerializer the serializer for cache elements + * @param keyMatcher the key matcher for getMatching() calls * @return JDBCDiskCache * @throws SQLException if the creation of the cache instance fails */ @Override - public <K, V> JDBCDiskCache<K, V> createCache( final AuxiliaryCacheAttributes rawAttr, - final ICompositeCacheManager compositeCacheManager, - final ICacheEventLogger cacheEventLogger, - final IElementSerializer elementSerializer ) + public <K, V> JDBCDiskCache<K, V> createCache( final AuxiliaryCacheAttributes iaca, + final ICompositeCacheManager cacheMgr, final ICacheEventLogger cacheEventLogger, + final IElementSerializer elementSerializer, IKeyMatcher<K> keyMatcher) throws SQLException { // TODO get this from the attributes. System.setProperty( "hsqldb.cache_scale", "8" ); - final JDBCDiskCache<K, V> cache = super.createCache(rawAttr, compositeCacheManager, - cacheEventLogger, elementSerializer); - setupDatabase( cache.getDataSource(), (JDBCDiskCacheAttributes) rawAttr ); + final JDBCDiskCache<K, V> cache = super.createCache(iaca, cacheMgr, + cacheEventLogger, elementSerializer, keyMatcher); + setupDatabase( cache.getDataSource(), (JDBCDiskCacheAttributes) iaca ); return cache; } diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/mysql/MySQLDiskCacheFactory.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/mysql/MySQLDiskCacheFactory.java index 3c600fa9..bd83cd8c 100644 --- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/mysql/MySQLDiskCacheFactory.java +++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/mysql/MySQLDiskCacheFactory.java @@ -34,6 +34,7 @@ import org.apache.commons.jcs4.auxiliary.disk.jdbc.mysql.util.ScheduleParser; import org.apache.commons.jcs4.engine.behavior.ICompositeCacheManager; import org.apache.commons.jcs4.engine.behavior.IElementSerializer; import org.apache.commons.jcs4.engine.logging.behavior.ICacheEventLogger; +import org.apache.commons.jcs4.engine.match.behavior.IKeyMatcher; import org.apache.commons.jcs4.log.Log; /** @@ -65,25 +66,27 @@ public class MySQLDiskCacheFactory * This factory method should create an instance of the mysqlcache. * * @param rawAttr specific cache configuration attributes - * @param compositeCacheManager the global cache manager - * @param cacheEventLogger a specific logger for cache events - * @param elementSerializer a serializer for cache elements + * @param cacheMgr the global cache manager + * @param cacheEventLogger the cache event logger + * @param elementSerializer the serializer for cache elements + * @param keyMatcher the key matcher for getMatching() calls * @return MySQLDiskCache the cache instance * @throws SQLException if the cache instance could not be created */ @Override public <K, V> MySQLDiskCache<K, V> createCache( final AuxiliaryCacheAttributes rawAttr, - final ICompositeCacheManager compositeCacheManager, - final ICacheEventLogger cacheEventLogger, final IElementSerializer elementSerializer ) + final ICompositeCacheManager cacheMgr, final ICacheEventLogger cacheEventLogger, + final IElementSerializer elementSerializer, final IKeyMatcher<K> keyMatcher) throws SQLException { final MySQLDiskCacheAttributes cattr = (MySQLDiskCacheAttributes) rawAttr; final TableState tableState = getTableState( cattr.getTableName() ); - final DataSourceFactory dsFactory = getDataSourceFactory(cattr, compositeCacheManager.getConfigurationProperties()); + final DataSourceFactory dsFactory = getDataSourceFactory(cattr, cacheMgr.getConfigurationProperties()); final MySQLDiskCache<K, V> cache = new MySQLDiskCache<>( cattr, dsFactory, tableState); cache.setCacheEventLogger( cacheEventLogger ); cache.setElementSerializer( elementSerializer ); + cache.setKeyMatcher(keyMatcher); // create a shrinker if we need it. createShrinkerWhenNeeded( cattr, cache ); @@ -151,4 +154,10 @@ public class MySQLDiskCacheFactory } } } + + @Override + public Class<MySQLDiskCacheAttributes> getAttributeClass() + { + return MySQLDiskCacheAttributes.class; + } } diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java index 0ed8b891..0fa53263 100644 --- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java +++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java @@ -37,6 +37,7 @@ import org.apache.commons.jcs4.engine.behavior.IElementSerializer; import org.apache.commons.jcs4.engine.behavior.IShutdownObserver; import org.apache.commons.jcs4.engine.control.CompositeCacheManager; import org.apache.commons.jcs4.engine.logging.behavior.ICacheEventLogger; +import org.apache.commons.jcs4.engine.match.behavior.IKeyMatcher; import org.apache.commons.jcs4.log.Log; import org.apache.commons.jcs4.utils.discovery.UDPDiscoveryAttributes; import org.apache.commons.jcs4.utils.discovery.UDPDiscoveryManager; @@ -155,14 +156,15 @@ public class LateralTCPCacheFactory * @param <V> cache value type * @param iaca the cache configuration object * @param cacheMgr the cache manager - * @param cacheEventLogger the event logger - * @param elementSerializer the serializer to use when sending or receiving + * @param cacheEventLogger the cache event logger + * @param elementSerializer the serializer for cache elements + * @param keyMatcher the key matcher for getMatching() calls * @return a LateralTCPCacheNoWaitFacade */ @Override - public <K, V> LateralTCPCacheNoWaitFacade<K, V> createCache( - final AuxiliaryCacheAttributes iaca, final ICompositeCacheManager cacheMgr, - final ICacheEventLogger cacheEventLogger, final IElementSerializer elementSerializer ) + public <K, V> LateralTCPCacheNoWaitFacade<K, V> createCache(final AuxiliaryCacheAttributes iaca, + final ICompositeCacheManager cacheMgr, final ICacheEventLogger cacheEventLogger, + final IElementSerializer elementSerializer, final IKeyMatcher<K> keyMatcher) { final LateralTCPCacheAttributes lac = (LateralTCPCacheAttributes) iaca; final ArrayList<LateralTCPCacheNoWait<K, V>> noWaits = new ArrayList<>(); @@ -182,8 +184,9 @@ public class LateralTCPCacheFactory lacClone.setTcpServer( server ); final LateralTCPCacheNoWait<K, V> lateralNoWait = createCacheNoWait(lacClone, cacheEventLogger, elementSerializer); + lateralNoWait.setKeyMatcher(keyMatcher); - addListenerIfNeeded( lacClone, cacheMgr, elementSerializer ); + addListenerIfNeeded(lacClone, cacheMgr, elementSerializer); monitorCache(lateralNoWait); noWaits.add( lateralNoWait ); } @@ -194,6 +197,7 @@ public class LateralTCPCacheFactory // create the no wait facade. final LateralTCPCacheNoWaitFacade<K, V> lcnwf = new LateralTCPCacheNoWaitFacade<>(listener, noWaits, lac); + lcnwf.setKeyMatcher(keyMatcher); // create udp discovery if available. createDiscoveryService( lac, lcnwf, cacheMgr, cacheEventLogger, elementSerializer ); diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListener.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListener.java index 97de363e..8d5afc7f 100644 --- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListener.java +++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListener.java @@ -136,7 +136,7 @@ public class LateralTCPDiscoveryListener lca.setTcpServer(serverAndPort); final LateralTCPCacheFactory factory = - (LateralTCPCacheFactory) cacheManager.registryFacGet(factoryName); + (LateralTCPCacheFactory) cacheManager.getRegisteredAuxiliaryFactory(factoryName); final LateralTCPCacheNoWait<?, ?> noWait = factory.createCacheNoWait(lca, cacheEventLogger, elementSerializer); diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheFactory.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheFactory.java index 0e2bc493..085fcec2 100644 --- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheFactory.java +++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheFactory.java @@ -25,13 +25,13 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import org.apache.commons.jcs4.auxiliary.AbstractAuxiliaryCacheFactory; -import org.apache.commons.jcs4.auxiliary.AuxiliaryCache; import org.apache.commons.jcs4.auxiliary.AuxiliaryCacheAttributes; import org.apache.commons.jcs4.auxiliary.remote.behavior.IRemoteCacheAttributes; import org.apache.commons.jcs4.auxiliary.remote.server.behavior.RemoteType; import org.apache.commons.jcs4.engine.behavior.ICompositeCacheManager; import org.apache.commons.jcs4.engine.behavior.IElementSerializer; import org.apache.commons.jcs4.engine.logging.behavior.ICacheEventLogger; +import org.apache.commons.jcs4.engine.match.behavior.IKeyMatcher; /** * The RemoteCacheFactory creates remote caches for the cache hub. It returns a no wait facade which @@ -55,19 +55,21 @@ public class RemoteCacheFactory * The failover runner will get a cache from the manager. When the primary is restored it will * tell the manager for the failover to deregister the listener. * - * @param iaca - * @param cacheMgr - * @param cacheEventLogger - * @param elementSerializer - * @return AuxiliaryCache + * @param iaca the cache attributes for this cache + * @param cacheMgr This allows auxiliaries to reference the manager without assuming that it is + * a singleton. This will allow JCS to be a non-singleton. Also, it makes it easier + * to test. + * @param cacheEventLogger the cache event logger + * @param elementSerializer the serializer for cache elements + * @param keyMatcher the key matcher for getMatching() calls + * @return RemoteCacheNoWaitFacade */ @Override - public <K, V> AuxiliaryCache<K, V> createCache( - final AuxiliaryCacheAttributes iaca, final ICompositeCacheManager cacheMgr, - final ICacheEventLogger cacheEventLogger, final IElementSerializer elementSerializer ) + public <K, V> RemoteCacheNoWaitFacade<K, V> createCache(final AuxiliaryCacheAttributes iaca, + final ICompositeCacheManager cacheMgr, final ICacheEventLogger cacheEventLogger, + final IElementSerializer elementSerializer, final IKeyMatcher<K> keyMatcher) { final RemoteCacheAttributes rca = (RemoteCacheAttributes) iaca; - final ArrayList<RemoteCacheNoWait<K,V>> noWaits = new ArrayList<>(); switch (rca.getRemoteType()) @@ -82,7 +84,8 @@ public class RemoteCacheFactory if ( rca.getRemoteLocation() != null ) { failovers.add( rca.getRemoteLocation() ); - final RemoteCacheManager rcm = getManager( rca, cacheMgr, cacheEventLogger, elementSerializer ); + final RemoteCacheManager rcm = getManager( rca, cacheMgr, cacheEventLogger, + elementSerializer, keyMatcher); noWaits.add(rcm.getCache(rca)); } @@ -100,7 +103,8 @@ public class RemoteCacheFactory failovers.add( location ); final RemoteCacheAttributes frca = (RemoteCacheAttributes) rca.clone(); frca.setRemoteLocation(location); - final RemoteCacheManager rcm = getManager( frca, cacheMgr, cacheEventLogger, elementSerializer ); + final RemoteCacheManager rcm = getManager( frca, cacheMgr, + cacheEventLogger, elementSerializer, keyMatcher); // add a listener if there are none, need to tell rca what // number it is at @@ -134,7 +138,8 @@ public class RemoteCacheFactory { final RemoteCacheAttributes crca = (RemoteCacheAttributes) rca.clone(); crca.setRemoteLocation(location); - final RemoteCacheManager rcm = getManager( crca, cacheMgr, cacheEventLogger, elementSerializer ); + final RemoteCacheManager rcm = getManager( crca, cacheMgr, + cacheEventLogger, elementSerializer, keyMatcher); crca.setRemoteType( RemoteType.CLUSTER ); noWaits.add(rcm.getCache(crca)); } @@ -142,7 +147,11 @@ public class RemoteCacheFactory break; } - return new RemoteCacheNoWaitFacade<>(noWaits, rca, cacheEventLogger, elementSerializer, this); + RemoteCacheNoWaitFacade<K, V> rcnwf = new RemoteCacheNoWaitFacade<>(noWaits, rca, + cacheEventLogger, elementSerializer, this); + rcnwf.setKeyMatcher(keyMatcher); + + return rcnwf; } // end createCache @@ -201,14 +210,14 @@ public class RemoteCacheFactory * * @param cattr the cache configuration object * @param cacheMgr the cache manager - * @param cacheEventLogger the event logger - * @param elementSerializer the serializer to use for sending and receiving + * @param cacheEventLogger the cache event logger + * @param elementSerializer the serializer for cache elements + * @param keyMatcher the key matcher for getMatching() calls * @return The instance value, never null */ - public RemoteCacheManager getManager( final IRemoteCacheAttributes cattr, - final ICompositeCacheManager cacheMgr, - final ICacheEventLogger cacheEventLogger, - final IElementSerializer elementSerializer ) + public RemoteCacheManager getManager(final IRemoteCacheAttributes cattr, + final ICompositeCacheManager cacheMgr, final ICacheEventLogger cacheEventLogger, + final IElementSerializer elementSerializer, final IKeyMatcher<?> keyMatcher) { final RemoteCacheAttributes rca = (RemoteCacheAttributes) cattr.clone(); if (rca.getRemoteLocation() == null) @@ -216,9 +225,10 @@ public class RemoteCacheFactory rca.setRemoteLocation("", Registry.REGISTRY_PORT); } - return managers.computeIfAbsent(rca.getRemoteLocation(), key -> { - - final RemoteCacheManager manager = new RemoteCacheManager(rca, cacheMgr, monitor, cacheEventLogger, elementSerializer); + return managers.computeIfAbsent(rca.getRemoteLocation(), key -> + { + final RemoteCacheManager manager = new RemoteCacheManager(rca, cacheMgr, monitor, + cacheEventLogger, elementSerializer, keyMatcher); monitor.addManager(manager); return manager; diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheManager.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheManager.java index d2c09cde..5205ffb9 100644 --- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheManager.java +++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheManager.java @@ -36,6 +36,7 @@ import org.apache.commons.jcs4.engine.behavior.ICacheServiceNonLocal; import org.apache.commons.jcs4.engine.behavior.ICompositeCacheManager; import org.apache.commons.jcs4.engine.behavior.IElementSerializer; import org.apache.commons.jcs4.engine.logging.behavior.ICacheEventLogger; +import org.apache.commons.jcs4.engine.match.behavior.IKeyMatcher; import org.apache.commons.jcs4.log.Log; /** @@ -61,6 +62,9 @@ public class RemoteCacheManager /** The serializer. */ private final IElementSerializer elementSerializer; + /** The key matcher. */ + private final IKeyMatcher<?> keyMatcher; + /** Handle to the remote cache service; or a zombie handle if failed to connect. */ private ICacheServiceNonLocal<?, ?> remoteService; @@ -90,17 +94,20 @@ public class RemoteCacheManager * @param cattr cache attributes * @param cacheMgr the cache hub * @param monitor the cache monitor thread for error notifications - * @param cacheEventLogger - * @param elementSerializer + * @param cacheEventLogger the cache event logger + * @param elementSerializer the serializer for cache elements + * @param keyMatcher the key matcher for getMatching() calls */ - protected RemoteCacheManager( final IRemoteCacheAttributes cattr, final ICompositeCacheManager cacheMgr, - final RemoteCacheMonitor monitor, - final ICacheEventLogger cacheEventLogger, final IElementSerializer elementSerializer) + protected RemoteCacheManager(final IRemoteCacheAttributes cattr, + final ICompositeCacheManager cacheMgr, final RemoteCacheMonitor monitor, + final ICacheEventLogger cacheEventLogger, final IElementSerializer elementSerializer, + final IKeyMatcher<?> keyMatcher) { this.cacheMgr = cacheMgr; this.monitor = monitor; this.cacheEventLogger = cacheEventLogger; this.elementSerializer = elementSerializer; + this.keyMatcher = keyMatcher; this.remoteWatch = new CacheWatchRepairable(); this.registry = RemoteUtils.getNamingURL(cattr.getRemoteLocation(), cattr.getRemoteServiceName()); @@ -245,6 +252,7 @@ public class RemoteCacheManager * @param cattr the cache configuration * @return the instance */ + @SuppressWarnings("unchecked") protected <K, V> RemoteCacheNoWait<K, V> newRemoteCacheNoWait(final IRemoteCacheAttributes cattr) { final RemoteCacheNoWait<K, V> remoteCacheNoWait; @@ -262,15 +270,16 @@ public class RemoteCacheManager listener, e ); } - @SuppressWarnings("unchecked") final IRemoteCacheClient<K, V> remoteCacheClient = new RemoteCache<>(cattr, (ICacheServiceNonLocal<K, V>) remoteService, listener, monitor); remoteCacheClient.setCacheEventLogger( cacheEventLogger ); remoteCacheClient.setElementSerializer( elementSerializer ); + remoteCacheClient.setKeyMatcher((IKeyMatcher<K>)keyMatcher); remoteCacheNoWait = new RemoteCacheNoWait<>( remoteCacheClient ); remoteCacheNoWait.setCacheEventLogger( cacheEventLogger ); remoteCacheNoWait.setElementSerializer( elementSerializer ); + remoteCacheNoWait.setKeyMatcher((IKeyMatcher<K>)keyMatcher); return remoteCacheNoWait; } diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/http/client/RemoteHttpCacheFactory.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/http/client/RemoteHttpCacheFactory.java index 777092aa..b82262ef 100644 --- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/http/client/RemoteHttpCacheFactory.java +++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/http/client/RemoteHttpCacheFactory.java @@ -20,7 +20,6 @@ package org.apache.commons.jcs4.auxiliary.remote.http.client; */ import org.apache.commons.jcs4.auxiliary.AbstractAuxiliaryCacheFactory; -import org.apache.commons.jcs4.auxiliary.AuxiliaryCache; import org.apache.commons.jcs4.auxiliary.AuxiliaryCacheAttributes; import org.apache.commons.jcs4.auxiliary.remote.RemoteCacheNoWait; import org.apache.commons.jcs4.auxiliary.remote.behavior.IRemoteCacheClient; @@ -29,6 +28,7 @@ import org.apache.commons.jcs4.auxiliary.remote.server.behavior.RemoteType; import org.apache.commons.jcs4.engine.behavior.ICompositeCacheManager; import org.apache.commons.jcs4.engine.behavior.IElementSerializer; import org.apache.commons.jcs4.engine.logging.behavior.ICacheEventLogger; +import org.apache.commons.jcs4.engine.match.behavior.IKeyMatcher; import org.apache.commons.jcs4.log.Log; import org.apache.commons.jcs4.utils.config.OptionConverter; @@ -54,15 +54,19 @@ public class RemoteHttpCacheFactory * The failover runner will get a cache from the manager. When the primary is restored it will * tell the manager for the failover to deregister the listener. * - * @param iaca - * @param cacheMgr - * @param cacheEventLogger - * @param elementSerializer - * @return AuxiliaryCache + * @param iaca the cache attributes for this cache + * @param cacheMgr This allows auxiliaries to reference the manager without assuming that it is + * a singleton. This will allow JCS to be a non-singleton. Also, it makes it easier + * to test. + * @param cacheEventLogger the cache event logger + * @param elementSerializer the serializer for cache elements + * @param keyMatcher the key matcher for getMatching() calls + * @return RemoteCacheNoWait */ @Override - public <K, V> AuxiliaryCache<K, V> createCache( final AuxiliaryCacheAttributes iaca, final ICompositeCacheManager cacheMgr, - final ICacheEventLogger cacheEventLogger, final IElementSerializer elementSerializer ) + public <K, V> RemoteCacheNoWait<K, V> createCache(final AuxiliaryCacheAttributes iaca, + final ICompositeCacheManager cacheMgr, final ICacheEventLogger cacheEventLogger, + final IElementSerializer elementSerializer, final IKeyMatcher<K> keyMatcher) { final RemoteHttpCacheAttributes rca = (RemoteHttpCacheAttributes) iaca; @@ -77,10 +81,12 @@ public class RemoteHttpCacheFactory new RemoteHttpCache<>( rca, remoteService, listener, monitor ); remoteCacheClient.setCacheEventLogger( cacheEventLogger ); remoteCacheClient.setElementSerializer( elementSerializer ); + remoteCacheClient.setKeyMatcher(keyMatcher); final RemoteCacheNoWait<K, V> remoteCacheNoWait = new RemoteCacheNoWait<>( remoteCacheClient ); remoteCacheNoWait.setCacheEventLogger( cacheEventLogger ); remoteCacheNoWait.setElementSerializer( elementSerializer ); + remoteCacheNoWait.setKeyMatcher(keyMatcher); return remoteCacheNoWait; } diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCacheConfigurator.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCacheConfigurator.java index 284f4065..4c92c933 100644 --- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCacheConfigurator.java +++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCacheConfigurator.java @@ -135,47 +135,55 @@ public class CompositeCacheConfigurator if (auxCache == null) { + final String prefix = AUXILIARY_PREFIX + auxName; // GET FACTORY - AuxiliaryCacheFactory auxFac = ccm.registryFacGet( auxName ); + AuxiliaryCacheFactory auxFac = ccm.getRegisteredAuxiliaryFactory( auxName ); if ( auxFac == null ) { // auxFactory was not previously initialized. - final String prefix = AUXILIARY_PREFIX + auxName; auxFac = OptionConverter.instantiateByKey( props, prefix, null ); if ( auxFac == null ) { - log.error( "Could not instantiate auxFactory named \"{0}\"", auxName ); + log.error( "Could not instantiate auxiliary factory named \"{0}\"", auxName ); return null; } - auxFac.setName( auxName ); - if (auxFac instanceof IRequireScheduler irs) { irs.setScheduledExecutorService(ccm.getScheduledExecutorService()); } + auxFac.setName( auxName ); auxFac.initialize(); - ccm.registryFacPut( auxFac ); + ccm.registerAuxiliaryFactory( auxFac ); } // GET ATTRIBUTES - AuxiliaryCacheAttributes auxAttr = ccm.registryAttrGet( auxName ); - final String attrName = AUXILIARY_PREFIX + auxName + ATTRIBUTE_PREFIX; - if ( auxAttr == null ) + final String attrName = prefix + ATTRIBUTE_PREFIX; + Class<? extends AuxiliaryCacheAttributes> attributeClass = OptionConverter.findClassByKey(props, attrName); + if (attributeClass == null) { - // auxFactory was not previously initialized. - auxAttr = OptionConverter.instantiateByKey( props, attrName, null ); - if ( auxAttr == null ) - { - log.error( "Could not instantiate auxAttr named \"{0}\"", attrName ); - return null; - } - auxAttr.setName( auxName ); - ccm.registryAttrPut( auxAttr ); + attributeClass = auxFac.getAttributeClass(); + log.debug("Using default auxiliary cache attributes class for \"{0}\": {1}", + auxName, attributeClass.getName()); + } + else + { + log.info( "Using custom auxiliary cache attributes class for \"{0}\": {1}", + auxName, attributeClass.getName()); } - auxAttr = auxAttr.clone(); + AuxiliaryCacheAttributes auxAttr; + try + { + auxAttr = attributeClass.getDeclaredConstructor().newInstance(); + } + catch (final Exception e) + { + // Should not happen + log.error("Could not instantiate default auxiliary attributes \"{0}\"", attributeClass.getName(), e); + return null; + } log.debug( "Parsing options for \"{0}\"", attrName ); @@ -184,21 +192,19 @@ public class CompositeCacheConfigurator log.debug( "End of parsing for \"{0}\"", attrName ); // GET CACHE FROM FACTORY WITH ATTRIBUTES + auxAttr.setName( auxName ); auxAttr.setCacheName( regName ); - final String auxPrefix = AUXILIARY_PREFIX + auxName; - // CONFIGURE THE EVENT LOGGER final ICacheEventLogger cacheEventLogger = - AuxiliaryCacheConfigurator.parseCacheEventLogger( props, auxPrefix ); + AuxiliaryCacheConfigurator.parseCacheEventLogger( props, prefix ); // CONFIGURE THE ELEMENT SERIALIZER final IElementSerializer elementSerializer = - AuxiliaryCacheConfigurator.parseElementSerializer( props, auxPrefix ); + AuxiliaryCacheConfigurator.parseElementSerializer( props, prefix ); // CONFIGURE THE KEYMATCHER - //IKeyMatcher keyMatcher = parseKeyMatcher( props, auxPrefix ); - // TODO add to factory interface + IKeyMatcher<K> keyMatcher = parseKeyMatcher( props, prefix ); // Consider putting the compositeCache back in the factory interface // since the manager may not know about it at this point. @@ -206,7 +212,8 @@ public class CompositeCacheConfigurator // before the auxiliary is created. try { - auxCache = auxFac.createCache( auxAttr, ccm, cacheEventLogger, elementSerializer ); + auxCache = auxFac.createCache(auxAttr, ccm, cacheEventLogger, + elementSerializer, keyMatcher); } catch (final Exception e) { @@ -261,6 +268,11 @@ public class CompositeCacheConfigurator log.debug("Using default composite cache attributes class for region \"{0}\": {1}", regName, attributeClass.getName()); } + else + { + log.info( "Using custom composite cache attributes class for region \"{0}\": {1}", + regName, attributeClass.getName()); + } log.debug("Parsing options for \"{0}\"", prefix); @@ -320,21 +332,19 @@ public class CompositeCacheConfigurator */ protected <K> IKeyMatcher<K> parseKeyMatcher( final Properties props, final String auxPrefix ) { - - // auxFactory was not previously initialized. final String keyMatcherClassName = auxPrefix + KEY_MATCHER_PREFIX; IKeyMatcher<K> keyMatcher = OptionConverter.instantiateByKey( props, keyMatcherClassName, null ); - if ( keyMatcher != null ) + if (keyMatcher == null) { - final String attributePrefix = auxPrefix + KEY_MATCHER_PREFIX + ATTRIBUTE_PREFIX; - PropertySetter.setProperties( keyMatcher, props, attributePrefix + "." ); - log.info( "Using custom key matcher [{0}] for auxiliary [{1}]", keyMatcher, auxPrefix ); + // use the default key matcher + keyMatcher = new KeyMatcherPatternImpl<>(); + log.debug( "Using standard key matcher [{0}] for auxiliary [{1}]", keyMatcher, auxPrefix ); } else { - // use the default standard serializer - keyMatcher = new KeyMatcherPatternImpl<>(); - log.info( "Using standard key matcher [{0}] for auxiliary [{1}]", keyMatcher, auxPrefix ); + final String attributePrefix = auxPrefix + KEY_MATCHER_PREFIX + ATTRIBUTE_PREFIX; + PropertySetter.setProperties( keyMatcher, props, attributePrefix + "." ); + log.info( "Using custom key matcher [{0}] for auxiliary [{1}]", keyMatcher, auxPrefix ); } return keyMatcher; } diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCacheManager.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCacheManager.java index d2295b80..c4283bd8 100644 --- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCacheManager.java +++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCacheManager.java @@ -40,7 +40,6 @@ import javax.management.ObjectName; import org.apache.commons.jcs4.access.exception.CacheException; import org.apache.commons.jcs4.admin.JCSAdminBean; import org.apache.commons.jcs4.auxiliary.AuxiliaryCache; -import org.apache.commons.jcs4.auxiliary.AuxiliaryCacheAttributes; import org.apache.commons.jcs4.auxiliary.AuxiliaryCacheFactory; import org.apache.commons.jcs4.engine.CompositeCacheAttributes; import org.apache.commons.jcs4.engine.ElementAttributes; @@ -184,14 +183,10 @@ public class CompositeCacheManager /** Default element attributes for this cache manager */ private IElementAttributes defaultElementAttr = new ElementAttributes(); - /** Used to keep track of configured auxiliaries */ + /** Used to keep track of configured auxiliary factories */ private final ConcurrentMap<String, AuxiliaryCacheFactory> auxiliaryFactoryRegistry = new ConcurrentHashMap<>( ); - /** Used to keep track of attributes for auxiliaries. */ - private final ConcurrentMap<String, AuxiliaryCacheAttributes> auxiliaryAttributeRegistry = - new ConcurrentHashMap<>( ); - /** Used to keep track of configured auxiliaries */ private final ConcurrentMap<String, AuxiliaryCache<?, ?>> auxiliaryCaches = new ConcurrentHashMap<>( ); @@ -738,37 +733,22 @@ public class CompositeCacheManager } /** - * @param name - * @return AuxiliaryCacheAttributes - */ - public AuxiliaryCacheAttributes registryAttrGet( final String name ) - { - return auxiliaryAttributeRegistry.get( name ); - } - - /** - * @param auxAttr - */ - public void registryAttrPut( final AuxiliaryCacheAttributes auxAttr ) - { - auxiliaryAttributeRegistry.put( auxAttr.getName(), auxAttr ); - } - - /** + * Get auxiliary factory from registry * @param name * @return AuxiliaryCacheFactory */ - public AuxiliaryCacheFactory registryFacGet( final String name ) + public AuxiliaryCacheFactory getRegisteredAuxiliaryFactory(final String name) { - return auxiliaryFactoryRegistry.get( name ); + return auxiliaryFactoryRegistry.get(name); } /** + * Register auxiliary factory for re-use * @param auxFac */ - public void registryFacPut( final AuxiliaryCacheFactory auxFac ) + public void registerAuxiliaryFactory(final AuxiliaryCacheFactory auxFac) { - auxiliaryFactoryRegistry.put( auxFac.getName(), auxFac ); + auxiliaryFactoryRegistry.put(auxFac.getName(), auxFac); } /** */ @@ -862,8 +842,6 @@ public class CompositeCacheManager // shut down factories auxiliaryFactoryRegistry.values().forEach(AuxiliaryCacheFactory::dispose); - - auxiliaryAttributeRegistry.clear(); auxiliaryFactoryRegistry.clear(); // shutdown all scheduled jobs diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/config/OptionConverter.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/config/OptionConverter.java index 768af297..403e4c9c 100644 --- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/config/OptionConverter.java +++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/config/OptionConverter.java @@ -45,76 +45,6 @@ public class OptionConverter /** System property delimter end length */ private static final int DELIM_STOP_LEN = 1; - /** - * Combines two arrays. - * @param l - * @param r - * @return String[] - */ - public static String[] concatanateArrays( final String[] l, final String[] r ) - { - final int len = l.length + r.length; - final String[] a = new String[len]; - - System.arraycopy( l, 0, a, 0, l.length ); - System.arraycopy( r, 0, a, l.length, r.length ); - - return a; - } - - /** - * Escapes special characters. - * - * @param s - * @return String - */ - public static String convertSpecialChars( final String s ) - { - char c; - final int len = s.length(); - final StringBuilder sb = new StringBuilder( len ); - - int i = 0; - while ( i < len ) - { - c = s.charAt( i++ ); - if ( c == '\\' ) - { - c = s.charAt( i++ ); - switch (c) { - case 'n': - c = '\n'; - break; - case 'r': - c = '\r'; - break; - case 't': - c = '\t'; - break; - case 'f': - c = '\f'; - break; - case '\b': - c = '\b'; - break; - case '\"': - c = '\"'; - break; - case '\'': - c = '\''; - break; - case '\\': - c = '\\'; - break; - default: - break; - } - } - sb.append( c ); - } - return sb.toString(); - } - /** * Find the value corresponding to {@code key} in {@code props}. Then perform variable * substitution on the found value. @@ -123,7 +53,6 @@ public class OptionConverter * @param props * @return substituted string */ - public static String findAndSubst( final String key, final Properties props ) { final String value = props.getProperty( key ); @@ -143,30 +72,6 @@ public class OptionConverter } } - /** - * Very similar to {@code System.getProperty} except that the {@link SecurityException} is - * hidden. - * @param key The key to search for. - * @param def The default value to return. - * @return the string value of the system property, or the default value if there is no property - * with that key. - * @since 1.1 - */ - - public static String getSystemProperty( final String key, final String def ) - { - try - { - return System.getProperty( key, def ); - } - catch ( final Throwable e ) - { - // MS-Java throws com.ms.security.SecurityExceptionEx - log.debug( "Was not allowed to read system property \"{0}\".", key ); - return def; - } - } - /** * Get the class object given a class name. * @@ -216,7 +121,7 @@ public class OptionConverter { try { - @SuppressWarnings("unchecked") // CCE catched + @SuppressWarnings("unchecked") // CCE caught final Class<T> classObj = (Class<T>) Class.forName( className ); return classObj.getDeclaredConstructor().newInstance(); @@ -291,7 +196,7 @@ public class OptionConverter * @return String * @throws IllegalArgumentException if {@code val} is malformed. */ - public static String substVars( final String val, final Properties props ) + private static String substVars( final String val, final Properties props ) throws IllegalArgumentException { final StringBuilder sbuf = new StringBuilder(); @@ -338,97 +243,26 @@ public class OptionConverter } /** - * If {@code value} is "true", then {@code true} is returned. If {@code value} is - * "false", then {@code true} is returned. Otherwise, {@code default} is returned. - * - * Case of value is unimportant. - * @param value - * @param defaultValue - * @return Object - */ - public static boolean toBoolean( final String value, final boolean defaultValue ) - { - if ( value == null ) - { - return defaultValue; - } - final String trimmedVal = value.trim(); - if ( "true".equalsIgnoreCase( trimmedVal ) ) - { - return true; - } - if ( "false".equalsIgnoreCase( trimmedVal ) ) - { - return false; - } - return defaultValue; - } - - /** - * @param value - * @param defaultValue - * @return long + * Very similar to {@code System.getProperty} except that the {@link SecurityException} is + * hidden. + * @param key The key to search for. + * @param def The default value to return. + * @return the string value of the system property, or the default value if there is no property + * with that key. + * @since 1.1 */ - public static long toFileSize( final String value, final long defaultValue ) + private static String getSystemProperty( final String key, final String def ) { - if ( value == null ) - { - return defaultValue; - } - - String s = value.trim().toUpperCase(); - long multiplier = 1; - int index; - - if ( ( index = s.indexOf( "KB" ) ) != -1 ) - { - multiplier = 1024; - s = s.substring( 0, index ); - } - else if ( ( index = s.indexOf( "MB" ) ) != -1 ) - { - multiplier = 1024 * 1024; - s = s.substring( 0, index ); - } - else if ( ( index = s.indexOf( "GB" ) ) != -1 ) - { - multiplier = 1024 * 1024 * 1024; - s = s.substring( 0, index ); - } try { - return Long.parseLong(s) * multiplier; - } - catch ( final NumberFormatException e ) - { - log.error( "[{0}] is not in proper int form.", s); - log.error( "[{0}] not in expected format", value, e ); + return System.getProperty( key, def ); } - return defaultValue; - } - - /** - * Converts to int. - * - * @param value - * @param defaultValue - * @return int - */ - public static int toInt( final String value, final int defaultValue ) - { - if ( value != null ) + catch ( final Throwable e ) { - final String s = value.trim(); - try - { - return Integer.parseInt(s); - } - catch ( final NumberFormatException e ) - { - log.error( "[{0}] is not in proper int form.", s, e ); - } + // MS-Java throws com.ms.security.SecurityExceptionEx + log.debug( "Was not allowed to read system property \"{0}\".", key ); + return def; } - return defaultValue; } /** No instances please. */ diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/config/PropertySetter.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/config/PropertySetter.java index f334a438..bbc7687c 100644 --- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/config/PropertySetter.java +++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/config/PropertySetter.java @@ -123,6 +123,7 @@ public class PropertySetter } else if( type.isEnum() ) { + @SuppressWarnings("unchecked") final Enum<?> valueOf = Enum.valueOf(type.asSubclass(Enum.class), v); return valueOf; } @@ -211,7 +212,7 @@ public class PropertySetter * @throws PropertySetterException */ - public void setProperty( final PropertyDescriptor prop, final String name, final String value ) + protected void setProperty( final PropertyDescriptor prop, final String name, final String value ) throws PropertySetterException { final Method setter = prop.getWriteMethod(); @@ -262,7 +263,7 @@ public class PropertySetter * @param value String value of the property */ - public void setProperty( String name, final String value ) + protected void setProperty( String name, final String value ) { if ( value == null ) { diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/MockAuxiliaryCacheFactory.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/MockAuxiliaryCacheFactory.java index 6ef98ef3..8c579853 100644 --- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/MockAuxiliaryCacheFactory.java +++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/MockAuxiliaryCacheFactory.java @@ -22,6 +22,7 @@ package org.apache.commons.jcs4.auxiliary; import org.apache.commons.jcs4.engine.behavior.ICompositeCacheManager; import org.apache.commons.jcs4.engine.behavior.IElementSerializer; import org.apache.commons.jcs4.engine.logging.behavior.ICacheEventLogger; +import org.apache.commons.jcs4.engine.match.behavior.IKeyMatcher; /** For testing */ public class MockAuxiliaryCacheFactory @@ -35,18 +36,21 @@ public class MockAuxiliaryCacheFactory * * @param attr * @param cacheMgr - * @param cacheEventLogger - * @param elementSerializer + * @param cacheEventLogger the cache event logger + * @param elementSerializer the serializer for cache elements + * @param keyMatcher the key matcher for getMatching() calls * @return AuxiliaryCache */ @Override public <K, V> AuxiliaryCache<K, V> - createCache( final AuxiliaryCacheAttributes attr, final ICompositeCacheManager cacheMgr, - final ICacheEventLogger cacheEventLogger, final IElementSerializer elementSerializer ) + createCache(final AuxiliaryCacheAttributes attr, + final ICompositeCacheManager cacheMgr, final ICacheEventLogger cacheEventLogger, + final IElementSerializer elementSerializer, final IKeyMatcher<K> keyMatcher) { final MockAuxiliaryCache<K, V> auxCache = new MockAuxiliaryCache<>(); auxCache.setCacheEventLogger( cacheEventLogger ); auxCache.setElementSerializer( elementSerializer ); + auxCache.setKeyMatcher(keyMatcher); return auxCache; } diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCacheUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCacheUnitTest.java index 7b84fad8..9ec622e2 100644 --- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCacheUnitTest.java +++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCacheUnitTest.java @@ -35,6 +35,7 @@ import org.apache.commons.jcs4.access.CacheAccess; import org.apache.commons.jcs4.auxiliary.disk.jdbc.dsfactory.DataSourceFactory; import org.apache.commons.jcs4.engine.behavior.ICacheElement; import org.apache.commons.jcs4.engine.control.MockCompositeCacheManager; +import org.apache.commons.jcs4.engine.control.MockKeyMatcher; import org.apache.commons.jcs4.utils.serialization.StandardSerializer; import org.apache.commons.jcs4.utils.threadpool.DaemonThreadFactory; import org.junit.jupiter.api.BeforeEach; @@ -143,7 +144,8 @@ public class JDBCDiskCacheUnitTest dcFactory.setScheduledExecutorService(Executors.newScheduledThreadPool(2, new DaemonThreadFactory("JCS-JDBCDiskCacheManager-", Thread.MIN_PRIORITY))); - final JDBCDiskCache<String, String> diskCache = dcFactory.createCache( cattr, compositeCacheManager, null, new StandardSerializer() ); + final JDBCDiskCache<String, String> diskCache = dcFactory.createCache( cattr, + compositeCacheManager, null, new StandardSerializer(), new MockKeyMatcher<>()); assertNotNull( diskCache, "Should have a cache instance" ); // DO WORK diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListenerUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListenerUnitTest.java index eb6cb0e4..d9748a6d 100644 --- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListenerUnitTest.java +++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListenerUnitTest.java @@ -28,7 +28,9 @@ import java.util.List; import org.apache.commons.jcs4.engine.ZombieCacheServiceNonLocal; import org.apache.commons.jcs4.engine.behavior.IElementSerializer; import org.apache.commons.jcs4.engine.control.CompositeCacheManager; +import org.apache.commons.jcs4.engine.control.MockKeyMatcher; import org.apache.commons.jcs4.engine.logging.MockCacheEventLogger; +import org.apache.commons.jcs4.engine.match.behavior.IKeyMatcher; import org.apache.commons.jcs4.utils.discovery.DiscoveredService; import org.apache.commons.jcs4.utils.serialization.StandardSerializer; import org.junit.jupiter.api.BeforeEach; @@ -52,6 +54,9 @@ class LateralTCPDiscoveryListenerUnitTest /** The serializer. */ protected IElementSerializer elementSerializer; + /** The key matcher. */ + protected IKeyMatcher<String> keyMatcher; + /** Create the listener for testing */ @BeforeEach void setUp() @@ -63,6 +68,7 @@ class LateralTCPDiscoveryListenerUnitTest cacheMgr = CompositeCacheManager.getInstance(); cacheEventLogger = new MockCacheEventLogger(); elementSerializer = new StandardSerializer(); + keyMatcher = new MockKeyMatcher<>(); listener = new LateralTCPDiscoveryListener( factory.getName(), cacheMgr, cacheEventLogger, elementSerializer ); @@ -109,7 +115,7 @@ class LateralTCPDiscoveryListenerUnitTest final LateralTCPCacheNoWait<String, String> noWait = factory.createCacheNoWait(lca, cacheEventLogger, elementSerializer); // this is the normal process, the discovery service expects it there cacheMgr.addAuxiliaryCache(factory.getName(), cacheName, noWait); - cacheMgr.registryFacPut(factory); + cacheMgr.registerAuxiliaryFactory(factory); final LateralTCPCacheNoWaitFacade<String, String> facade = setupFacade(cacheName); listener.addNoWaitFacade( cacheName, facade ); @@ -189,7 +195,8 @@ class LateralTCPDiscoveryListenerUnitTest lca.setTcpListenerPort(1120); lca.setCacheName(cacheName); lca.setUdpDiscoveryEnabled(false); - final LateralTCPCacheNoWaitFacade<String, String> noWait = factory.createCache(lca, cacheMgr, cacheEventLogger, elementSerializer); + final LateralTCPCacheNoWaitFacade<String, String> noWait = factory.createCache(lca, + cacheMgr, cacheEventLogger, elementSerializer, keyMatcher); // VERIFY assertFalse( noWait.containsNoWait( "" ), "No waits should be empty." ); @@ -219,7 +226,7 @@ class LateralTCPDiscoveryListenerUnitTest final LateralTCPCacheNoWait<String, String> noWait = factory.createCacheNoWait(lca, cacheEventLogger, elementSerializer); // this is the normal process, the discovery service expects it there cacheMgr.addAuxiliaryCache(factory.getName(), cacheName, noWait); - cacheMgr.registryFacPut(factory); + cacheMgr.registerAuxiliaryFactory(factory); final LateralTCPCacheNoWaitFacade<String, String> facade = setupFacade(cacheName); listener.addNoWaitFacade( cacheName, facade ); diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheNoWaitFacadeUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheNoWaitFacadeUnitTest.java index eff19a45..7ad474fe 100644 --- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheNoWaitFacadeUnitTest.java +++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheNoWaitFacadeUnitTest.java @@ -76,7 +76,7 @@ class RemoteCacheNoWaitFacadeUnitTest final TestRemoteCacheFactory factory = new TestRemoteCacheFactory(); factory.initialize(); - final AuxiliaryCache<String, String> cache = factory.createCache(cattr, null, null, null); + final AuxiliaryCache<String, String> cache = factory.createCache(cattr, null, null, null, null); final RemoteCacheNoWaitFacade<String, String> facade = (RemoteCacheNoWaitFacade<String, String>) cache; assertEquals( 2, cattr.getFailovers().size(), "Should have two failovers." ); diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/TestRemoteCache.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/TestRemoteCache.java index 6d6f7ae9..188354b6 100644 --- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/TestRemoteCache.java +++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/TestRemoteCache.java @@ -30,6 +30,7 @@ import org.apache.commons.jcs4.engine.CacheElement; import org.apache.commons.jcs4.engine.behavior.ICompositeCacheManager; import org.apache.commons.jcs4.engine.control.MockCompositeCacheManager; import org.apache.commons.jcs4.engine.control.MockElementSerializer; +import org.apache.commons.jcs4.engine.control.MockKeyMatcher; import org.apache.commons.jcs4.log.Log; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; @@ -88,7 +89,8 @@ public class TestRemoteCache final RemoteCacheFactory factory = new RemoteCacheFactory(); factory.initialize(); - final RemoteCacheManager mgr = factory.getManager( rca, cacheMgr, new MockCacheEventLogger(), new MockElementSerializer() ); + final RemoteCacheManager mgr = factory.getManager( rca, cacheMgr, + new MockCacheEventLogger(), new MockElementSerializer(), new MockKeyMatcher<>()); final AuxiliaryCache<String, String> cache = mgr.getCache( rca ); final int numMes = 100; diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/TestRemoteCacheFactory.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/TestRemoteCacheFactory.java index 99b18760..63528e9e 100644 --- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/TestRemoteCacheFactory.java +++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/TestRemoteCacheFactory.java @@ -9,6 +9,7 @@ import org.apache.commons.jcs4.auxiliary.remote.behavior.IRemoteCacheAttributes; import org.apache.commons.jcs4.engine.behavior.ICompositeCacheManager; import org.apache.commons.jcs4.engine.behavior.IElementSerializer; import org.apache.commons.jcs4.engine.logging.behavior.ICacheEventLogger; +import org.apache.commons.jcs4.engine.match.behavior.IKeyMatcher; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -36,10 +37,12 @@ public class TestRemoteCacheFactory extends RemoteCacheFactory // Mock public class TestRemoteCacheManager extends RemoteCacheManager { - protected TestRemoteCacheManager(final IRemoteCacheAttributes cattr, final ICompositeCacheManager cacheMgr, final RemoteCacheMonitor monitor, final ICacheEventLogger cacheEventLogger, - final IElementSerializer elementSerializer) + protected TestRemoteCacheManager(final IRemoteCacheAttributes cattr, + final ICompositeCacheManager cacheMgr, final RemoteCacheMonitor monitor, + final ICacheEventLogger cacheEventLogger, + final IElementSerializer elementSerializer, final IKeyMatcher<?> keyMatcher) { - super(cattr, cacheMgr, monitor, cacheEventLogger, elementSerializer); + super(cattr, cacheMgr, monitor, cacheEventLogger, elementSerializer, keyMatcher); } @Override @@ -98,15 +101,15 @@ public class TestRemoteCacheFactory extends RemoteCacheFactory * * @param cattr the cache configuration object * @param cacheMgr the cache manager - * @param cacheEventLogger the event logger - * @param elementSerializer the serializer to use for sending and receiving + * @param cacheEventLogger the cache event logger + * @param elementSerializer the serializer for cache elements + * @param keyMatcher the key matcher for getMatching() calls * @return The instance value, never null */ @Override public RemoteCacheManager getManager( final IRemoteCacheAttributes cattr, - final ICompositeCacheManager cacheMgr, - final ICacheEventLogger cacheEventLogger, - final IElementSerializer elementSerializer ) + final ICompositeCacheManager cacheMgr, final ICacheEventLogger cacheEventLogger, + final IElementSerializer elementSerializer, final IKeyMatcher<?> keyMatcher) { final RemoteCacheAttributes rca = (RemoteCacheAttributes) cattr.clone(); if (rca.getRemoteLocation() == null) @@ -114,7 +117,9 @@ public class TestRemoteCacheFactory extends RemoteCacheFactory rca.setRemoteLocation("", Registry.REGISTRY_PORT); } - return managers.computeIfAbsent(rca.getRemoteLocation(), key -> new TestRemoteCacheManager(rca, cacheMgr, null, cacheEventLogger, elementSerializer)); + return managers.computeIfAbsent(rca.getRemoteLocation(), key -> + new TestRemoteCacheManager(rca, cacheMgr, null, cacheEventLogger, + elementSerializer, keyMatcher)); } /** diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/http/client/RemoteHttpCacheFactoryUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/http/client/RemoteHttpCacheFactoryUnitTest.java index acce64c3..dd7da962 100644 --- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/http/client/RemoteHttpCacheFactoryUnitTest.java +++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/http/client/RemoteHttpCacheFactoryUnitTest.java @@ -29,6 +29,7 @@ import org.apache.commons.jcs4.engine.behavior.ICompositeCacheManager; import org.apache.commons.jcs4.engine.behavior.IElementSerializer; import org.apache.commons.jcs4.engine.control.MockCompositeCacheManager; import org.apache.commons.jcs4.engine.logging.behavior.ICacheEventLogger; +import org.apache.commons.jcs4.engine.match.behavior.IKeyMatcher; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -80,6 +81,7 @@ class RemoteHttpCacheFactoryUnitTest assertNotNull( cacheMgr, "Should have a manager." ); final ICacheEventLogger cacheEventLogger = null; final IElementSerializer elementSerializer = null; + final IKeyMatcher<String> keyMatcher = null; final RemoteHttpCacheAttributes cattr = new RemoteHttpCacheAttributes(); assertNotNull( cattr, "Should have attributes." ); @@ -87,7 +89,8 @@ class RemoteHttpCacheFactoryUnitTest assertNotNull( factory, "Should have a factory." ); // DO WORK - final AuxiliaryCache<String, String> result = factory.createCache(cattr, cacheMgr, cacheEventLogger, elementSerializer); + final AuxiliaryCache<String, String> result = factory.createCache(cattr, cacheMgr, + cacheEventLogger, elementSerializer, keyMatcher); // VERIFY assertNotNull( result, "Should have a cache." ); diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/server/BasicRemoteCacheClientServerUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/server/BasicRemoteCacheClientServerUnitTest.java index 0a1f638a..594a31b0 100644 --- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/server/BasicRemoteCacheClientServerUnitTest.java +++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/server/BasicRemoteCacheClientServerUnitTest.java @@ -39,6 +39,7 @@ import org.apache.commons.jcs4.engine.CacheStatus; import org.apache.commons.jcs4.engine.behavior.ICacheElement; import org.apache.commons.jcs4.engine.control.MockCompositeCacheManager; import org.apache.commons.jcs4.engine.control.MockElementSerializer; +import org.apache.commons.jcs4.engine.control.MockKeyMatcher; import org.apache.commons.jcs4.utils.net.HostNameUtil; import org.apache.commons.jcs4.utils.timing.SleepUtil; import org.junit.jupiter.api.AfterAll; @@ -139,7 +140,9 @@ class BasicRemoteCacheClientServerUnitTest attributes.setLocalPort(LOCAL_PORT); attributes.setCacheName("testSinglePut"); - final RemoteCacheManager remoteCacheManager = factory.getManager(attributes, compositeCacheManager, new MockCacheEventLogger(), new MockElementSerializer()); + final RemoteCacheManager remoteCacheManager = factory.getManager(attributes, + compositeCacheManager, new MockCacheEventLogger(), new MockElementSerializer(), + new MockKeyMatcher<>()); final AuxiliaryCache<String, String> cache = remoteCacheManager.getCache(attributes); // DO WORK @@ -174,7 +177,8 @@ class BasicRemoteCacheClientServerUnitTest attributes.setCacheName("testPutRemove"); final MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger(); - final RemoteCacheManager remoteCacheManager = factory.getManager(attributes, compositeCacheManager, cacheEventLogger, null); + final RemoteCacheManager remoteCacheManager = factory.getManager(attributes, + compositeCacheManager, cacheEventLogger, null, new MockKeyMatcher<>()); final AuxiliaryCache<String, String> cache = remoteCacheManager.getCache(attributes); // DO WORK @@ -216,7 +220,9 @@ class BasicRemoteCacheClientServerUnitTest attributes.setLocalPort(LOCAL_PORT); attributes.setCacheName("testPutAndListen"); - final RemoteCacheManager remoteCacheManager = factory.getManager(attributes, compositeCacheManager, new MockCacheEventLogger(), new MockElementSerializer()); + final RemoteCacheManager remoteCacheManager = factory.getManager(attributes, + compositeCacheManager, new MockCacheEventLogger(), new MockElementSerializer(), + new MockKeyMatcher<>()); final AuxiliaryCache<String, String> cache = remoteCacheManager.getCache(attributes); final MockRemoteCacheListener<String, String> listener = new MockRemoteCacheListener<>(); @@ -251,7 +257,9 @@ class BasicRemoteCacheClientServerUnitTest attributes.setLocalPort(LOCAL_PORT); attributes.setCacheName("testPutaMultipleAndListen"); - final RemoteCacheManager remoteCacheManager = factory.getManager(attributes, compositeCacheManager, new MockCacheEventLogger(), new MockElementSerializer()); + final RemoteCacheManager remoteCacheManager = factory.getManager(attributes, + compositeCacheManager, new MockCacheEventLogger(), new MockElementSerializer(), + new MockKeyMatcher<>()); final AuxiliaryCache<String, String> cache = remoteCacheManager.getCache(attributes); final MockRemoteCacheListener<String, String> listener = new MockRemoteCacheListener<>(); diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/CompositeCacheConfiguratorUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/CompositeCacheConfiguratorUnitTest.java index 8e459454..07db90d3 100644 --- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/CompositeCacheConfiguratorUnitTest.java +++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/CompositeCacheConfiguratorUnitTest.java @@ -36,10 +36,10 @@ import org.junit.jupiter.api.Test; class CompositeCacheConfiguratorUnitTest { /** - * Verify that we can parse the event logger correctly + * Verify that we can parse optional auxiliary configurations correctly */ @Test - void testParseAuxiliary_CacheEventLogger_Normal() + void testParseAuxiliary_OptionalConfigurations_Normal() { // SETUP final String regionName = "MyRegion"; @@ -48,12 +48,14 @@ class CompositeCacheConfiguratorUnitTest final String auxPrefix = CompositeCacheConfigurator.AUXILIARY_PREFIX + auxName; final String auxiliaryClassName = MockAuxiliaryCacheFactory.class.getName(); final String eventLoggerClassName = MockCacheEventLogger.class.getName(); + final String keyMatcherClassName = MockKeyMatcher.class.getName(); final String auxiliaryAttributeClassName = MockAuxiliaryCacheAttributes.class.getName(); final Properties props = new Properties(); props.put( auxPrefix, auxiliaryClassName ); props.put( auxPrefix + CompositeCacheConfigurator.ATTRIBUTE_PREFIX, auxiliaryAttributeClassName ); props.put( auxPrefix + AuxiliaryCacheConfigurator.CACHE_EVENT_LOGGER_PREFIX, eventLoggerClassName ); + props.put( auxPrefix + CompositeCacheConfigurator.KEY_MATCHER_PREFIX, keyMatcherClassName); // System.out.print( props ); @@ -66,7 +68,13 @@ class CompositeCacheConfiguratorUnitTest // VERIFY assertNotNull( result, "Should have an auxcache." ); + assertEquals(MockAuxiliaryCache.class, result.getClass(), "Should have MockAuxiliaryCache."); + assertNotNull( manager.getRegisteredAuxiliaryFactory(auxName), "Should have a factory." ); + assertEquals(MockAuxiliaryCacheFactory.class, manager.getRegisteredAuxiliaryFactory(auxName).getClass(), "Should have MockAuxiliaryCacheFactory."); assertNotNull( result.getCacheEventLogger(), "Should have an event logger." ); + assertEquals(MockCacheEventLogger.class, result.getCacheEventLogger().getClass(), "Should have a MockCacheEventLogger."); + assertNotNull( result.getKeyMatcher(), "Should have a key matcher." ); + assertEquals(MockKeyMatcher.class, result.getKeyMatcher().getClass(), "Should have a MockKeyMatcher."); } /** diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/MockKeyMatcher.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/MockKeyMatcher.java new file mode 100644 index 00000000..59f3ea3f --- /dev/null +++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/MockKeyMatcher.java @@ -0,0 +1,36 @@ +package org.apache.commons.jcs4.engine.control; + +import java.util.HashSet; +import java.util.Set; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.commons.jcs4.engine.match.behavior.IKeyMatcher; + +public class MockKeyMatcher<K> implements IKeyMatcher<K> +{ + private static final long serialVersionUID = -5289971712212104935L; + + @Override + public Set<K> getMatchingKeysFromArray(String pattern, Set<K> keyArray) + { + return new HashSet<>(); + } +} diff --git a/commons-jcs4-core/src/test/test-conf/TestBlockDiskCache.ccf b/commons-jcs4-core/src/test/test-conf/TestBlockDiskCache.ccf index 87b66051..65c53779 100644 --- a/commons-jcs4-core/src/test/test-conf/TestBlockDiskCache.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestBlockDiskCache.ccf @@ -39,12 +39,10 @@ jcs.region.blockRegion4=blockDiskCache2 # Block Disk Cache jcs.auxiliary.blockDiskCache=org.apache.commons.jcs4.auxiliary.disk.block.BlockDiskCacheFactory -jcs.auxiliary.blockDiskCache.attributes=org.apache.commons.jcs4.auxiliary.disk.block.BlockDiskCacheAttributes jcs.auxiliary.blockDiskCache.attributes.DiskPath=target/test-sandbox/block-disk-cache # Block Disk Cache jcs.auxiliary.blockDiskCache2=org.apache.commons.jcs4.auxiliary.disk.block.BlockDiskCacheFactory -jcs.auxiliary.blockDiskCache2.attributes=org.apache.commons.jcs4.auxiliary.disk.block.BlockDiskCacheAttributes jcs.auxiliary.blockDiskCache2.attributes.DiskPath=target/test-sandbox/block-disk-cache2 # ############################################################# diff --git a/commons-jcs4-core/src/test/test-conf/TestBlockDiskCacheCon.ccf b/commons-jcs4-core/src/test/test-conf/TestBlockDiskCacheCon.ccf index 1a9dab2e..8ac3eb5b 100644 --- a/commons-jcs4-core/src/test/test-conf/TestBlockDiskCacheCon.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestBlockDiskCacheCon.ccf @@ -36,7 +36,6 @@ jcs.region.blockRegion4=blockDiskCache # Block Disk Cache jcs.auxiliary.blockDiskCache=org.apache.commons.jcs4.auxiliary.disk.block.BlockDiskCacheFactory -jcs.auxiliary.blockDiskCache.attributes=org.apache.commons.jcs4.auxiliary.disk.block.BlockDiskCacheAttributes jcs.auxiliary.blockDiskCache.attributes.DiskPath=target/test-sandbox/block-disk-cache-conc jcs.auxiliary.blockDiskCache.attributes.MaxPurgatorySize=10000 jcs.auxiliary.blockDiskCache.attributes.MaxKeySize=10000 diff --git a/commons-jcs4-core/src/test/test-conf/TestBlockDiskCacheHuge.ccf b/commons-jcs4-core/src/test/test-conf/TestBlockDiskCacheHuge.ccf index 96903612..f2ce19e6 100644 --- a/commons-jcs4-core/src/test/test-conf/TestBlockDiskCacheHuge.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestBlockDiskCacheHuge.ccf @@ -31,7 +31,6 @@ jcs.region.blockRegion1.cacheattributes.MaxObjects=0 # Block Disk Cache jcs.auxiliary.blockDiskCache=org.apache.commons.jcs4.auxiliary.disk.block.BlockDiskCacheFactory -jcs.auxiliary.blockDiskCache.attributes=org.apache.commons.jcs4.auxiliary.disk.block.BlockDiskCacheAttributes jcs.auxiliary.blockDiskCache.attributes.DiskPath=target/test-sandbox/block-disk-cache-huge jcs.auxiliary.blockDiskCache.attributes.MaxPurgatorySize=300000 jcs.auxiliary.blockDiskCache.attributes.MaxKeySize=1000000 diff --git a/commons-jcs4-core/src/test/test-conf/TestBlockDiskCacheSteadyLoad.ccf b/commons-jcs4-core/src/test/test-conf/TestBlockDiskCacheSteadyLoad.ccf index d6111388..18e71c69 100644 --- a/commons-jcs4-core/src/test/test-conf/TestBlockDiskCacheSteadyLoad.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestBlockDiskCacheSteadyLoad.ccf @@ -23,7 +23,6 @@ jcs.default.cacheattributes.DiskUsagePattern=UPDATE # AVAILABLE AUXILIARY CACHES jcs.auxiliary.DC=org.apache.commons.jcs4.auxiliary.disk.block.BlockDiskCacheFactory -jcs.auxiliary.DC.attributes=org.apache.commons.jcs4.auxiliary.disk.block.BlockDiskCacheAttributes jcs.auxiliary.DC.attributes.DiskPath=target/test-sandbox/block-steady-load jcs.auxiliary.DC.attributes.maxKeySize=20000 jcs.auxiliary.DC.attributes.blockSizeBytes=5000 diff --git a/commons-jcs4-core/src/test/test-conf/TestDiskCache.ccf b/commons-jcs4-core/src/test/test-conf/TestDiskCache.ccf index f497a90f..1a360fa4 100644 --- a/commons-jcs4-core/src/test/test-conf/TestDiskCache.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestDiskCache.ccf @@ -39,12 +39,10 @@ jcs.region.indexedRegion4=indexedDiskCache2 # Indexed Disk Cache jcs.auxiliary.indexedDiskCache=org.apache.commons.jcs4.auxiliary.disk.indexed.IndexedDiskCacheFactory -jcs.auxiliary.indexedDiskCache.attributes=org.apache.commons.jcs4.auxiliary.disk.indexed.IndexedDiskCacheAttributes jcs.auxiliary.indexedDiskCache.attributes.DiskPath=target/test-sandbox/indexed-disk-cache # Indexed Disk Cache jcs.auxiliary.indexedDiskCache2=org.apache.commons.jcs4.auxiliary.disk.indexed.IndexedDiskCacheFactory -jcs.auxiliary.indexedDiskCache2.attributes=org.apache.commons.jcs4.auxiliary.disk.indexed.IndexedDiskCacheAttributes jcs.auxiliary.indexedDiskCache2.attributes.DiskPath=target/test-sandbox/indexed-disk-cache2 # ############################################################# diff --git a/commons-jcs4-core/src/test/test-conf/TestDiskCacheCon.ccf b/commons-jcs4-core/src/test/test-conf/TestDiskCacheCon.ccf index b49394c1..0d5e3d39 100644 --- a/commons-jcs4-core/src/test/test-conf/TestDiskCacheCon.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestDiskCacheCon.ccf @@ -36,7 +36,6 @@ jcs.region.indexedRegion4=indexedDiskCache # Indexed Disk Cache jcs.auxiliary.indexedDiskCache=org.apache.commons.jcs4.auxiliary.disk.indexed.IndexedDiskCacheFactory -jcs.auxiliary.indexedDiskCache.attributes=org.apache.commons.jcs4.auxiliary.disk.indexed.IndexedDiskCacheAttributes jcs.auxiliary.indexedDiskCache.attributes.DiskPath=target/test-sandbox/indexed-disk-cache-conc jcs.auxiliary.indexedDiskCache.attributes.MaxPurgatorySize=10000 jcs.auxiliary.indexedDiskCache.attributes.MaxKeySize=10000 diff --git a/commons-jcs4-core/src/test/test-conf/TestDiskCacheDefragPerformance.ccf b/commons-jcs4-core/src/test/test-conf/TestDiskCacheDefragPerformance.ccf index 9a465d51..d9a5bd5c 100644 --- a/commons-jcs4-core/src/test/test-conf/TestDiskCacheDefragPerformance.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestDiskCacheDefragPerformance.ccf @@ -22,7 +22,6 @@ cs.default.cacheattributes.DiskUsagePatterName=UPDATE # AVAILABLE AUXILIARY CACHES jcs.auxiliary.DC=org.apache.commons.jcs4.auxiliary.disk.indexed.IndexedDiskCacheFactory -jcs.auxiliary.DC.attributes=org.apache.commons.jcs4.auxiliary.disk.indexed.IndexedDiskCacheAttributes jcs.auxiliary.DC.attributes.DiskPath=target/test-sandbox/defrag jcs.auxiliary.DC.attributes.maxKeySize=10000 jcs.auxiliary.DC.attributes.MaxPurgatorySize=5000 diff --git a/commons-jcs4-core/src/test/test-conf/TestDiskCacheHuge.ccf b/commons-jcs4-core/src/test/test-conf/TestDiskCacheHuge.ccf index 3970407e..87574e16 100644 --- a/commons-jcs4-core/src/test/test-conf/TestDiskCacheHuge.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestDiskCacheHuge.ccf @@ -31,7 +31,6 @@ jcs.region.indexedRegion1.cacheattributes.MaxObjects=0 # Indexed Disk Cache jcs.auxiliary.indexedDiskCache=org.apache.commons.jcs4.auxiliary.disk.indexed.IndexedDiskCacheFactory -jcs.auxiliary.indexedDiskCache.attributes=org.apache.commons.jcs4.auxiliary.disk.indexed.IndexedDiskCacheAttributes jcs.auxiliary.indexedDiskCache.attributes.DiskPath=target/test-sandbox/indexed-disk-cache-conc jcs.auxiliary.indexedDiskCache.attributes.MaxPurgatorySize=300000 jcs.auxiliary.indexedDiskCache.attributes.MaxKeySize=500000 diff --git a/commons-jcs4-core/src/test/test-conf/TestDiskCacheNoMemory.ccf b/commons-jcs4-core/src/test/test-conf/TestDiskCacheNoMemory.ccf index d09109f4..c65b8acf 100644 --- a/commons-jcs4-core/src/test/test-conf/TestDiskCacheNoMemory.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestDiskCacheNoMemory.ccf @@ -40,12 +40,10 @@ jcs.region.indexedRegion4=indexedDiskCache2 # Indexed Disk Cache jcs.auxiliary.indexedDiskCache=org.apache.commons.jcs4.auxiliary.disk.indexed.IndexedDiskCacheFactory -jcs.auxiliary.indexedDiskCache.attributes=org.apache.commons.jcs4.auxiliary.disk.indexed.IndexedDiskCacheAttributes jcs.auxiliary.indexedDiskCache.attributes.DiskPath=target/test-sandbox/indexed-disk-cache-nomemory # Indexed Disk Cache jcs.auxiliary.indexedDiskCache2=org.apache.commons.jcs4.auxiliary.disk.indexed.IndexedDiskCacheFactory -jcs.auxiliary.indexedDiskCache2.attributes=org.apache.commons.jcs4.auxiliary.disk.indexed.IndexedDiskCacheAttributes jcs.auxiliary.indexedDiskCache2.attributes.DiskPath=target/test-sandbox/indexed-disk-cache2-nomemory # ############################################################# diff --git a/commons-jcs4-core/src/test/test-conf/TestDiskCacheSteadyLoad.ccf b/commons-jcs4-core/src/test/test-conf/TestDiskCacheSteadyLoad.ccf index 4c914d13..d839bbd9 100644 --- a/commons-jcs4-core/src/test/test-conf/TestDiskCacheSteadyLoad.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestDiskCacheSteadyLoad.ccf @@ -23,7 +23,6 @@ jcs.default.cacheattributes.DiskUsagePattern=UPDATE # AVAILABLE AUXILIARY CACHES jcs.auxiliary.DC=org.apache.commons.jcs4.auxiliary.disk.indexed.IndexedDiskCacheFactory -jcs.auxiliary.DC.attributes=org.apache.commons.jcs4.auxiliary.disk.indexed.IndexedDiskCacheAttributes jcs.auxiliary.DC.attributes.DiskPath=target/test-sandbox/steady-load jcs.auxiliary.DC.attributes.maxKeySize=1000 jcs.auxiliary.DC.attributes.MaxPurgatorySize=1000 diff --git a/commons-jcs4-core/src/test/test-conf/TestDiskCacheUsagePattern.ccf b/commons-jcs4-core/src/test/test-conf/TestDiskCacheUsagePattern.ccf index f9ae52cd..66440eb2 100644 --- a/commons-jcs4-core/src/test/test-conf/TestDiskCacheUsagePattern.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestDiskCacheUsagePattern.ccf @@ -31,7 +31,6 @@ jcs.region.Update.cacheattributes.DiskUsagePattern=UPDATE # #### AUXILIARY CACHES # Indexed Disk Cache jcs.auxiliary.indexedDiskCache=org.apache.commons.jcs4.auxiliary.disk.indexed.IndexedDiskCacheFactory -jcs.auxiliary.indexedDiskCache.attributes=org.apache.commons.jcs4.auxiliary.disk.indexed.IndexedDiskCacheAttributes jcs.auxiliary.indexedDiskCache.attributes.DiskPath=target/test-sandbox/indexed-disk-cache-conc jcs.auxiliary.indexedDiskCache.attributes.MaxPurgatorySize=10000 jcs.auxiliary.indexedDiskCache.attributes.MaxKeySize=10000 diff --git a/commons-jcs4-core/src/test/test-conf/TestElementSerializer.ccf b/commons-jcs4-core/src/test/test-conf/TestElementSerializer.ccf index a585d51e..7e656e84 100644 --- a/commons-jcs4-core/src/test/test-conf/TestElementSerializer.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestElementSerializer.ccf @@ -36,14 +36,12 @@ jcs.region.blockRegion3=blockDiskCache3 # Block Disk Cache jcs.auxiliary.blockDiskCache=org.apache.commons.jcs4.auxiliary.disk.block.BlockDiskCacheFactory -jcs.auxiliary.blockDiskCache.attributes=org.apache.commons.jcs4.auxiliary.disk.block.BlockDiskCacheAttributes jcs.auxiliary.blockDiskCache.attributes.DiskPath=target/test-sandbox/block-disk-cache jcs.auxiliary.blockDiskCache.serializer=org.apache.commons.jcs4.utils.serialization.CompressingSerializer # Block Disk Cache jcs.auxiliary.blockDiskCache2=org.apache.commons.jcs4.auxiliary.disk.block.BlockDiskCacheFactory -jcs.auxiliary.blockDiskCache2.attributes=org.apache.commons.jcs4.auxiliary.disk.block.BlockDiskCacheAttributes jcs.auxiliary.blockDiskCache2.attributes.DiskPath=target/test-sandbox/block-disk-cache2 jcs.auxiliary.blockDiskCache2.attributes.EventQueueType=POOLED jcs.auxiliary.blockDiskCache2.serializer=org.apache.commons.jcs4.utils.serialization.EncryptingSerializer @@ -52,7 +50,6 @@ jcs.auxiliary.blockDiskCache2.serializer.attributes.aesCipherTransformation=AES/ # Block Disk Cache jcs.auxiliary.blockDiskCache3=org.apache.commons.jcs4.auxiliary.disk.block.BlockDiskCacheFactory -jcs.auxiliary.blockDiskCache3.attributes=org.apache.commons.jcs4.auxiliary.disk.block.BlockDiskCacheAttributes jcs.auxiliary.blockDiskCache3.attributes.DiskPath=target/test-sandbox/block-disk-cache3 jcs.auxiliary.blockDiskCache3.attributes.EventQueueType=POOLED jcs.auxiliary.blockDiskCache3.serializer=org.apache.commons.jcs4.utils.serialization.JSONSerializer diff --git a/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCache.ccf b/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCache.ccf index ae8bae2d..39527dbf 100644 --- a/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCache.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCache.ccf @@ -36,7 +36,6 @@ jcs.region.noRemoveAll.cacheattributes.MaxObjects=0 # ################# AUXILIARY CACHES AVAILABLE ################ # HSQL disk cache jcs.auxiliary.HSQL=org.apache.commons.jcs4.auxiliary.disk.jdbc.hsql.HSQLDiskCacheFactory -jcs.auxiliary.HSQL.attributes=org.apache.commons.jcs4.auxiliary.disk.jdbc.JDBCDiskCacheAttributes jcs.auxiliary.HSQL.attributes.userName=sa jcs.auxiliary.HSQL.attributes.password= jcs.auxiliary.HSQL.attributes.url=jdbc:hsqldb:target/HSQLDiskCacheUnitTest1 @@ -50,7 +49,6 @@ jcs.auxiliary.HSQL.attributes.EventQueueType=SINGLE # HSQL disk cache, doesn't allow remove all jcs.auxiliary.HSQL_NORA=org.apache.commons.jcs4.auxiliary.disk.jdbc.hsql.HSQLDiskCacheFactory -jcs.auxiliary.HSQL_NORA.attributes=org.apache.commons.jcs4.auxiliary.disk.jdbc.JDBCDiskCacheAttributes jcs.auxiliary.HSQL_NORA.attributes.userName=sa jcs.auxiliary.HSQL_NORA.attributes.password= jcs.auxiliary.HSQL_NORA.attributes.url=jdbc:hsqldb:target/HSQLDiskCacheUnitTest2 diff --git a/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCacheConcurrent.ccf b/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCacheConcurrent.ccf index 197bdec7..08ec3078 100644 --- a/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCacheConcurrent.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCacheConcurrent.ccf @@ -36,7 +36,6 @@ jcs.region.noRemoveAll.cacheattributes.MaxObjects=0 # ################# AUXILIARY CACHES AVAILABLE ################ # HSQL disk cache jcs.auxiliary.HSQL=org.apache.commons.jcs4.auxiliary.disk.jdbc.hsql.HSQLDiskCacheFactory -jcs.auxiliary.HSQL.attributes=org.apache.commons.jcs4.auxiliary.disk.jdbc.JDBCDiskCacheAttributes jcs.auxiliary.HSQL.attributes.userName=sa jcs.auxiliary.HSQL.attributes.password= jcs.auxiliary.HSQL.attributes.url=jdbc:hsqldb:target/HSQLDiskCacheUnitTest1 @@ -51,7 +50,6 @@ jcs.auxiliary.HSQL.attributes.EventQueuePoolName=disk_cache_event_queue # HSQL disk cache, doesn't allow remove all jcs.auxiliary.HSQL_NORA=org.apache.commons.jcs4.auxiliary.disk.jdbc.hsql.HSQLDiskCacheFactory -jcs.auxiliary.HSQL_NORA.attributes=org.apache.commons.jcs4.auxiliary.disk.jdbc.JDBCDiskCacheAttributes jcs.auxiliary.HSQL_NORA.attributes.userName=sa jcs.auxiliary.HSQL_NORA.attributes.password= jcs.auxiliary.HSQL_NORA.attributes.url=jdbc:hsqldb:target/HSQLDiskCacheUnitTest2 diff --git a/commons-jcs4-core/src/test/test-conf/TestJCS-73.ccf b/commons-jcs4-core/src/test/test-conf/TestJCS-73.ccf index a66b8106..b466763c 100644 --- a/commons-jcs4-core/src/test/test-conf/TestJCS-73.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestJCS-73.ccf @@ -27,7 +27,6 @@ jcs.default.elementattributes.IsLateral=false jcs.default.elementattributes.IsEternal=true jcs.auxiliary.CACHE=org.apache.commons.jcs4.auxiliary.disk.indexed.IndexedDiskCacheFactory -jcs.auxiliary.CACHE.attributes=org.apache.commons.jcs4.auxiliary.disk.indexed.IndexedDiskCacheAttributes jcs.auxiliary.CACHE.attributes.DiskPath=target/test-sandbox/concurrent_cache jcs.auxiliary.CACHE.attributes.MaxPurgatorySize=-1 jcs.auxiliary.CACHE.attributes.MaxKeySize=-1 diff --git a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCache.ccf b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCache.ccf index 805a03ee..9136aedd 100644 --- a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCache.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCache.ccf @@ -29,7 +29,6 @@ jcs.default.elementattributes.MaxIdleTime=1800 # ################# AUXILIARY CACHES AVAILABLE ################ # JDBC disk cache jcs.auxiliary.JDBC=org.apache.commons.jcs4.auxiliary.disk.jdbc.JDBCDiskCacheFactory -jcs.auxiliary.JDBC.attributes=org.apache.commons.jcs4.auxiliary.disk.jdbc.JDBCDiskCacheAttributes jcs.auxiliary.JDBC.attributes.userName=sa jcs.auxiliary.JDBC.attributes.password= jcs.auxiliary.JDBC.attributes.url=jdbc:hsqldb:target/cache_hsql_db diff --git a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheRemoval.ccf b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheRemoval.ccf index 1c273a49..fd9d260e 100644 --- a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheRemoval.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheRemoval.ccf @@ -30,7 +30,6 @@ jcs.default.elementattributes.MaxIdleTime=1800 # ################# AUXILIARY CACHES AVAILABLE ################ # JDBC disk cache jcs.auxiliary.JDBC=org.apache.commons.jcs4.auxiliary.disk.jdbc.JDBCDiskCacheFactory -jcs.auxiliary.JDBC.attributes=org.apache.commons.jcs4.auxiliary.disk.jdbc.JDBCDiskCacheAttributes jcs.auxiliary.JDBC.attributes.userName=sa jcs.auxiliary.JDBC.attributes.password= jcs.auxiliary.JDBC.attributes.url=jdbc:hsqldb:target/JDBCDiskCacheRemovalUnitTest diff --git a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheSharedPool.ccf b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheSharedPool.ccf index c049aecd..471aaef1 100644 --- a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheSharedPool.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheSharedPool.ccf @@ -35,7 +35,6 @@ jcs.region.testCache1.cacheattributes.MaxObjects=100 # ################# AUXILIARY CACHES AVAILABLE ################ # JDBC disk cache jcs.auxiliary.JDBC_0=org.apache.commons.jcs4.auxiliary.disk.jdbc.JDBCDiskCacheFactory -jcs.auxiliary.JDBC_0.attributes=org.apache.commons.jcs4.auxiliary.disk.jdbc.JDBCDiskCacheAttributes jcs.auxiliary.JDBC_0.attributes.tableName=JCS_STORE_0 jcs.auxiliary.JDBC_0.attributes.testBeforeInsert=false jcs.auxiliary.JDBC_0.attributes.allowRemoveAll=true @@ -45,7 +44,6 @@ jcs.auxiliary.JDBC_0.attributes.EventQueueType=POOLED jcs.auxiliary.JDBC_0.attributes.EventQueuePoolName=disk_cache_event_queue jcs.auxiliary.JDBC_1=org.apache.commons.jcs4.auxiliary.disk.jdbc.JDBCDiskCacheFactory -jcs.auxiliary.JDBC_1.attributes=org.apache.commons.jcs4.auxiliary.disk.jdbc.JDBCDiskCacheAttributes jcs.auxiliary.JDBC_1.attributes.tableName=JCS_STORE_1 jcs.auxiliary.JDBC_1.attributes.testBeforeInsert=false jcs.auxiliary.JDBC_1.attributes.allowRemoveAll=true diff --git a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheShrink.ccf b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheShrink.ccf index eeb31fe4..33eeffda 100644 --- a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheShrink.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheShrink.ccf @@ -44,7 +44,6 @@ jcs.region.eternal.elementattributes.IsEternal=true # ################# AUXILIARY CACHES AVAILABLE ################ # JDBC disk cache jcs.auxiliary.JDBC=org.apache.commons.jcs4.auxiliary.disk.jdbc.JDBCDiskCacheFactory -jcs.auxiliary.JDBC.attributes=org.apache.commons.jcs4.auxiliary.disk.jdbc.JDBCDiskCacheAttributes jcs.auxiliary.JDBC.attributes.userName=sa jcs.auxiliary.JDBC.attributes.password= jcs.auxiliary.JDBC.attributes.url=jdbc:hsqldb:target/JDBCDiskCacheShrinkUnitTest diff --git a/commons-jcs4-core/src/test/test-conf/TestMySQLDiskCache.ccf b/commons-jcs4-core/src/test/test-conf/TestMySQLDiskCache.ccf index 7658b984..7a62b00c 100644 --- a/commons-jcs4-core/src/test/test-conf/TestMySQLDiskCache.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestMySQLDiskCache.ccf @@ -32,7 +32,6 @@ jcs.default.elementattributes.MaxIdleTime=1800 # ################# AUXILIARY CACHES AVAILABLE ################ # MYSQL disk cache jcs.auxiliary.MYSQL=org.apache.commons.jcs4.auxiliary.disk.jdbc.mysql.MySQLDiskCacheFactory -jcs.auxiliary.MYSQL.attributes=org.apache.commons.jcs4.auxiliary.disk.jdbc.mysql.MySQLDiskCacheAttributes jcs.auxiliary.MYSQL.attributes.userName=sa jcs.auxiliary.MYSQL.attributes.password= jcs.auxiliary.MYSQL.attributes.url=jdbc:hsqldb:target/MySQLDiskCacheHsqlBackedUnitTest diff --git a/commons-jcs4-core/src/test/test-conf/TestRemoteClient.ccf b/commons-jcs4-core/src/test/test-conf/TestRemoteClient.ccf index aaf38fb3..737a86a7 100644 --- a/commons-jcs4-core/src/test/test-conf/TestRemoteClient.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestRemoteClient.ccf @@ -28,7 +28,6 @@ jcs.default.elementattributes.MaxIdleTime=1800 jcs.auxiliary.RC=org.apache.commons.jcs4.auxiliary.remote.RemoteCacheFactory -jcs.auxiliary.RC.attributes=org.apache.commons.jcs4.auxiliary.remote.RemoteCacheAttributes jcs.auxiliary.RC.attributes.FailoverServers=localhost:1101 jcs.auxiliary.RC.attributes.LocalPort=1201 jcs.auxiliary.RC.attributes.RemoveUponRemotePut=false diff --git a/commons-jcs4-core/src/test/test-conf/TestRemoteHttpCache.ccf b/commons-jcs4-core/src/test/test-conf/TestRemoteHttpCache.ccf index dffc2773..e43561da 100644 --- a/commons-jcs4-core/src/test/test-conf/TestRemoteHttpCache.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestRemoteHttpCache.ccf @@ -29,5 +29,4 @@ jcs.default.elementattributes.MaxIdleTime=1800 ## The Http Remote Cache Client jcs.auxiliary.RC=org.apache.commons.jcs4.auxiliary.remote.http.client.RemoteHttpCacheFactory -jcs.auxiliary.RC.attributes=org.apache.commons.jcs4.auxiliary.remote.http.client.RemoteHttpCacheAttributes jcs.auxiliary.RC.attributes.url=http://localhost:8000/jcs-app/RemoteCache diff --git a/commons-jcs4-core/src/test/test-conf/TestSimpleEventHandling.ccf b/commons-jcs4-core/src/test/test-conf/TestSimpleEventHandling.ccf index ccb17c60..61dca71b 100644 --- a/commons-jcs4-core/src/test/test-conf/TestSimpleEventHandling.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestSimpleEventHandling.ccf @@ -47,6 +47,5 @@ jcs.region.Idletime.elementattributes.MaxIdleTime=1 # #### AUXILIARY CACHES # Indexed Disk Cache jcs.auxiliary.indexedDiskCache=org.apache.commons.jcs4.auxiliary.disk.indexed.IndexedDiskCacheFactory -jcs.auxiliary.indexedDiskCache.attributes=org.apache.commons.jcs4.auxiliary.disk.indexed.IndexedDiskCacheAttributes jcs.auxiliary.indexedDiskCache.attributes.DiskPath=target/test-sandbox/indexed-disk-cache diff --git a/commons-jcs4-core/src/test/test-conf/TestSystemProperties.ccf b/commons-jcs4-core/src/test/test-conf/TestSystemProperties.ccf index f5fc6d31..c02b1345 100644 --- a/commons-jcs4-core/src/test/test-conf/TestSystemProperties.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestSystemProperties.ccf @@ -29,7 +29,6 @@ jcs.region.missing.cacheattributes.MaxObjects=${NO_SUCH_PROPERTY} # Indexed Disk Cache jcs.auxiliary.indexedDiskCache=org.apache.commons.jcs4.auxiliary.disk.indexed.IndexedDiskCacheFactory -jcs.auxiliary.indexedDiskCache.attributes=org.apache.commons.jcs4.auxiliary.disk.indexed.IndexedDiskCacheAttributes jcs.auxiliary.indexedDiskCache.attributes.DiskPath=target/test-sandbox/${MY_SYSTEM_PROPERTY_DISK_DIR} diff --git a/commons-jcs4-core/src/test/test-conf/TestTCPLateralCache.ccf b/commons-jcs4-core/src/test/test-conf/TestTCPLateralCache.ccf index eb3b8783..130c8a66 100644 --- a/commons-jcs4-core/src/test/test-conf/TestTCPLateralCache.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestTCPLateralCache.ccf @@ -31,7 +31,6 @@ jcs.region.testTcpRegion1.cacheattributes.MaxObjects=10000 # simple Lateral TCP auxiliary jcs.auxiliary.LTCP=org.apache.commons.jcs4.auxiliary.lateral.socket.tcp.LateralTCPCacheFactory -jcs.auxiliary.LTCP.attributes=org.apache.commons.jcs4.auxiliary.lateral.socket.tcp.LateralTCPCacheAttributes jcs.auxiliary.LTCP.attributes.TcpServers=localhost:1111 jcs.auxiliary.LTCP.attributes.TcpListenerPort=1110 jcs.auxiliary.LTCP.attributes.TcpListenerHost=localhost diff --git a/commons-jcs4-core/src/test/test-conf/TestTCPLateralCacheConcurrent.ccf b/commons-jcs4-core/src/test/test-conf/TestTCPLateralCacheConcurrent.ccf index 2d41616e..0e0fe20b 100644 --- a/commons-jcs4-core/src/test/test-conf/TestTCPLateralCacheConcurrent.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestTCPLateralCacheConcurrent.ccf @@ -20,7 +20,6 @@ jcs.default.cacheattributes.MaxObjects=10000 # #### AUXILIARY CACHES # simple Lateral TCP auxiliary jcs.auxiliary.LTCP=org.apache.commons.jcs4.auxiliary.lateral.socket.tcp.LateralTCPCacheFactory -jcs.auxiliary.LTCP.attributes=org.apache.commons.jcs4.auxiliary.lateral.socket.tcp.LateralTCPCacheAttributes jcs.auxiliary.LTCP.attributes.TransmissionTypeName=TCP # jcs.auxiliary.LTCP.attributes.TcpServers= jcs.auxiliary.LTCP.attributes.TcpListenerPort=1102 diff --git a/commons-jcs4-core/src/test/test-conf/TestTCPLateralIssueRemoveCache.ccf b/commons-jcs4-core/src/test/test-conf/TestTCPLateralIssueRemoveCache.ccf index b941d403..73fdd1a0 100644 --- a/commons-jcs4-core/src/test/test-conf/TestTCPLateralIssueRemoveCache.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestTCPLateralIssueRemoveCache.ccf @@ -31,7 +31,6 @@ jcs.region.testTcpRegion1.cacheattributes.MaxObjects=10000 # simple Lateral TCP auxiliary jcs.auxiliary.LTCP=org.apache.commons.jcs4.auxiliary.lateral.socket.tcp.LateralTCPCacheFactory -jcs.auxiliary.LTCP.attributes=org.apache.commons.jcs4.auxiliary.lateral.socket.tcp.LateralTCPCacheAttributes jcs.auxiliary.LTCP.attributes.TcpServers=localhost:1117 jcs.auxiliary.LTCP.attributes.TcpListenerPort=1118 jcs.auxiliary.LTCP.attributes.AllowGet=false diff --git a/commons-jcs4-core/src/test/test-conf/TestTCPLateralRemoveFilter.ccf b/commons-jcs4-core/src/test/test-conf/TestTCPLateralRemoveFilter.ccf index 99899767..026281dd 100644 --- a/commons-jcs4-core/src/test/test-conf/TestTCPLateralRemoveFilter.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestTCPLateralRemoveFilter.ccf @@ -31,7 +31,6 @@ jcs.region.testTcpRegion1.cacheattributes.MaxObjects=10000 # simple Lateral TCP auxiliary jcs.auxiliary.LTCP=org.apache.commons.jcs4.auxiliary.lateral.socket.tcp.LateralTCPCacheFactory -jcs.auxiliary.LTCP.attributes=org.apache.commons.jcs4.auxiliary.lateral.socket.tcp.LateralTCPCacheAttributes jcs.auxiliary.LTCP.attributes.TcpServers=localhost:1117 jcs.auxiliary.LTCP.attributes.TcpListenerPort=2001 jcs.auxiliary.LTCP.attributes.AllowGet=false
