Search in sources :

Example 16 with InMemoryPropertyStore

use of org.ff4j.property.store.InMemoryPropertyStore in project ff4j by ff4j.

the class AbstractStepDef method clearFeatureStore.

protected void clearFeatureStore() {
    ff4j.setPropertiesStore(new InMemoryPropertyStore());
    ff4j.setFeatureStore(new InMemoryFeatureStore());
}
Also used : InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) InMemoryFeatureStore(org.ff4j.store.InMemoryFeatureStore)

Example 17 with InMemoryPropertyStore

use of org.ff4j.property.store.InMemoryPropertyStore in project ff4j by ff4j.

the class FF4jBeanDefinitionParser method postProcess.

/**
 * {@inheritDoc} *
 */
protected void postProcess(final BeanDefinitionBuilder definitionBuilder, final Element ff4jTag) {
    super.postProcess(definitionBuilder, ff4jTag);
    logger.debug("Initialization from <ff4j:ff4j> TAG");
    // If filename is present ff4j will be initialized with both features and properties inmemory.
    if (StringUtils.hasLength(ff4jTag.getAttribute(ATT_FF4J_FILENAME))) {
        String fileName = ff4jTag.getAttribute(ATT_FF4J_FILENAME);
        InMemoryFeatureStore imfs = new InMemoryFeatureStore(fileName);
        InMemoryPropertyStore imps = new InMemoryPropertyStore(fileName);
        definitionBuilder.getBeanDefinition().getPropertyValues().addPropertyValue("featureStore", imfs);
        definitionBuilder.getBeanDefinition().getPropertyValues().addPropertyValue("propertiesStore", imps);
        logger.debug("... Setting in-memory stores : " + imfs.readAll().size() + " feature(s), " + imps.readAllProperties().size() + " propertie(s)");
    }
    if (StringUtils.hasLength(ff4jTag.getAttribute(ATT_FF4J_AUTOCREATE))) {
        String autocreate = ff4jTag.getAttribute(ATT_FF4J_AUTOCREATE);
        logger.debug("... Setting autocreate property to '" + autocreate + "'");
    }
    if (StringUtils.hasLength(ff4jTag.getAttribute(ATT_FF4J_AUTH_MANAGER))) {
        String authManagerBeanId = ff4jTag.getAttribute(ATT_FF4J_AUTH_MANAGER);
        RuntimeBeanReference refSolution = new RuntimeBeanReference(authManagerBeanId);
        definitionBuilder.getBeanDefinition().getPropertyValues().addPropertyValue("authorizationsManager", refSolution);
        logger.debug("... Setting authorizationManager with " + authManagerBeanId);
    }
    logger.debug("... Initialization done");
}
Also used : InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) InMemoryFeatureStore(org.ff4j.store.InMemoryFeatureStore) RuntimeBeanReference(org.springframework.beans.factory.config.RuntimeBeanReference)

Example 18 with InMemoryPropertyStore

use of org.ff4j.property.store.InMemoryPropertyStore in project ff4j by ff4j.

the class PropertyStoreAuditProxyTest method initPropertyStore.

/**
 * {@inheritDoc}
 */
@Override
protected PropertyStore initPropertyStore() {
    FF4j ff4j = new FF4j();
    PropertyStore ps = new InMemoryPropertyStore("ff4j.xml");
    ff4j.setPropertiesStore(ps);
    return new PropertyStoreAuditProxy(ff4j, ps);
}
Also used : PropertyStoreAuditProxy(org.ff4j.audit.proxy.PropertyStoreAuditProxy) InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) FF4j(org.ff4j.FF4j) InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) PropertyStore(org.ff4j.property.store.PropertyStore)

Example 19 with InMemoryPropertyStore

use of org.ff4j.property.store.InMemoryPropertyStore in project ff4j by ff4j.

the class CacheProxyTest method testCacheProxyManager.

