Commits

Micha Kops committed 520b03f

Programmatic example in a test servlet added.

Comments (0)

Files changed (2)

src/main/java/com/hascode/tutorial/fflag/config/FeatureFlagConfiguration.java

 @ApplicationScoped
 public class FeatureFlagConfiguration implements TogglzConfig {
 
-	private static final String FEATURE_FLAG_ADMIN_ROLE = "feature_flag_admin";
-
 	@Override
 	public Class<? extends Feature> getFeatureClass() {
 		return UserFeatures.class;
 
 	@Override
 	public UserProvider getUserProvider() {
-		// return new ServletUserProvider(FEATURE_FLAG_ADMIN_ROLE);
 		return new UserProvider() {
 			@Override
 			public FeatureUser getCurrentUser() {

src/main/java/com/hascode/tutorial/fflag/servlet/FeatureFlagTestServlet.java

+package com.hascode.tutorial.fflag.servlet;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.hascode.tutorial.fflag.feature.UserFeatures;
+
+@WebServlet(urlPatterns = "/fftest")
+public class FeatureFlagTestServlet extends HttpServlet {
+	private static final long serialVersionUID = 1L;
+
+	@Override
+	protected void doGet(final HttpServletRequest req,
+			final HttpServletResponse resp) throws ServletException,
+			IOException {
+		StringBuilder sb = new StringBuilder();
+		sb.append("Available features are:\n");
+		if (UserFeatures.DISPLAY_SIMPLE_USER_PROFILE.isActive()) {
+			sb.append("\t- Display simple user profiles is enabled\n");
+		}
+		if (UserFeatures.DISPLAY_EXTENDED_USER_PROFILE.isActive()) {
+			sb.append("\t- Display extended user profiles is enabled\n");
+		}
+		resp.getWriter().append(sb.toString());
+	}
+
+}