]> git.mxchange.org Git - pizzaservice-war.git/blobdiff - src/java/org/mxchange/pizzaapplication/beans/controller/PizzaServiceWebBean.java
updated jshop-ee-jar + made first calls
[pizzaservice-war.git] / src / java / org / mxchange / pizzaapplication / beans / controller / PizzaServiceWebBean.java
index f3885dfe839c7288facc4b51fc016af9e6b6ad46..41f61484673a5c85557bc44be4daf057de3df8b8 100644 (file)
@@ -20,21 +20,21 @@ import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.rmi.RemoteException;
 import java.sql.SQLException;
-import java.text.MessageFormat;
 import java.util.Deque;
 import java.util.Iterator;
 import javax.annotation.PostConstruct;
+import javax.ejb.EJB;
 import javax.enterprise.context.SessionScoped;
 import javax.faces.FacesException;
 import javax.inject.Named;
-import org.mxchange.jshop.beans.BaseFrameworkBean;
-import org.mxchange.jshop.category.Category;
-import org.mxchange.jshop.exceptions.CategoryTitleAlreadyUsedException;
-import org.mxchange.jshop.exceptions.ProductTitleAlreadyUsedException;
-import org.mxchange.jshop.item.AddableBasketItem;
-import org.mxchange.jshop.product.Product;
-import org.mxchange.pizzaapplication.application.PizzaApplication;
-import org.mxchange.pizzaapplication.application.PizzaServiceApplication;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jcoreee.beans.BaseFrameworkBean;
+import org.mxchange.jshopcore.exceptions.CategoryTitleAlreadyUsedException;
+import org.mxchange.jshopcore.exceptions.ProductTitleAlreadyUsedException;
+import org.mxchange.jshopcore.model.category.Category;
+import org.mxchange.jshopcore.model.product.Product;
+import org.mxchange.jshopeelib.beans.remote.shop.ShopSessionBeanRemote;
 
 /**
  * Main application class
@@ -50,9 +50,10 @@ public class PizzaServiceWebBean extends BaseFrameworkBean implements PizzaWebBe
        private static final long serialVersionUID = 58137539530279L;
 
        /**
-        * Pizza application
+        * Remote bean
         */
-       private final PizzaApplication app;
+       @EJB
+       private final ShopSessionBeanRemote remote;
 
        /**
         * Initializer block
@@ -60,47 +61,37 @@ public class PizzaServiceWebBean extends BaseFrameworkBean implements PizzaWebBe
        {
                // Get new application instance
                this.getLogger().debug("INITIALIZER!"); //NOI18N
-               this.app = new PizzaServiceApplication();
        }
 
        /**
         * Default constructor
+        * 
+        * @throws javax.naming.NamingException Something happened here?
         */
-       public PizzaServiceWebBean () {
+       public PizzaServiceWebBean () throws NamingException {
                this.getLogger().trace("CALLED!"); //NOI18N
+
+               // Get initial context
+               InitialContext context = new InitialContext();
+
+               // Try to lookup the bean
+               this.remote = (ShopSessionBeanRemote) context.lookup("ejb/stateless-shop"); //NOI18N
        }
 
        @Override
        @PostConstruct
        public void init () throws FacesException {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("application={0} - CALLED!", this.getApplication())); //NOI18N
-
-               // Must not be null
-               if (this.getApplication() == null) {
-                       // Abort here
-                       throw new NullPointerException("application is null"); //NOI18N
-               }
-
-               try {
-                       // Call init method
-                       this.app.init();
-               } catch (final SQLException | IOException ex) {
-                       // Continue to throw
-                       throw new FacesException(ex);
-               }
-       }
+               this.getLogger().trace("CALLED!"); //NOI18N
 
