]> git.mxchange.org Git - pizzaservice-war.git/blob - src/java/org/mxchange/pizzaapplication/beans/enums/PizzaServiceDataWebBean.java
Continued a bit:
[pizzaservice-war.git] / src / java / org / mxchange / pizzaapplication / beans / enums / PizzaServiceDataWebBean.java
1 /*
2  * Copyright (C) 2015 Roland Haeder
3  *
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.
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 General Public License for more details.
13  *
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/>.
16  */
17 package org.mxchange.pizzaapplication.beans.enums;
18
19 import java.text.MessageFormat;
20 import java.util.List;
21 import javax.enterprise.context.ApplicationScoped;
22 import javax.inject.Named;
23 import javax.naming.InitialContext;
24 import javax.naming.NamingException;
25 import org.mxchange.jcore.model.contact.gender.Gender;
26 import org.mxchange.jcoreee.beans.BaseFrameworkBean;
27 import org.mxchange.jshop.beans.data.ShopDataBeanRemote;
28
29 /**
30  * A customer bean which hides the customer instance
31  *
32  * @author Roland Haeder
33  */
34 @Named ("data")
35 @ApplicationScoped
36 public class PizzaServiceDataWebBean extends BaseFrameworkBean implements DataWebBean {
37
38         /**
39          * Serial number
40          */
41         private static final long serialVersionUID = 835482364189L;
42
43         /**
44          * Remote bean
45          */
46         private final ShopDataBeanRemote remote;
47
48         /**
49          * Default constructor
50          * 
51          * @throws javax.naming.NamingException If something happens?
52          */
53         public PizzaServiceDataWebBean () throws NamingException {
54                 // Get initial context
55                 InitialContext context = new InitialContext();
56
57                 // Try to lookup bean
58                 this.remote = (ShopDataBeanRemote) context.lookup("ejb/stateless-data");
59         }
60
61         @Override
62         public Gender[] allGenders () {
63                 // Trace message
64                 this.getLogger().trace("CALLED!");
65
66                 // Return it
67                 return this.getRemote().allGenders();
68         }
69
70         @Override
71         public List<Gender> selectableGenders () {
72                 // Trace message
73                 this.getLogger().trace("CALLED!"); //NOI18N
74
75                 // Init array
76                 // TODO Call EJB here?
77                 List<Gender> genders = this.getRemote().selectableGenders();
78
79                 // Trace message
80                 this.getLogger().trace(MessageFormat.format("genders={0} - EXIT!", genders)); //NOI18N
81
82                 // Return it
83                 return genders;
84         }
85
86         /**
87          * @return the remote
88          */
89         private ShopDataBeanRemote getRemote () {
90                 return this.remote;
91         }
92 }