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.pizzaservice;
19 import java.io.IOException;
20 import java.lang.reflect.InvocationTargetException;
21 import java.sql.SQLException;
22 import java.util.Deque;
23 import javax.annotation.PostConstruct;
24 import javax.ejb.Stateless;
25 import javax.servlet.ServletException;
26 import org.mxchange.jcore.exceptions.BadTokenException;
27 import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException;
28 import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException;
29 import org.mxchange.jshop.beans.BaseFrameworkBean;
30 import org.mxchange.jshop.beans.remote.shop.ShopSessionBeanRemote;
31 import org.mxchange.jshop.category.Category;
32 import org.mxchange.jshop.product.Product;
33 import org.mxchange.pizzaapplication.application.PizzaApplication;
34 import org.mxchange.pizzaapplication.application.PizzaServiceApplication;
39 * @author Roland Haeder
41 @Stateless (name="shop", mappedName = "ejb/stateless-shop")
42 public class PizzaServiceSessionBean extends BaseFrameworkBean implements ShopSessionBeanRemote {
47 private static final long serialVersionUID = 578314942948L;
50 * Application instance
52 private final PizzaApplication app;
58 // Get new application instance
59 this.getLogger().debug("INITIALIZER!"); //NOI18N
60 this.app = new PizzaServiceApplication();
66 public PizzaServiceSessionBean () {
67 this.getLogger().trace("CALLED!"); //NOI18N
71 public void init () throws RuntimeException {
73 this.getLogger().trace("CALLED!"); //NOI18N
78 } catch (final UnsupportedDatabaseBackendException | SQLException | IOException | BadTokenException ex) {
80 throw new RuntimeException(ex);
85 public Deque<Product> getAvailableProducts () throws ServletException {
87 return this.app.getAvailableProducts();
88 } catch (final IOException | BadTokenException | SQLException | CorruptedDatabaseFileException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
90 throw new ServletException(ex);
95 public Deque<Product> getAllProducts () throws ServletException {
97 return this.app.getAllProducts();
98 } catch (final IOException | BadTokenException | SQLException | CorruptedDatabaseFileException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
100 throw new ServletException(ex);
105 public Deque<Category> getAllCategories () throws ServletException {
107 return this.app.getAllCategories();
108 } catch (final IOException | BadTokenException | SQLException | CorruptedDatabaseFileException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
110 throw new ServletException(ex);