]> git.mxchange.org Git - pizzaservice-war.git/blob - src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebRequestBean.java
d174089db22c6521ddf23f8fa17603f71fd0e577
[pizzaservice-war.git] / src / java / org / mxchange / pizzaapplication / beans / receipt / PizzaReceiptWebRequestBean.java
1 /*
2  * Copyright (C) 2016 - 2022 Free Software Foundation
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.annotation.PostConstruct;
20 import javax.enterprise.context.RequestScoped;
21 import javax.faces.FacesException;
22 import javax.inject.Inject;
23 import javax.inject.Named;
24 import javax.naming.Context;
25 import javax.naming.InitialContext;
26 import javax.naming.NamingException;
27 import org.mxchange.jshopcore.model.receipt.ReceiptBeanRemote;
28 import org.mxchange.pizzaapplication.beans.BasePizzaBean;
29 import org.mxchange.pizzaapplication.beans.helper.PizzaWebRequestHelperController;
30
31 /**
32  * Checkout controller
33  * <p>
34  * @author Roland Häder<roland@mxchange.org>
35  */
36 @Named ("receiptController")
37 @RequestScoped
38 public class PizzaReceiptWebRequestBean extends BasePizzaBean implements PizzaReceiptWebRequestController {
39
40         /**
41          * Serial number
42          */
43         private static final long serialVersionUID = 95_723_834_783_478_781L;
44
45         /**
46          * Bean helper instance
47          */
48         @Inject
49         private PizzaWebRequestHelperController beanHelper;
50
51         /**
52          * Remote bean instance
53          */
54         private ReceiptBeanRemote receiptBean;
55
56         /**
57          * Default constructor
58          */
59         public PizzaReceiptWebRequestBean () {
60         }
61
62         @Override
63         public String fetchAccessKey () {
64                 return this.receiptBean.fetchAccessKey(this.beanHelper.getCustomer());
65         }
66
67         /**
68          * Post-construction method
69          */
70         @PostConstruct
71         public void init () {
72                 try {
73                         // Get initial context
74                         Context context = new InitialContext();
75
76                         // Get factory from JMS resource
77                         this.receiptBean = (ReceiptBeanRemote) context.lookup("java:global/pizzaservice-ejb/pdf!org.mxchange.jshopcore.model.receipt.ReceiptBeanRemote");
78                 } catch (final NamingException e) {
79                         // Continued to throw
80                         throw new FacesException(e);
81                 }
82         }
83 }