public CacheApiBean(PropertyStore propertyStore) { if (propertyStore instanceof FF4jCacheProxy) { FF4jCacheProxy cacheProxy = (FF4jCacheProxy) propertyStore; // FIXME : This is wrong. Need to ask Cedrick to change the implementation for property cacheStore = cacheProxy.getCachedTargetStore(); cacheProvider = cacheProxy.getCacheProvider(); propertyNames = cacheProxy.getCacheManager().listCachedPropertyNames(); } }
/** * Start the polling of target store is required. */ public void startPolling(long delay) { if (store2CachePoller == null) { throw new IllegalStateException("The poller has not been initialize, please check"); } getStore2CachePoller().start(delay); }
/** {@inheritDoc} */ @Override public void delete(String featureId) { // Access target store getTargetFeatureStore().delete(featureId); // even is not present, evict won't failed getCacheManager().evictFeature(featureId); }
/** * Parameterized constructor. * * @param fcp * cache proxy */ public Store2CachePollingWorker(FF4jCacheProxy fcp) { this(fcp.getTargetFeatureStore(),fcp.getTargetPropertyStore(),null); this.ff4JCacheProxy = fcp; }
/** {@inheritDoc} */ @Override public boolean existProperty(String propertyName) { // not in cache but maybe created from last access if (getCacheManager().getProperty(propertyName) == null) { return getTargetPropertyStore().existProperty(propertyName); } return true; }
/** * POST Operation to clean cache. */ @POST @Path("/" + RESOURCE_CACHE) @Produces(MediaType.TEXT_PLAIN) @ApiOperation(value= "Clear Cache", response=Response.class) @ApiResponses({ @ApiResponse(code = 200, message= "cache is cleard"), @ApiResponse(code = 404, message= "no cache content provided") }) public Response clear() { FF4jCacheProxy cacheProxy = ff4j.getCacheProxy(); if (cacheProxy == null) { return Response.status(Response.Status.NOT_FOUND).entity("Current Store is not cached").build(); } cacheProxy.getCacheManager().clearProperties(); return Response.ok("Cache has been cleared").build(); }
/** {@inheritDoc} */ @Override public void clear() { // Cache Operations : As modification, flush cache for this getCacheManager().clearProperties(); getTargetPropertyStore().clear(); // Cache Operations : As modification, flush cache for this getCacheManager().clearFeatures(); getTargetFeatureStore().clear(); }
/** * Cache JSON expression for a store. * * @param store * current store * @return * cache expression */ public static final String cacheJson(Object store) { StringBuilder sb = new StringBuilder(); if (store instanceof FF4jCacheProxy) { FF4jCacheProxy cacheProxy = (FF4jCacheProxy) store; sb.append(",\"cached\":true"); sb.append(",\"cacheProvider\":\"" + cacheProxy.getCacheProvider() + "\""); sb.append(",\"cacheStore\":\"" + cacheProxy.getCachedTargetStore() + "\""); } else { sb.append(",\"cached\":false"); } return sb.toString(); }
/** {@inheritDoc} */ public String getCachedTargetStore() { return getTargetFeatureStore().getClass().getName(); }
/** {@inheritDoc} */ @Override public Map<String, Property<?>> readAllProperties() { return getTargetPropertyStore().readAllProperties(); }
/** * Enable a cache proxy. * * @param cm * current cache manager * @return * current ff4j bean */ public FF4j cache(FF4JCacheManager cm) { FF4jCacheProxy cp = new FF4jCacheProxy(getFeatureStore(), getPropertiesStore(), cm); setFeatureStore(cp); setPropertiesStore(cp); return this; }
/** {@inheritDoc} */ @Override public void deleteProperty(String name) { // Access target store getTargetPropertyStore().deleteProperty(name); // even is not present, evict name failed getCacheManager().evictProperty(name); }
/** * POST Operation to clean cache. */ @POST @Path("/" + RESOURCE_CACHE) @Produces(MediaType.TEXT_PLAIN) @ApiOperation(value= "Clear Cache", response=Response.class) @ApiResponses({ @ApiResponse(code = 200, message= "cache is cleard"), @ApiResponse(code = 404, message= "no cache content provided") }) public Response clear() { FF4jCacheProxy cacheProxy = ff4j.getCacheProxy(); if (cacheProxy == null) { return Response.status(Response.Status.NOT_FOUND).entity("Current Store is not cached").build(); } cacheProxy.getCacheManager().clearFeatures(); return Response.ok("Cache has been cleared").build(); }
/** {@inheritDoc} */ @Override public void createSchema() { // Create table for features but not only getTargetFeatureStore().createSchema(); // Also create tables for properties getTargetPropertyStore().createSchema(); }
/** {@inheritDoc} */ @Override public Map<String, Feature> readAll() { // Cannot be sure of whole cache - do not test any feature one-by-one : accessing FeatureStore return getTargetFeatureStore().readAll(); }
/** {@inheritDoc} */ @Override public Set<String> listPropertyNames() { return getTargetPropertyStore().listPropertyNames(); }
public CacheApiBean(FeatureStore featureStore) { if (featureStore instanceof FF4jCacheProxy) { FF4jCacheProxy cacheProxy = (FF4jCacheProxy) featureStore; cacheStore = cacheProxy.getCachedTargetStore(); cacheProvider = cacheProxy.getCacheProvider(); featureNames = cacheProxy.getCacheManager().listCachedFeatureNames(); } }
/** {@inheritDoc} */ @Override public void disable(String featureId) { // Reach target getTargetFeatureStore().disable(featureId); // Cache Operations : As modification, flush cache for this getCacheManager().evictFeature(featureId); }
/** {@inheritDoc} */ @Override public <T> void createProperty(Property<T> property) { getTargetPropertyStore().createProperty(property); getCacheManager().putProperty(property); }
public void clearCachedFeatureStore() { // Fixing #218 : If audit is enabled, cannot clear cache. FF4jCacheProxy cacheProxy = ff4j.getCacheProxy(); if (cacheProxy == null) { throw new FeatureStoreNotCached(); } cacheProxy.getCacheManager().clearFeatures(); } }