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