From f156893ea56293b961bd094c712270e06c83e01f Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Fri, 28 Aug 2015 15:28:48 +0200 Subject: [PATCH] =?utf8?q?Maybe=20an=20idea=20to=20get=20rid=20of=20the=20?= =?utf8?q?scriptlet=20in=20index.jsp=3F=20A=20bean=20for=20basket=20items?= =?utf8?q?=3F=20Signed-off-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../beans/item/BasketItemBean.java | 107 ++++++++++++++++++ .../pizzaapplication/beans/item/ItemBean.java | 45 ++++++++ 2 files changed, 152 insertions(+) create mode 100644 src/java/org/mxchange/pizzaapplication/beans/item/BasketItemBean.java create mode 100644 src/java/org/mxchange/pizzaapplication/beans/item/ItemBean.java 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 index 00000000..458ede09 --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/item/BasketItemBean.java @@ -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 . + */ +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 index 00000000..05fcaf93 --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/item/ItemBean.java @@ -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 . + */ +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 (); +} -- 2.39.5