/** {@inheritDoc} */ @Override public Feature read(String featureUid) { Feature fp = getCacheManager().getFeature(featureUid); // not in cache but may has been created from now if (null == fp) { fp = getTargetFeatureStore().read(featureUid); getCacheManager().putFeature(fp); } return fp; }
/** {@inheritDoc} */ @Override public Property<?> readProperty(String name) { Property<?> fp = getCacheManager().getProperty(name); // not in cache but may has been created from now if (null == fp) { fp = getTargetPropertyStore().readProperty(name); getCacheManager().putProperty(fp); } return fp; }
/** {@inheritDoc} */ @Override public Property<?> readProperty(String name, Property<?> defaultValue) { Property<?> fp = getCacheManager().getProperty(name); // Not in cache but may has been created from now // Or in cache but with different value that default if (null == fp) { fp = getTargetPropertyStore().readProperty(name, defaultValue); getCacheManager().putProperty(fp); } return fp; }
/** {@inheritDoc} */ @Override public <T> void updateProperty(Property<T> propertyValue) { // Update the property getTargetPropertyStore().updateProperty(propertyValue); // Update the cache accordirly getCacheManager().evictProperty(propertyValue.getName()); // Update the property in cache getCacheManager().putProperty(propertyValue); }
/** {@inheritDoc} */ @Override public void delete(String featureId) { // Access target store getTargetFeatureStore().delete(featureId); // even is not present, evict won't failed getCacheManager().evictFeature(featureId); }
/** {@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; }
/** {@inheritDoc} */ @Override public void deleteProperty(String name) { // Access target store getTargetPropertyStore().deleteProperty(name); // even is not present, evict name failed getCacheManager().evictProperty(name); }
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(); } }
/** {@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 void create(Feature fp) { getTargetFeatureStore().create(fp); getCacheManager().putFeature(fp); }
/** {@inheritDoc} */ @Override public void removeFromGroup(String featureId, String groupName) { getTargetFeatureStore().removeFromGroup(featureId, groupName); getCacheManager().evictFeature(featureId); }
/** {@inheritDoc} */ public void importFeatures(Collection<Feature> features) { getCacheManager().clearFeatures(); getTargetFeatureStore().importFeatures(features); }
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 enable(String featureId) { // Reach target getTargetFeatureStore().enable(featureId); // Modification => flush cache getCacheManager().evictFeature(featureId); }
/** {@inheritDoc} */ @Override public void grantRoleOnFeature(String featureId, String roleName) { getTargetFeatureStore().grantRoleOnFeature(featureId, roleName); getCacheManager().evictFeature(featureId); }
/** {@inheritDoc} */ @Override public void removeRoleFromFeature(String featureId, String roleName) { getTargetFeatureStore().removeRoleFromFeature(featureId, roleName); getCacheManager().evictFeature(featureId); }
/** {@inheritDoc} */ @Override public void enableGroup(String groupName) { getTargetFeatureStore().enableGroup(groupName); // Cannot know wich feature to work with (exceptional event) : flush cache getCacheManager().clearFeatures(); }
/** {@inheritDoc} */ @Override public <T> void createProperty(Property<T> property) { getTargetPropertyStore().createProperty(property); getCacheManager().putProperty(property); }
/** {@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(); }
/** {@inheritDoc} */ @Override public void updateProperty(String name, String newValue) { // Retrieve the full object from its name Property<?> fp = getTargetPropertyStore().readProperty(name); fp.setValueFromString(newValue); // Update value in target store getTargetPropertyStore().updateProperty(fp); // Remove from cache old value getCacheManager().evictProperty(fp.getName()); // Add new value in the cache getCacheManager().putProperty(fp); }