]> git.mxchange.org Git - pizzaservice-war.git/blob - src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebSessionBean.java
Rewritten a lot:
[pizzaservice-war.git] / src / java / org / mxchange / pizzaapplication / beans / receipt / PizzaReceiptWebSessionBean.java
1 /*
2  * Copyright (C) 2016 Roland Haeder
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.Named;
22 import javax.naming.Context;
23 import javax.naming.InitialContext;
24 import javax.naming.NamingException;
25 import org.mxchange.jcustomercore.model.customer.Customer;
26 import org.mxchange.jshopcore.model.receipt.ReceiptBeanRemote;
27 import org.mxchange.pizzaapplication.beans.BasePizzaController;
28
29 /**
30  * Checkout controller
31  * <p>
32  * @author Roland Haeder<roland@mxchange.org>
33  */
34 @Named ("receiptController")
35 @SessionScoped
36 public class PizzaReceiptWebSessionBean extends BasePizzaController implements PizzaReceiptWebSessionController {
37
38         /**
39          * Serial number
40          */
41         private static final long serialVersionUID = 95_723_834_783_478_781L;
42
43         /**
44          * Customer instance
45          */
46         private Customer customer;
47
48         /**
49          * Remote bean instance
50          */
51         private ReceiptBeanRemote receiptBean;
52
53         /**
54          * Default constructor
55          */
56         public PizzaReceiptWebSessionBean () {
57                 try {
58                         // Get initial context
59                         Context context = new InitialContext();
60
61                         // Get factory from JMS resource
62                         this.receiptBean = (ReceiptBeanRemote) context.lookup("java:global/jshop-ejb/pdf!org.mxchange.jshopcore.model.receipt.ReceiptBeanRemote");
63                 } catch (final NamingException e) {
64                         // Continued to throw
65                         throw new FacesException(e);
66                 }
67         }
68
69         @Override
70         public String fetchAccessKey () {
71                 return this.receiptBean.fetchAccessKey(this.getCustomer());
72         }
73
74         @Override
75         public Customer getCustomer () {
76                 return this.customer;
77         }
78
79         @Override
80         public void setCustomer (final Customer customer) {
81                 this.customer = customer;
82         }
83
84 }