-       @Override
-       @Deprecated
-       public String getPrintableProductAvailability (final Product product) {
-               return this.app.getPrintableProductAvailability(product);
+               // Super call
+               super.init();
        }
 
        @Override
        public Iterator<Product> getAvailableProductsIterator () throws RemoteException {
                try {
-                       return this.app.getAvailableProductsIterator();
+                       return this.remote.getAvailableProductsIterator();
                } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
                        // Continue to throw
                        throw new RemoteException("getAvailableProductsIterator() failed", ex);
@@ -110,7 +101,7 @@ public class PizzaServiceWebBean extends BaseFrameworkBean implements PizzaWebBe
        @Override
        public Iterator<Product> getAllProductsIterator () throws RemoteException {
                try {
-                       return this.app.getAllProductsIterator();
+                       return this.remote.getAllProductsIterator();
                } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
                        // Continue to throw
                        throw new RemoteException("getAllProductsIterator() failed.", ex);
@@ -120,7 +111,7 @@ public class PizzaServiceWebBean extends BaseFrameworkBean implements PizzaWebBe
        @Override
        public Deque<Product> getAvailableProducts () throws RemoteException {
                try {
-                       return this.app.getAvailableProducts();
+                       return this.remote.getAvailableProducts();
                } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
                        // Continue to throw
                        throw new RemoteException("getAvailableProducts() failed.", ex);
@@ -130,7 +121,7 @@ public class PizzaServiceWebBean extends BaseFrameworkBean implements PizzaWebBe
        @Override
        public Deque<Product> getAllProducts () throws RemoteException {
                try {
-                       return this.app.getAllProducts();
+                       return this.remote.getAllProducts();
                } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
                        // Continue to throw
                        throw new RemoteException("getAllProducts() failed", ex);
@@ -140,7 +131,7 @@ public class PizzaServiceWebBean extends BaseFrameworkBean implements PizzaWebBe
        @Override
        public Iterator<Category> getAllCategoriesIterator () throws RemoteException {
                try {
-                       return this.app.getAllCategoriesIterator();
+                       return this.remote.getAllCategoriesIterator();
                } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
                        // Continue to throw
                        throw new RemoteException("getAllCategoriesIterator() failed.", ex);
@@ -150,7 +141,7 @@ public class PizzaServiceWebBean extends BaseFrameworkBean implements PizzaWebBe
        @Override
        public Deque<Category> getAllCategories () throws RemoteException {
                try {
-                       return this.app.getAllCategories();
+                       return this.remote.getAllCategories();
                } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
                        // Continue to throw
                        throw new RemoteException("getAllCategories() failed.", ex);
@@ -160,7 +151,7 @@ public class PizzaServiceWebBean extends BaseFrameworkBean implements PizzaWebBe
        @Override
        public void doAdminAddCategory (final Category category) throws RemoteException, CategoryTitleAlreadyUsedException {
                try {
-                       this.app.doAdminAddCategory(category);
+                       this.remote.doAdminAddCategory(category);
                } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
                        // Continue to throw
                        throw new RemoteException("doAdminAddCategory() failed.", ex);
@@ -170,42 +161,10 @@ public class PizzaServiceWebBean extends BaseFrameworkBean implements PizzaWebBe
        @Override
        public void doAdminAddProduct (final Product product) throws RemoteException, ProductTitleAlreadyUsedException {
                try {
-                       this.app.doAdminAddProduct(product);
+                       this.remote.doAdminAddProduct(product);
                } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
                        // Continue to throw
                        throw new RemoteException("doAdminAddProduct() failed.", ex);
                }
        }
-
-       @Override
-       @Deprecated
-       public String getPrintableProduktCategory (final Product product) throws RemoteException {
-               try {
-                       return this.app.getPrintableProductCategory(product);
-               } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
-                       // Continue to throw
-                       throw new RemoteException("getPrintableProduktCategory() failed.", ex);
-               }
-       }
-
-       @Override
-       @Deprecated
-       public void doAdminHandleProductForms () throws RemoteException {
-               // Deprecated method called
-               throw new UnsupportedOperationException("Deprecated method called");
-       }
-
-       @Override
-       @Deprecated
-       public void doAdminHandleCategoryForms () throws RemoteException {
-               // Deprecated method called
-               throw new UnsupportedOperationException("Deprecated method called");
-       }
-
-       @Override
-       @Deprecated
-       public String generateLinkForParent (final Category category) {
-               // Deligate to app
-               return this.app.generateLinkForParent(category);
-       }
 }