From 66dbf6459649ff1dab721d8b9ba92dee22cb5f7e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 15 Jul 2016 12:35:47 +0200 Subject: [PATCH] Renamed controller (please cherry-pick this): - renamed it as it was old name MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../PizzaFeatureWebApplicationBean.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/java/org/mxchange/pizzaapplication/beans/features/PizzaFeatureWebApplicationBean.java diff --git a/src/java/org/mxchange/pizzaapplication/beans/features/PizzaFeatureWebApplicationBean.java b/src/java/org/mxchange/pizzaapplication/beans/features/PizzaFeatureWebApplicationBean.java new file mode 100644 index 00000000..e590cdaa --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/features/PizzaFeatureWebApplicationBean.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2016 Cho-Time GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.pizzaapplication.beans.features; + +import javax.enterprise.context.ApplicationScoped; +import javax.faces.context.FacesContext; +import javax.inject.Named; +import org.mxchange.pizzaapplication.beans.BasePizzaController; + +/** + * A feature bean + *

+ * @author Roland Haeder + */ +@Named ("featureController") +@ApplicationScoped +public class PizzaFeatureWebApplicationBean extends BasePizzaController implements PizzaFeaturesWebApplicationController { + + /** + * Serial number + */ + private static final long serialVersionUID = 64_237_512_690_168_674L; + + @Override + public boolean isFeatureEnabled (final String feature) { + // The parameter must be set + if (null == feature) { + // Throw NPE + throw new NullPointerException("feature is null"); //NOI18N + } else if (feature.isEmpty()) { + // Is empty + throw new IllegalArgumentException("feature is empty"); //NOI18N + } + + // Get context parameter + String contextParameter = FacesContext.getCurrentInstance().getExternalContext().getInitParameter(String.format("is_feature_%s_enabled", feature)); //NOI18N + + // Is it set? + boolean isEnabled = ((contextParameter instanceof String) && (contextParameter.toLowerCase().equals("true"))); //NOI18N + + // Return value + return isEnabled; + } + +} -- 2.39.5