2 * Copyright (C) 2015 Roland Haeder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.pizzaapplication.beans.controller;
19 import java.io.IOException;
20 import java.lang.reflect.InvocationTargetException;
21 import java.rmi.RemoteException;
22 import java.sql.SQLException;
23 import java.util.Deque;
24 import java.util.Iterator;
25 import javax.annotation.PostConstruct;
27 import javax.enterprise.context.SessionScoped;
28 import javax.faces.FacesException;
29 import javax.inject.Named;
30 import javax.naming.InitialContext;
31 import javax.naming.NamingException;
32 import org.mxchange.jcoreee.beans.BaseFrameworkBean;
33 import org.mxchange.jshopcore.exceptions.CategoryTitleAlreadyUsedException;
34 import org.mxchange.jshopcore.exceptions.ProductTitleAlreadyUsedException;
35 import org.mxchange.jshopcore.model.category.Category;
36 import org.mxchange.jshopcore.model.product.Product;
37 import org.mxchange.jshopeelib.beans.remote.shop.ShopSessionBeanRemote;
40 * Main application class
42 * @author Roland Haeder
46 public class PizzaServiceWebBean extends BaseFrameworkBean implements PizzaWebBean {
50 private static final long serialVersionUID = 58137539530279L;
56 private final ShopSessionBeanRemote remote;
62 // Get new application instance
63 this.getLogger().debug("INITIALIZER!"); //NOI18N
69 * @throws javax.naming.NamingException Something happened here?
71 public PizzaServiceWebBean () throws NamingException {
72 this.getLogger().trace("CALLED!"); //NOI18N
74 // Get initial context
75 InitialContext context = new InitialContext();
77 // Try to lookup the bean
78 this.remote = (ShopSessionBeanRemote) context.lookup("ejb/stateless-shop"); //NOI18N
83 public void init () throws FacesException {
85 this.getLogger().trace("CALLED!"); //NOI18N
92 public Iterator<Product> getAvailableProductsIterator () throws RemoteException {
94 return this.remote.getAvailableProductsIterator();
95 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
97 throw new RemoteException("getAvailableProductsIterator() failed", ex);
102 public Iterator<Product> getAllProductsIterator () throws RemoteException {
104 return this.remote.getAllProductsIterator();
105 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
107 throw new RemoteException("getAllProductsIterator() failed.", ex);
112 public Deque<Product> getAvailableProducts () throws RemoteException {
114 return this.remote.getAvailableProducts();
115 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
117 throw new RemoteException("getAvailableProducts() failed.", ex);
122 public Deque<Product> getAllProducts () throws RemoteException {
124 return this.remote.getAllProducts();
125 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
127 throw new RemoteException("getAllProducts() failed", ex);
132 public Iterator<Category> getAllCategoriesIterator () throws RemoteException {
134 return this.remote.getAllCategoriesIterator();
135 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
137 throw new RemoteException("getAllCategoriesIterator() failed.", ex);
142 public Deque<Category> getAllCategories () throws RemoteException {
144 return this.remote.getAllCategories();
145 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
147 throw new RemoteException("getAllCategories() failed.", ex);
152 public void doAdminAddCategory (final Category category) throws RemoteException, CategoryTitleAlreadyUsedException {
154 this.remote.doAdminAddCategory(category);
155 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
157 throw new RemoteException("doAdminAddCategory() failed.", ex);
162 public void doAdminAddProduct (final Product product) throws RemoteException, ProductTitleAlreadyUsedException {
164 this.remote.doAdminAddProduct(product);
165 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
167 throw new RemoteException("doAdminAddProduct() failed.", ex);