/** * Normally called to initialize CoherenceCache. To be able to test the method without having * <code>com.tangosol.net.CacheFactory</code> implementation, it can also be called with a test * implementations classname. * * @param implementation Cache implementation classname to initialize. * @param params Parameters to initialize the cache (e.g. name, capacity). * @throws CacheAcquireException If cache can not be initialized. */ @SuppressWarnings("unchecked") public void initialize(final String implementation, final Properties params) throws CacheAcquireException { super.initialize(params); String cacheURL = params.getProperty("cacheURL", DEFAULT_CACHE_URL); String cacheProperties = params.getProperty("cacheProperties", DEFAULT_CACHE_PROPERTIES); StringBuffer clusterURL = new StringBuffer(); clusterURL.append(cacheURL); clusterURL.append(getName()); clusterURL.append("?"); clusterURL.append(cacheProperties); if (LOG.isDebugEnabled()) { LOG.debug(clusterURL.toString()); } try { ClassLoader ldr = this.getClass().getClassLoader(); Class<?> cls = ldr.loadClass(implementation); setCache( (Map) invokeStaticMethod( cls, "find", TYPES_FIND_CACHE, new Object[] {clusterURL.toString()})); } catch (Exception e) { LOG.error("Problem!", e); String msg = "Error creating Gigaspaces cache: " + e.getMessage(); LOG.error(msg, e); throw new CacheAcquireException(msg, e); } }
/** * Normally called to initialize JCache. To be able to test the method without having <code> * javax.util.jcs.CacheAccessFactory</code> implementation, it can also be called with a test * implementations classname. * * @param implementation Cache implementation classname to initialize. * @param params Parameters to initialize the cache (e.g. name, capacity). * @throws CacheAcquireException If cache can not be initialized. */ public void initialize(final String implementation, final Properties params) throws CacheAcquireException { super.initialize(params); try { ClassLoader ldr = this.getClass().getClassLoader(); Class cls = ldr.loadClass(implementation); Object factory = invokeStaticMethod(cls, "getInstance", null, null); setCache( (Map) invokeMethod( factory, "getMapAccess", TYPES_GET_MAP_ACCESS, new Object[] {getName()})); } catch (Exception e) { String msg = "Error creating JCache cache: " + e.getMessage(); LOG.error(msg, e); throw new CacheAcquireException(msg, e); } }