1 package org.apache.slide.util; 2 3 import java.net.URL ; 4 5 import net.sf.ehcache.CacheException; 6 import net.sf.ehcache.CacheManager; 7 8 13 public class CacheManagerFactory { 14 15 private static CacheManager defaultCacheManager; 16 private static HashMap cacheManagers = new HashMap(); 17 18 private CacheManagerFactory() {} 19 20 26 public static CacheManager getDefaultCacheManager() throws CacheException { 27 if ( defaultCacheManager == null ) { 28 defaultCacheManager = CacheManager.create(); 29 } 30 return defaultCacheManager; 31 } 32 33 42 public static CacheManager getCacheManager( String configFilePath ) throws CacheException { 43 CacheManager cm = (CacheManager)cacheManagers.get( configFilePath ); 44 if ( cm == null ) { 45 cm = CacheManager.create( configFilePath ); 46 } 47 return cm; 48 } 49 50 59 public static CacheManager getCacheManager( URL configFileURL ) throws CacheException { 60 CacheManager cm = (CacheManager)cacheManagers.get( configFileURL ); 61 if ( cm == null ) { 62 cm = CacheManager.create( configFileURL ); 63 } 64 return cm; 65 } 66 67 } 68 | Popular Tags |