From: Roland Häder Date: Fri, 15 Jul 2016 10:35:47 +0000 (+0200) Subject: Renamed controller (please cherry-pick this): X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=66dbf6459649ff1dab721d8b9ba92dee22cb5f7e;p=jfinancials-war.git Renamed controller (please cherry-pick this): - renamed it as it was old name Signed-off-by: Roland Häder --- 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; + } + +}