From ce889adae3f91a8296bf41ce5804a51483242b2a Mon Sep 17 00:00:00 2001 From: talio Date: Sun, 12 Nov 2017 16:12:35 +0200 Subject: forwarder implement toggling feature on forwarder Issue-Id : SDC-653 Change-Id: I238ae82b6f1fd9fce58ab584acd362a6bafd0dff Signed-off-by: talio --- .../sdc/common/togglz/ToggleableFeature.java | 15 ++++++++++++ .../sdc/common/togglz/TogglzConfiguration.java | 27 ++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/togglz/ToggleableFeature.java create mode 100644 openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/togglz/TogglzConfiguration.java (limited to 'openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp') diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/togglz/ToggleableFeature.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/togglz/ToggleableFeature.java new file mode 100644 index 0000000000..aab9845573 --- /dev/null +++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/togglz/ToggleableFeature.java @@ -0,0 +1,15 @@ +package org.openecomp.sdc.common.togglz; + +import org.togglz.core.Feature; +import org.togglz.core.annotation.Label; +import org.togglz.core.context.FeatureContext; + +public enum ToggleableFeature implements Feature { + + @Label ("Forwarder Capability") + FORWARDER_CAPABILITY; + + public boolean isActive() { + return FeatureContext.getFeatureManager().isActive(this); + } +} diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/togglz/TogglzConfiguration.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/togglz/TogglzConfiguration.java new file mode 100644 index 0000000000..d743205e5b --- /dev/null +++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/togglz/TogglzConfiguration.java @@ -0,0 +1,27 @@ +package org.openecomp.sdc.common.togglz; + +import org.togglz.core.Feature; +import org.togglz.core.manager.TogglzConfig; +import org.togglz.core.repository.StateRepository; +import org.togglz.core.repository.file.FileBasedStateRepository; +import org.togglz.core.user.SimpleFeatureUser; +import org.togglz.core.user.UserProvider; + +import java.io.File; + +public class TogglzConfiguration implements TogglzConfig { + @Override + public Class getFeatureClass() { + return ToggleableFeature.class; + } + + @Override + public StateRepository getStateRepository() { + return new FileBasedStateRepository(new File("/tmp/features.properties")); + } + + @Override + public UserProvider getUserProvider() { + return () -> new SimpleFeatureUser("admin", true); + } +} -- cgit 1.2.3-korg