use of org.ff4j.property.store.PropertyStore in project ff4j by ff4j.
the class FF4jCliDisplay method displayEnvironments.
/**
* Display a table of available environments.
*
* @param envs
* environnements in config file
*/
public static void displayEnvironments(Map<String, FF4j> envs) {
yellow("+--------------------+----------+------------+-------+----------+\n");
System.out.print("|");
cyan(" Environments ");
yellow("|");
cyan(" Features ");
yellow("|");
cyan(" Properties ");
yellow("|");
cyan(" Audit ");
yellow("|");
cyan(" Security ");
yellow("|\n");
System.out.println("+--------------------+----------+------------+-------+----------+");
for (Map.Entry<String, FF4j> entries : envs.entrySet()) {
FeatureStore fs = entries.getValue().getFeatureStore();
PropertyStore ps = entries.getValue().getPropertiesStore();
yellow("| ");
green(StringUtils.rightPad(entries.getKey(), 18));
yellow("| ");
String featureStore = "---";
if (fs != null) {
featureStore = String.valueOf(fs.readAll().size());
}
white(StringUtils.rightPad(featureStore, 8));
yellow("| ");
String propertyStore = "---";
if (fs != null) {
propertyStore = String.valueOf(ps.listPropertyNames().size());
}
white(StringUtils.rightPad(propertyStore, 10));
yellow("|");
AnsiTerminal.textAttribute(AnsiTextAttribute.BOLD);
if (entries.getValue().isEnableAudit()) {
green(" ON ");
} else {
red(" OFF ");
}
AnsiTerminal.textAttribute(AnsiTextAttribute.CLEAR);
yellow("|");
AnsiTerminal.textAttribute(AnsiTextAttribute.BOLD);
if (entries.getValue().getAuthorizationsManager() != null) {
green(" ON ");
} else {
red(" OFF ");
}
AnsiTerminal.textAttribute(AnsiTextAttribute.CLEAR);
yellow("|\n");
}
System.out.println("+--------------------+----------+------------+-------+----------+");
System.out.println("");
}
use of org.ff4j.property.store.PropertyStore in project ff4j by ff4j.
the class PropertyStoreArchaiusPolledSourceTest method initArchauis.
@BeforeClass
public static void initArchauis() 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, 1000, true);
// Define configuration with polling and source
configuration = new DynamicConfiguration(ff4jSource, scheduler);
}
use of org.ff4j.property.store.PropertyStore in project ff4j by ff4j.
the class ConsoleOperations method importFile.
/**
* User action to import Features from a properties files.
*
* @param in
* inpustream from configuration file
* @throws IOException
* Error raised if the configuration cannot be read
*/
public static void importFile(FF4j ff4j, InputStream in) throws IOException {
FeatureStore store = ff4j.getFeatureStore();
XmlConfig xmlConfig = new XmlParser().parseConfigurationFile(in);
Map<String, Feature> mapsOfFeat = xmlConfig.getFeatures();
for (Entry<String, Feature> feature : mapsOfFeat.entrySet()) {
if (store.exist(feature.getKey())) {
store.update(feature.getValue());
} else {
store.create(feature.getValue());
}
}
LOGGER.info(mapsOfFeat.size() + " features have been imported.");
PropertyStore pstore = ff4j.getPropertiesStore();
Map<String, Property<?>> mapsOfProperties = xmlConfig.getProperties();
for (Entry<String, Property<?>> p : mapsOfProperties.entrySet()) {
if (pstore.existProperty(p.getKey())) {
pstore.updateProperty(p.getValue());
} else {
pstore.createProperty(p.getValue());
}
}
LOGGER.info(mapsOfProperties.size() + " features have been imported.");
}
Aggregations