/** * Create caches used internally. System status gives them creation priority. *<p> * @param props Configuration properties * @param ccm Cache hub */ protected void parseSystemRegions( Properties props, CompositeCacheManager ccm ) { for (String key : props.stringPropertyNames() ) { if ( key.startsWith( SYSTEM_REGION_PREFIX ) && key.indexOf( "attributes" ) == -1 ) { String regionName = key.substring( SYSTEM_REGION_PREFIX.length() ); String auxiliaries = OptionConverter.findAndSubst( key, props ); ICache<?, ?> cache; synchronized ( regionName ) { cache = parseRegion( props, ccm, regionName, auxiliaries, null, SYSTEM_REGION_PREFIX ); } ccm.addCache( regionName, cache ); } } }
/** * Create caches used internally. System status gives them creation priority. *<p> * @param props */ protected <K, V> void parseSystemRegions( Properties props ) { Enumeration<?> en = props.propertyNames(); while ( en.hasMoreElements() ) { String key = (String) en.nextElement(); if ( key.startsWith( SYSTEM_REGION_PREFIX ) && key.indexOf( "attributes" ) == -1 ) { String regionName = key.substring( SYSTEM_REGION_PREFIX.length() ); String value = OptionConverter.findAndSubst( key, props ); ICache<K, V> cache; synchronized ( regionName ) { cache = parseRegion( props, regionName, value, null, SYSTEM_REGION_PREFIX ); } compositeCacheManager.addCache( regionName, cache ); } } }
/** * Parse region elements. *<p> * @param props */ protected <K, V> void parseRegions( Properties props ) { List<String> regionNames = new ArrayList<String>(); Enumeration<?> en = props.propertyNames(); while ( en.hasMoreElements() ) { String key = (String) en.nextElement(); if ( key.startsWith( REGION_PREFIX ) && key.indexOf( "attributes" ) == -1 ) { String regionName = key.substring( REGION_PREFIX.length() ); regionNames.add( regionName ); String auxiliaryList = OptionConverter.findAndSubst( key, props ); ICache<K, V> cache; synchronized ( regionName ) { cache = parseRegion( props, regionName, auxiliaryList ); } compositeCacheManager.addCache( regionName, cache ); } } if ( log.isInfoEnabled() ) { log.info( "Parsed regions " + regionNames ); } }
/** * Parse region elements. *<p> * @param props Configuration properties * @param ccm Cache hub */ protected void parseRegions( Properties props, CompositeCacheManager ccm ) { List<String> regionNames = new ArrayList<String>(); for (String key : props.stringPropertyNames() ) { if ( key.startsWith( REGION_PREFIX ) && key.indexOf( "attributes" ) == -1 ) { String regionName = key.substring( REGION_PREFIX.length() ); regionNames.add( regionName ); String auxiliaries = OptionConverter.findAndSubst( key, props ); ICache<?, ?> cache; synchronized ( regionName ) { cache = parseRegion( props, ccm, regionName, auxiliaries ); } ccm.addCache( regionName, cache ); } } if ( log.isInfoEnabled() ) { log.info( "Parsed regions " + regionNames ); } }
/** * Verify that calling release, when there are active clients, the caches are correctly disposed or not. */ public void testRelease() { // See JCS-184 // create the manager CompositeCacheManager manager = CompositeCacheManager.getInstance(); // add a simple cache CompositeCacheAttributes cacheAttributes = new CompositeCacheAttributes(); CompositeCache<String, String> cache = new CompositeCache<String, String>(cacheAttributes, /* attr */ null); manager.addCache("simple_cache", cache); // add a client to the cache CompositeCacheManager.getUnconfiguredInstance(); // won't release as there are still clients. Only disposed when release() is called by // the last client manager.release(); assertEquals("The cache was disposed during release!", CacheStatus.ALIVE, cache.getStatus()); manager.release(); assertEquals("The cache was NOT disposed during release!", CacheStatus.DISPOSED, cache.getStatus()); }