]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Renamed controller (please cherry-pick this):
authorRoland Häder <roland@mxchange.org>
Fri, 15 Jul 2016 10:35:47 +0000 (12:35 +0200)
committerRoland Haeder <roland@mxchange.org>
Thu, 28 Jul 2016 19:51:51 +0000 (21:51 +0200)
- renamed it as it was old name

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/pizzaapplication/beans/features/PizzaFeatureWebApplicationBean.java [new file with mode: 0644]

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 (file)
index 0000000..e590cda
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+ */
+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
+ * <p>
+ * @author Roland Haeder<rhaeder@cho-time.de>
+ */
+@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;
+       }
+
+}