]> git.mxchange.org Git - pizzaservice-war.git/blob - src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebBean.java
Continued:
[pizzaservice-war.git] / src / java / org / mxchange / pizzaapplication / beans / category / AdminCategoryWebBean.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.category;
18
19 import java.rmi.RemoteException;
20 import javax.enterprise.context.SessionScoped;
21 import javax.faces.view.facelets.FaceletException;
22 import javax.inject.Named;
23 import javax.naming.InitialContext;
24 import javax.naming.NamingException;
25 import org.mxchange.jcoreee.beans.BaseFrameworkBean;
26 import org.mxchange.jshopcore.model.category.Category;
27 import org.mxchange.jshopcore.model.category.CategorySessionBeanRemote;
28
29 /**
30  * Main application class
31  *
32  * @author Roland Haeder
33  */
34 @Named("admin_category")
35 @SessionScoped
36 public class AdminCategoryWebBean extends BaseFrameworkBean implements AdminCategoryWebController {
37         /**
38          * Serial id
39          */
40         private static final long serialVersionUID = 5_819_375_183_472_871L;
41
42         /**
43          * Remote bean for categories
44          */
45         private final CategorySessionBeanRemote category;
46
47         /**
48          * Default constructor
49          * 
50          * @throws javax.naming.NamingException Something happened here?
51          */
52         public AdminCategoryWebBean () throws NamingException {
53                 // Get initial context
54                 InitialContext context = new InitialContext();
55
56                 // Try to lookup the bean
57                 this.category = (CategorySessionBeanRemote) context.lookup("ejb/stateless-product"); //NOI18N
58         }
59
60         @Override
61         public void doAdminAddCategory (final Category category) throws FaceletException {
62                 try {
63                         // Deligate to bean
64                         this.category.doAdminAddCategory(category);
65                 } catch (final RemoteException ex) {
66                         // Continue to throw
67                         throw new FaceletException(ex);
68                 }
69         }
70 }