1 19 package javax.util.jcache; 20 21 import org.fjank.jcache.AttributesImpl; 22 23 24 29 public abstract class CacheAccessFactory { 30 private static CacheAccessFactory _singleton; 31 32 35 protected CacheAccessFactory() { 36 } 37 43 public Attributes getDefaultAttributes() { 44 return new AttributesImpl(); 45 } 46 67 public static synchronized CacheAccessFactory getInstance() { 68 if(_singleton!=null) { 69 return _singleton; 70 } 71 String clazz = System.getProperty("javax.util.jcache.CacheAccessFactory"); 72 if (clazz == null) { 73 clazz = "org.fjank.jcache.CacheAccessFactoryImpl"; 74 } 75 try { 76 _singleton = (CacheAccessFactory) Class.forName(clazz).newInstance(); 77 return _singleton; 78 } catch (InstantiationException e) { 79 throw new IllegalStateException ("CacheAccessFactory '" + clazz 80 + "' could not be instantiated."); 81 } catch (IllegalAccessException e) { 82 throw new IllegalStateException ("CacheAccessFactory '" + clazz 83 + "' did not have a public empty args constructor."); 84 } catch (ClassNotFoundException e) { 85 throw new IllegalStateException ("CacheAccessFactory '" + clazz 86 + "' could not be located."); 87 } 88 } 89 90 104 public abstract void defineRegion(final String name) 105 throws ObjectExistsException, NullObjectNameException, 106 CacheNotAvailableException; 107 108 124 public abstract void defineRegion(final String name, 125 final Attributes attributes) 126 throws ObjectExistsException, NullObjectNameException, 127 CacheNotAvailableException; 128 129 137 public abstract Cache getCache() throws CacheException; 138 139 150 public abstract Cache getCache(final boolean b) throws CacheException; 151 152 public abstract CacheMap getMapAccess() throws CacheException; 153 154 public abstract CacheMap getMapAccess(final String region) throws CacheException; 155 } 156 | Popular Tags |