use of org.ff4j.property.store.PropertyStore in project ff4j by ff4j.
the class FF4jConfiguration method subset.
/**
* {@inheritDoc}
*/
@Override
public Configuration subset(String prefix) {
Map<String, Property<?>> myProps = ff4jStore().readAllProperties();
PropertyStore ps = new InMemoryPropertyStore();
for (Map.Entry<String, Property<?>> prop : myProps.entrySet()) {
if (prop.getKey().startsWith(prefix)) {
ps.createProperty(prop.getValue());
}
}
return new FF4jConfiguration(ps);
}
use of org.ff4j.property.store.PropertyStore in project ff4j by ff4j.
the class PropertyStoreArchaiusCommonsConfTest method testInitPropertyStore2.
/**
* {@inheritDoc}
*/
@Test
public void testInitPropertyStore2() {
PropertyStore sourceStore = new InMemoryPropertyStore("ff4j-properties.xml");
PropertyStore archaiusStore = new PropertyStoreArchaius(sourceStore);
Assert.assertTrue(archaiusStore.existProperty("a"));
}
use of org.ff4j.property.store.PropertyStore in project ff4j by ff4j.
the class PropertyStoreAsArchaiusInputTest method initArchauisWithFF4j.
@BeforeClass
public static void initArchauisWithFF4j() throws InterruptedException {
// Sample FF4J Store
PropertyStore ff4jStore = new InMemoryPropertyStore("ff4j-properties.xml");
// FF4Store as polling Source for Archiaus
PolledConfigurationSource ff4jSource = new FF4jPolledConfigurationSource(ff4jStore);
// Working Thread (polling from ff4j => Archaius)
AbstractPollingScheduler scheduler = new FixedDelayPollingScheduler(0, 100, true);
// Define configuration with polling and source
DynamicConfiguration configuration = new DynamicConfiguration(ff4jSource, scheduler);
// Init configuration
ConfigurationManager.install(configuration);
// Other initialization mechanism
FF4jPolledConfigurationSource conf2 = new FF4jPolledConfigurationSource();
conf2.setFf4jStore(ff4jStore);
// Must invoke poll
Thread.sleep(100);
}
use of org.ff4j.property.store.PropertyStore 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);
}
use of org.ff4j.property.store.PropertyStore 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));
}
Aggregations