From: Roland Haeder Date: Wed, 9 Sep 2015 09:19:59 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4e46abc3349babdee32d8949f311c89f25cf6919;hp=616a8915310de2a6b0237c2e2b54e2c59fae5b1b;p=pizzaservice-war.git Continued: - added controller for products and categories (both admin) - updated jcore-ee-logger.jar + updated jshop-ee-lib.jar Signed-off-by:Roland Häder --- diff --git a/lib/jcore-ee-logger.jar b/lib/jcore-ee-logger.jar index 5b54c7d6..6a5ff51e 100644 Binary files a/lib/jcore-ee-logger.jar and b/lib/jcore-ee-logger.jar differ diff --git a/lib/jshop-ee-lib.jar b/lib/jshop-ee-lib.jar index 657fb707..1697bcc7 100644 Binary files a/lib/jshop-ee-lib.jar and b/lib/jshop-ee-lib.jar differ diff --git a/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebBean.java new file mode 100644 index 00000000..240437b7 --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebBean.java @@ -0,0 +1,70 @@ +/* + * 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.category; + +import java.rmi.RemoteException; +import javax.enterprise.context.SessionScoped; +import javax.faces.view.facelets.FaceletException; +import javax.inject.Named; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import org.mxchange.jcoreee.beans.BaseFrameworkBean; +import org.mxchange.jshopcore.model.category.Category; +import org.mxchange.jshopcore.model.category.CategorySessionBeanRemote; + +/** + * Main application class + * + * @author Roland Haeder + */ +@Named("admin_category") +@SessionScoped +public class AdminCategoryWebBean extends BaseFrameworkBean implements AdminCategoryWebController { + /** + * Serial id + */ + private static final long serialVersionUID = 5_819_375_183_472_871L; + + /** + * Remote bean for categories + */ + private final CategorySessionBeanRemote category; + + /** + * Default constructor + * + * @throws javax.naming.NamingException Something happened here? + */ + public AdminCategoryWebBean () throws NamingException { + // Get initial context + InitialContext context = new InitialContext(); + + // Try to lookup the bean + this.category = (CategorySessionBeanRemote) context.lookup("ejb/stateless-product"); //NOI18N + } + + @Override + public void doAdminAddCategory (final Category category) throws FaceletException { + try { + // Deligate to bean + this.category.doAdminAddCategory(category); + } catch (final RemoteException ex) { + // Continue to throw + throw new FaceletException(ex); + } + } +} diff --git a/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebController.java b/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebController.java new file mode 100644 index 00000000..c38dcdb5 --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebController.java @@ -0,0 +1,36 @@ +/* + * 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.category; + +import javax.faces.view.facelets.FaceletException; +import org.mxchange.jshopcore.model.category.Category; + +/** + * An interface for product controllers for "ADMIN" role + * + * @author Roland Haeder + */ +public interface AdminCategoryWebController { + + /** + * Adds given category data from request to database + * + * @param category Category instance + * @throws javax.faces.view.facelets.FaceletException If something unexpected happened + */ + public void doAdminAddCategory (final Category category) throws FaceletException; +} diff --git a/src/java/org/mxchange/pizzaapplication/beans/controller/AdminProductWebController.java b/src/java/org/mxchange/pizzaapplication/beans/controller/AdminProductWebController.java deleted file mode 100644 index 6000979c..00000000 --- a/src/java/org/mxchange/pizzaapplication/beans/controller/AdminProductWebController.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.controller; - -import java.util.Deque; -import javax.faces.view.facelets.FaceletException; -import org.mxchange.jshopcore.model.category.Category; -import org.mxchange.jshopcore.model.product.Product; - -/** - * An interface for product controllers for "ADMIN" role - * - * @author Roland Haeder - */ -public interface AdminProductWebController { - - /** - * Adds given category data from request to database - * - * @param category Category instance - * @throws javax.faces.view.facelets.FaceletException If something unexpected happened - */ - public void doAdminAddCategory (final Category category) throws FaceletException; - - /** - * Adds given product data from request to database - * - * @param product Product instance - * @throws javax.faces.view.facelets.FaceletException If something unexpected happened - */ - public void doAdminAddProduct (final Product product) throws FaceletException; - - /** - * Some "getter" for a linked list of all products - * - * @return All products - * @throws javax.faces.view.facelets.FaceletException If anything went wrong - */ - public Deque getAllProducts () throws FaceletException; -} diff --git a/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebBean.java new file mode 100644 index 00000000..0792c6b8 --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebBean.java @@ -0,0 +1,77 @@ +/* + * 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.product; + +import java.rmi.RemoteException; +import java.util.Deque; +import javax.enterprise.context.SessionScoped; +import javax.faces.view.facelets.FaceletException; +import javax.inject.Named; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import org.mxchange.jcoreee.beans.BaseFrameworkBean; +import org.mxchange.jshopcore.model.product.Product; +import org.mxchange.jshopcore.model.product.ProductSessionBeanRemote; + +/** + * Main application class + * + * @author Roland Haeder + */ +@Named("admin_product") +@SessionScoped +public class AdminProductWebBean extends BaseFrameworkBean implements AdminProductWebController { + /** + * Serial id + */ + private static final long serialVersionUID = 5_819_375_183_472_871L; + + /** + * Remote bean for products + */ + private final ProductSessionBeanRemote product; + + /** + * Default constructor + * + * @throws javax.naming.NamingException Something happened here? + */ + public AdminProductWebBean () throws NamingException { + // Get initial context + InitialContext context = new InitialContext(); + + // Try to lookup the bean + this.product = (ProductSessionBeanRemote) context.lookup("ejb/stateless-product"); //NOI18N + } + + @Override + public void doAdminAddProduct (final Product product) throws FaceletException { + // Call bean + this.product.doAdminAddProduct(product); + } + + @Override + public Deque getAllProducts () throws FaceletException { + try { + // Call bean + return this.product.getAllProducts(); + } catch (final RemoteException ex) { + // Continue to throw + throw new FaceletException(ex); + } + } +} diff --git a/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebController.java b/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebController.java new file mode 100644 index 00000000..a77b18db --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebController.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.product; + +import java.util.Deque; +import javax.faces.view.facelets.FaceletException; +import org.mxchange.jshopcore.model.product.Product; + +/** + * An interface for product controllers for "ADMIN" role + * + * @author Roland Haeder + */ +public interface AdminProductWebController { + + /** + * Adds given product data from request to database + * + * @param product Product instance + * @throws javax.faces.view.facelets.FaceletException If something unexpected happened + */ + public void doAdminAddProduct (final Product product) throws FaceletException; + + /** + * Some "getter" for a linked list of all products + * + * @return All products + * @throws javax.faces.view.facelets.FaceletException If anything went wrong + */ + public Deque getAllProducts () throws FaceletException; +}