01: package ri.cache;
02:
03: import org.apache.commons.logging.Log;
04: import org.apache.commons.logging.LogFactory;
05:
06: import javax.cache.spi.Provider;
07: import javax.cache.CacheManager;
08: import javax.cache.CacheException;
09:
10: /**
11: * ReferenceProvider
12: *
13: * @author Brian Goetz
14: */
15: public class ReferenceProvider implements Provider {
16: public static final String name = "jcache";
17: public static final String scheme = "jcache:";
18: private Log log = LogFactory.getLog(ReferenceProvider.class);
19:
20: public String getName() {
21: return name;
22: }
23:
24: public boolean acceptsUri(String uri) {
25: return uri != null && uri.startsWith(scheme);
26: }
27:
28: public CacheManager getCacheManager(String uri) {
29: if (uri == null || !uri.startsWith(scheme))
30: throw new IllegalArgumentException(uri);
31:
32: String rest = uri.substring(scheme.length());
33: // @@@ more needed
34:
35: try {
36: return new ReferenceCacheManager(uri);
37: } catch (CacheException ce) {
38: // TODO: Deal with this case properly!!
39: log.error("Unable to create reference provider", ce);
40: return null;
41: }
42: }
43: }
|