]> git.mxchange.org Git - pizzaservice-war.git/blob - src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebSessionBean.java
2318775ba6afbf452d3c4be7791bbe62705bd785
[pizzaservice-war.git] / src / java / org / mxchange / pizzaapplication / beans / receipt / PizzaReceiptWebSessionBean.java
1 /*
2  * Copyright (C) 2016, 2017 Roland Häder
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Affero General Public License as
6  * published by the Free Software Foundation, either version 3 of the
7  * License, or (at your option) any later version.
8  *
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 Affero General Public License for more details.
13  *
14  * You should have received a copy of the GNU Affero General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 package org.mxchange.pizzaapplication.beans.receipt;
18
19 import javax.enterprise.context.SessionScoped;
20 import javax.faces.FacesException;
21 import javax.inject.Inject;
22 import javax.inject.Named;
23 import javax.naming.Context;
24 import javax.naming.InitialContext;
25 import javax.naming.NamingException;
26 import org.mxchange.jshopcore.model.receipt.ReceiptBeanRemote;
27 import org.mxchange.pizzaapplication.beans.BasePizzaController;
28 import org.mxchange.pizzaapplication.beans.helper.PizzaWebRequestHelperController;
29
30 /**
31  * Checkout controller
32  * <p>
33  * @author Roland Häder<roland@mxchange.org>
34  */
35 @Named ("receiptController")
36 @SessionScoped
37 public class PizzaReceiptWebSessionBean extends BasePizzaController implements PizzaReceiptWebSessionController {
38
39         /**
40          * Serial number
41          */
42         private static final long serialVersionUID = 95_723_834_783_478_781L;
43
44         /**
45          * Bean helper instance
46          */
47         @Inject
48         private PizzaWebRequestHelperController beanHelper;
49
50         /**
51          * Remote bean instance
52          */
53         private ReceiptBeanRemote receiptBean;
54
55         /**
56          * Default constructor
57          */
58         public PizzaReceiptWebSessionBean () {
59                 try {
60                         // Get initial context
61                         Context context = new InitialContext();
62
63                         // Get factory from JMS resource
64                         this.receiptBean = (ReceiptBeanRemote) context.lookup("java:global/jshop-ejb/pdf!org.mxchange.jshopcore.model.receipt.ReceiptBeanRemote");
65                 } catch (final NamingException e) {
66                         // Continued to throw
67                         throw new FacesException(e);
68                 }
69         }
70
71         @Override
72         public String fetchAccessKey () {
73                 return this.receiptBean.fetchAccessKey(this.beanHelper.getCustomer());
74         }
75
76 }