use of org.ff4j.core.Feature in project ff4j by ff4j.
the class FeatureStoreStepDef method the_following_features_are_cached.
@Given("^the following features are cached$")
public void the_following_features_are_cached(List<FeaturePojo> features) throws Throwable {
for (FeaturePojo featurePojo : features) {
Feature feature = new Feature(featurePojo.getUid(), Boolean.valueOf(featurePojo.getEnable()), featurePojo.getDescription(), featurePojo.getGroup(), Arrays.asList(featurePojo.getPermissions().split(",")));
((FF4jCacheProxy) ff4j.getFeatureStore()).getCacheManager().putFeature(feature);
}
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class FeatureStoreServicesStepDef method the_following_features_are_cached.
@Given("^the following features are cached$")
public void the_following_features_are_cached(List<FeaturePojo> features) throws Throwable {
for (FeaturePojo featurePojo : features) {
Feature feature = new Feature(featurePojo.getUid(), Boolean.valueOf(featurePojo.getEnable()), featurePojo.getDescription(), featurePojo.getGroup(), Arrays.asList(featurePojo.getPermissions().split(",")));
((FF4jCacheProxy) ff4j.getFeatureStore()).getCacheManager().putFeature(feature);
}
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class AbstractStepDef method createFeatures.
protected void createFeatures(List<FeaturePojo> features) {
for (FeaturePojo featurePojo : features) {
Feature feature = new Feature(featurePojo.getUid(), Boolean.valueOf(featurePojo.getEnable()), featurePojo.getDescription(), featurePojo.getGroup(), Arrays.asList(featurePojo.getPermissions().split(",")));
createFeature(feature);
}
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class FF4jCliDisplay method displayFeatures.
/**
* Command line uptime
*/
public static void displayFeatures(Map<String, Feature> features) {
if (features == null || features.isEmpty()) {
System.out.println(" There are no features in the store");
}
AnsiTerminal.foreGroundColor(AnsiForegroundColor.YELLOW);
System.out.println("+--------------------+--------+---------------+--------------------------------+");
System.out.print("|");
AnsiTerminal.textAttribute(AnsiTextAttribute.BOLD);
AnsiTerminal.foreGroundColor(AnsiForegroundColor.CYAN);
System.out.print(" Feature names ");
AnsiTerminal.textAttribute(AnsiTextAttribute.CLEAR);
AnsiTerminal.foreGroundColor(AnsiForegroundColor.YELLOW);
System.out.print("|");
AnsiTerminal.textAttribute(AnsiTextAttribute.BOLD);
AnsiTerminal.foreGroundColor(AnsiForegroundColor.CYAN);
System.out.print(" State ");
AnsiTerminal.textAttribute(AnsiTextAttribute.CLEAR);
AnsiTerminal.foreGroundColor(AnsiForegroundColor.YELLOW);
System.out.print("|");
AnsiTerminal.textAttribute(AnsiTextAttribute.BOLD);
AnsiTerminal.foreGroundColor(AnsiForegroundColor.CYAN);
System.out.print(" Group ");
AnsiTerminal.textAttribute(AnsiTextAttribute.CLEAR);
AnsiTerminal.foreGroundColor(AnsiForegroundColor.YELLOW);
System.out.print("|");
AnsiTerminal.textAttribute(AnsiTextAttribute.BOLD);
AnsiTerminal.foreGroundColor(AnsiForegroundColor.CYAN);
System.out.print(" Roles ");
AnsiTerminal.textAttribute(AnsiTextAttribute.CLEAR);
AnsiTerminal.foreGroundColor(AnsiForegroundColor.YELLOW);
System.out.println("|");
System.out.println("+--------------------+--------+---------------+--------------------------------+");
for (Feature feat : features.values()) {
AnsiTerminal.foreGroundColor(AnsiForegroundColor.YELLOW);
System.out.print("| ");
AnsiTerminal.textAttribute(AnsiTextAttribute.BOLD);
AnsiTerminal.foreGroundColor(AnsiForegroundColor.GREEN);
System.out.print(StringUtils.rightPad(feat.getUid(), 19));
AnsiTerminal.textAttribute(AnsiTextAttribute.CLEAR);
AnsiTerminal.foreGroundColor(AnsiForegroundColor.YELLOW);
System.out.print("| ");
if (feat.isEnable()) {
AnsiTerminal.textAttribute(AnsiTextAttribute.BOLD);
AnsiTerminal.foreGroundColor(AnsiForegroundColor.GREEN);
System.out.print(StringUtils.rightPad("ON", 7));
} else {
AnsiTerminal.textAttribute(AnsiTextAttribute.BOLD);
AnsiTerminal.foreGroundColor(AnsiForegroundColor.RED);
System.out.print(StringUtils.rightPad("OFF", 7));
}
AnsiTerminal.textAttribute(AnsiTextAttribute.CLEAR);
AnsiTerminal.foreGroundColor(AnsiForegroundColor.YELLOW);
System.out.print("| ");
AnsiTerminal.textAttribute(AnsiTextAttribute.BOLD);
AnsiTerminal.foreGroundColor(AnsiForegroundColor.WHITE);
String groupName = "---";
if (!StringUtils.isEmpty(feat.getGroup())) {
groupName = feat.getGroup();
}
System.out.print(StringUtils.rightPad(groupName, 14));
AnsiTerminal.textAttribute(AnsiTextAttribute.CLEAR);
AnsiTerminal.foreGroundColor(AnsiForegroundColor.YELLOW);
System.out.print("| ");
AnsiTerminal.textAttribute(AnsiTextAttribute.BOLD);
AnsiTerminal.foreGroundColor(AnsiForegroundColor.WHITE);
String roles = feat.getPermissions().toString();
roles = roles.substring(1, roles.length() - 1);
if ("".equals(roles)) {
roles = "---";
}
System.out.print(StringUtils.rightPad(roles, 31));
AnsiTerminal.textAttribute(AnsiTextAttribute.CLEAR);
AnsiTerminal.foreGroundColor(AnsiForegroundColor.YELLOW);
System.out.println("| ");
}
AnsiTerminal.textAttribute(AnsiTextAttribute.CLEAR);
AnsiTerminal.foreGroundColor(AnsiForegroundColor.YELLOW);
System.out.println("+--------------------+--------+---------------+--------------------------------+");
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class AutowiredFF4JBeanPostProcessor method autoWiredFeature.
private void autoWiredFeature(Object bean, Field field) {
// Find the required and name parameters
FF4JFeature annFeature = field.getAnnotation(FF4JFeature.class);
String annValue = annFeature.value();
String featureName = field.getName();
if (annValue != null && !"".equals(annValue)) {
featureName = annValue;
}
Feature feature = readFeature(field, featureName, annFeature.required());
if (feature != null) {
if (Feature.class.isAssignableFrom(field.getType())) {
injectValue(field, bean, featureName, feature);
} else if (Boolean.class.isAssignableFrom(field.getType())) {
injectValue(field, bean, featureName, new Boolean(feature.isEnable()));
} else if (boolean.class.isAssignableFrom(field.getType())) {
injectValue(field, bean, featureName, feature.isEnable());
} else {
throw new IllegalArgumentException("Field annotated with @FF4JFeature" + " must inherit from org.ff4j.Feature or be boolean " + field.getType() + " [class=" + bean.getClass().getName() + ", field=" + field.getName() + "]");
}
}
}
Aggregations