@Test
public void testCacheProxyManager() {
    FF4jCacheProxy proxy = new FF4jCacheProxy();
    FF4JCacheManager cm = new InMemoryCacheManager();
    proxy.setCacheManager(cm);
    proxy.isCached();
    Assert.assertNotNull(proxy.getCacheProvider());
    proxy.setTargetPropertyStore(new InMemoryPropertyStore());
    Assert.assertEquals(0, proxy.readAllProperties().size());
    proxy.createProperty(new PropertyString("p1", "v1"));
    Assert.assertTrue(proxy.existProperty("p1"));
    Assert.assertFalse(proxy.existProperty("p2"));
    proxy.setTargetFeatureStore(new InMemoryFeatureStore());
    Set<Feature> setOfFeatures = new HashSet<Feature>();
    setOfFeatures.add(new Feature("f1"));
    setOfFeatures.add(new Feature("f2"));
    proxy.importFeatures(setOfFeatures);
}
Also used : FF4JCacheManager(org.ff4j.cache.FF4JCacheManager) PropertyString(org.ff4j.property.PropertyString) InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) InMemoryCacheManager(org.ff4j.cache.InMemoryCacheManager) InMemoryFeatureStore(org.ff4j.store.InMemoryFeatureStore) FF4jCacheProxy(org.ff4j.cache.FF4jCacheProxy) Feature(org.ff4j.core.Feature) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 20 with InMemoryPropertyStore

use of org.ff4j.property.store.InMemoryPropertyStore in project ff4j by ff4j.

the class CacheProxyWithPollingTest method testCacheProxyManagerProperty.

@Test
public void testCacheProxyManagerProperty() throws InterruptedException {
    // When
    FeatureStore fs = new InMemoryFeatureStore("ff4j.xml");
    PropertyStore ps = new InMemoryPropertyStore("ff4j.xml");
    FF4JCacheManager cm = new InMemoryCacheManager();
    FF4jCacheProxy proxy = new FF4jCacheProxy(fs, ps, cm);
    // Start polling on 100ms basis
    proxy.startPolling(100);
    proxy.createSchema();
    Thread.sleep(200);
    // When (Remove something)
    fs.delete("AwesomeFeature");
    // Then (Proxy is not yet refresh)
    Assert.assertTrue(proxy.exist("AwesomeFeature"));
    // When (wait for cache refresh)
    Thread.sleep(200);
    // Then (also delete in cache si Cache is refreshed)
    Assert.assertFalse(proxy.exist("AwesomeFeature"));
    Store2CachePollingScheduler scheduler = proxy.getStore2CachePoller();
    scheduler.setInitialDelay(scheduler.getInitialDelay());
    scheduler.setPollingDelay(scheduler.getPollingDelay());
    proxy.stopPolling();
    proxy.setStore2CachePoller(new Store2CachePollingScheduler(fs, ps, cm));
}
Also used : FF4JCacheManager(org.ff4j.cache.FF4JCacheManager) InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) InMemoryCacheManager(org.ff4j.cache.InMemoryCacheManager) InMemoryFeatureStore(org.ff4j.store.InMemoryFeatureStore) FF4jCacheProxy(org.ff4j.cache.FF4jCacheProxy) InMemoryFeatureStore(org.ff4j.store.InMemoryFeatureStore) FeatureStore(org.ff4j.core.FeatureStore) Store2CachePollingScheduler(org.ff4j.cache.Store2CachePollingScheduler) InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) PropertyStore(org.ff4j.property.store.PropertyStore) Test(org.junit.Test)

Aggregations

InMemoryPropertyStore (org.ff4j.property.store.InMemoryPropertyStore)41 Test (org.junit.Test)28 InMemoryFeatureStore (org.ff4j.store.InMemoryFeatureStore)10 PropertyString (org.ff4j.property.PropertyString)8 Property (org.ff4j.property.Property)6 PropertyStore (org.ff4j.property.store.PropertyStore)6 InputStream (java.io.InputStream)4 Before (org.junit.Before)4 FF4j (org.ff4j.FF4j)3 FF4jCacheProxy (org.ff4j.cache.FF4jCacheProxy)3 InMemoryCacheManager (org.ff4j.cache.InMemoryCacheManager)3 AbstractPollingScheduler (com.netflix.config.AbstractPollingScheduler)2 DynamicConfiguration (com.netflix.config.DynamicConfiguration)2 FixedDelayPollingScheduler (com.netflix.config.FixedDelayPollingScheduler)2 PolledConfigurationSource (com.netflix.config.PolledConfigurationSource)2 HashSet (java.util.HashSet)2 FF4JCacheManager (org.ff4j.cache.FF4JCacheManager)2 Feature (org.ff4j.core.Feature)2 BeforeClass (org.junit.BeforeClass)2 ClientResponse (com.sun.jersey.api.client.ClientResponse)1