]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
Maybe an idea to get rid of the scriptlet in index.jsp? A bean for basket items?
authorRoland Haeder <roland@mxchange.org>
Fri, 28 Aug 2015 13:28:48 +0000 (15:28 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 28 Aug 2015 13:28:48 +0000 (15:28 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

src/java/org/mxchange/pizzaapplication/beans/item/BasketItemBean.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/item/ItemBean.java [new file with mode: 0644]

diff --git a/src/java/org/mxchange/pizzaapplication/beans/item/BasketItemBean.java b/src/java/org/mxchange/pizzaapplication/beans/item/BasketItemBean.java
new file mode 100644 (file)
index 0000000..458ede0
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.beans.basket;
+
+import java.io.IOException;
+import java.sql.SQLException;
+import javax.enterprise.context.SessionScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.mxchange.jcore.exceptions.BadTokenException;
+import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException;
+import org.mxchange.pizzaapplication.beans.item.ItemBean;
+
+/**
+ * A bean for basket items
+ *
+ * @author Roland Haeder
+ */
+@Named("item")
+@SessionScoped
+public class BasketItemBean implements ItemBean {
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 324813539158845L;
+
+       /**
+        * Class' logger
+        */
+       private final Logger LOG;
+
+       /**
+        * Instance of wrapped basket
+        */
+       @Inject
+       private BasketBean basket;
+
+       /**
+        * Initializer block
+        */
+       {
+               // Get logger
+               LOG = LogManager.getLogger(this);
+       }
+
+       /**
+        * Default constructor to be able to throw exceptions from super constructor
+        * @throws org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException If the backend is unsupported
+        * @throws java.sql.SQLException If an SQL error occurs
+        * @throws java.io.IOException If an IO Error occurs
+        * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found
+        */
+       public BasketItemBean () throws UnsupportedDatabaseBackendException, SQLException, IOException, BadTokenException {
+               // Trace message
+               this.getLogger().trace("CALLED!");
+       }
+
+       /**
+        * Getter for logger
+        *
+        * @return Logger
+        */
+       @Override
+       public Logger getLogger () {
+               return this.LOG;
+       }
+
+       /**
+        * @return the basket
+        */
+       @Override
+       public BasketBean getBasket () {
+               // Trace message
+               //* NOISY-DEBUG: */ this.getLogger().trace(MessageFormat.format("basket={0} - EXIT!", this.basket)); //NOI18N
+
+               // Return it
+               return this.basket;
+       }
+
+       /**
+        * @param basket the basket to set
+        */
+       @Override
+       public void setBasket (final BasketBean basket) {
+               // Trace message
+               //* NOISY-DEBUG: */ this.getLogger().trace(MessageFormat.format("basket={0} - CALLED!", basket)); //NOI18N
+
+               // Set it here
+               this.basket = basket;
+       }
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/item/ItemBean.java b/src/java/org/mxchange/pizzaapplication/beans/item/ItemBean.java
new file mode 100644 (file)
index 0000000..05fcaf9
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.beans.item;
+
+import java.io.Serializable;
+import org.apache.logging.log4j.Logger;
+import org.mxchange.pizzaapplication.beans.basket.BasketBean;
+
+/**
+ * An interface for an item bean
+ *
+ * @author Roland Haeder
+ */
+public interface ItemBean extends Serializable {
+       /**
+        * @return the basket
+        */
+       public BasketBean getBasket ();
+
+       /**
+        * @param basket the basket to set
+        */
+       public void setBasket (final BasketBean basket);
+
+       /**
+        * Getter for logger
+        *
+        * @return Logger
+        */
+       public Logger getLogger ();
+}