]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
Continued a bit:
authorRoland Haeder <roland@mxchange.org>
Sat, 5 Sep 2015 13:51:44 +0000 (15:51 +0200)
committerRoland Haeder <roland@mxchange.org>
Sat, 5 Sep 2015 13:52:09 +0000 (15:52 +0200)
- renamed getGenders() to allGenders()
- tried to get initial context and lookup bean
- the EJB methods allGenders() and selectableGenders() may now work?
Signed-off-by:Roland Häder <roland@mxchange.org>

lib/jshop-ejb.jar [deleted file]
nbproject/genfiles.properties
nbproject/project.xml
src/java/org/mxchange/pizzaapplication/beans/controller/PizzaServiceWebBean.java
src/java/org/mxchange/pizzaapplication/beans/enums/DataWebBean.java
src/java/org/mxchange/pizzaapplication/beans/enums/PizzaServiceDataWebBean.java

diff --git a/lib/jshop-ejb.jar b/lib/jshop-ejb.jar
deleted file mode 100644 (file)
index 0ba207f..0000000
Binary files a/lib/jshop-ejb.jar and /dev/null differ
index b37418b106a71831d642fdc3e808c1283c212d93..76bf30586e6bfbeda549e1716324ede1881834e9 100644 (file)
@@ -1,4 +1,4 @@
-build.xml.data.CRC32=f043d149
+build.xml.data.CRC32=ff1dc0da
 build.xml.script.CRC32=82213886
 build.xml.stylesheet.CRC32=651128d4@1.68.1.1
 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
index 257793f7548aa13a5f4443075e0e1b598c78de15..53d981aeb66539627dae41ff0a52d250a3090073 100644 (file)
                     <file>${file.reference.jcoreee.jar}</file>
                     <path-in-war>WEB-INF/lib</path-in-war>
                 </library>
+                <library dirs="200">
+                    <file>${file.reference.jshop-core.jar}</file>
+                    <path-in-war>WEB-INF/lib</path-in-war>
+                </library>
+                <library dirs="200">
+                    <file>${reference.PizzaService-lib.jar}</file>
+                    <path-in-war>WEB-INF/lib</path-in-war>
+                </library>
                 <library dirs="200">
                     <file>${file.reference.cdi-api.jar}</file>
                     <path-in-war>WEB-INF/lib</path-in-war>
                     <file>${file.reference.log4j-web-2.3.jar}</file>
                     <path-in-war>WEB-INF/lib</path-in-war>
                 </library>
-                <library dirs="200">
-                    <file>${file.reference.jshop-core.jar}</file>
-                    <path-in-war>WEB-INF/lib</path-in-war>
-                </library>
-                <library dirs="200">
-                    <file>${reference.PizzaService-lib.jar}</file>
-                    <path-in-war>WEB-INF/lib</path-in-war>
-                </library>
                 <library dirs="200">
                     <file>${file.reference.jshop-ejb.jar}</file>
                     <path-in-war>WEB-INF/lib</path-in-war>
index e69bba25a0cdf564b225f3158becde83d358e013..6949560f3bbff26f167305b189e40c277d72b625 100644 (file)
@@ -26,7 +26,10 @@ import javax.annotation.PostConstruct;
 import javax.enterprise.context.SessionScoped;
 import javax.faces.FacesException;
 import javax.inject.Named;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
 import org.mxchange.jcoreee.beans.BaseFrameworkBean;
+import org.mxchange.jshop.beans.shop.ShopSessionBeanRemote;
 import org.mxchange.jshopcore.exceptions.CategoryTitleAlreadyUsedException;
 import org.mxchange.jshopcore.exceptions.ProductTitleAlreadyUsedException;
 import org.mxchange.jshopcore.model.category.Category;
@@ -45,6 +48,11 @@ public class PizzaServiceWebBean extends BaseFrameworkBean implements PizzaWebBe
         */
        private static final long serialVersionUID = 58137539530279L;
 
+       /**
+        * Remote bean
+        */
+       private final ShopSessionBeanRemote remote;
+
        /**
         * Initializer block
         */
@@ -55,9 +63,17 @@ public class PizzaServiceWebBean extends BaseFrameworkBean implements PizzaWebBe
 
        /**
         * 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");
        }
 
        @Override
@@ -68,20 +84,12 @@ public class PizzaServiceWebBean extends BaseFrameworkBean implements PizzaWebBe
 
                // Super call
                super.init();
-
-               try {
-                       // Call init method
-                       this.app.init();
-               } catch (final SQLException | IOException ex) {
-                       // Continue to throw
-                       throw new FacesException(ex);
-               }
        }
 
        @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);
@@ -91,7 +99,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);
@@ -101,7 +109,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);
@@ -111,7 +119,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);
@@ -121,7 +129,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);
@@ -131,7 +139,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);
@@ -141,7 +149,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);
@@ -151,7 +159,7 @@ 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);
index 5fe8435d0b93c61de5e09aed593ee03762aaa61d..076b02b293a0cbc6d15f94c8c6408c2aed5319fd 100644 (file)
@@ -26,16 +26,18 @@ import org.mxchange.jcoreee.beans.FrameworkBean;
  * @author Roland Haeder
  */
 public interface DataWebBean extends FrameworkBean {
+
        /**
         * Getter for all genders as array
         *
         * @return All genders as array
         */
-       public Gender[] getGenders ();
+       public Gender[] allGenders ();
+
        /**
         * Getter for only selectable genders as array, UNKNOWN is not selectable
         *
         * @return All genders as array
         */
-       public List<Gender> getSelectableGenders ();
+       public List<Gender> selectableGenders ();
 }
index 87ed577b10b61516e180eb1074160f57aa1b571c..86f77a905fa616094fed51765cde5771d1a5ad8f 100644 (file)
 package org.mxchange.pizzaapplication.beans.enums;
 
 import java.text.MessageFormat;
-import java.util.Arrays;
 import java.util.List;
 import javax.enterprise.context.ApplicationScoped;
 import javax.inject.Named;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
 import org.mxchange.jcore.model.contact.gender.Gender;
 import org.mxchange.jcoreee.beans.BaseFrameworkBean;
+import org.mxchange.jshop.beans.data.ShopDataBeanRemote;
 
 /**
  * A customer bean which hides the customer instance
@@ -38,23 +40,41 @@ public class PizzaServiceDataWebBean extends BaseFrameworkBean implements DataWe
         */
        private static final long serialVersionUID = 835482364189L;
 
+       /**
+        * Remote bean
+        */
+       private final ShopDataBeanRemote remote;
+
+       /**
+        * Default constructor
+        * 
+        * @throws javax.naming.NamingException If something happens?
+        */
+       public PizzaServiceDataWebBean () throws NamingException {
+               // Get initial context
+               InitialContext context = new InitialContext();
+
+               // Try to lookup bean
+               this.remote = (ShopDataBeanRemote) context.lookup("ejb/stateless-data");
+       }
+
        @Override
-       public Gender[] getGenders () {
+       public Gender[] allGenders () {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("Genders={0} - EXIT!", Arrays.toString(Gender.values())));
+               this.getLogger().trace("CALLED!");
 
                // Return it
-               return Gender.values();
+               return this.getRemote().allGenders();
        }
 
        @Override
-       public List<Gender> getSelectableGenders () {
+       public List<Gender> selectableGenders () {
                // Trace message
                this.getLogger().trace("CALLED!"); //NOI18N
 
                // Init array
                // TODO Call EJB here?
-               List<Gender> genders = null;
+               List<Gender> genders = this.getRemote().selectableGenders();
 
                // Trace message
                this.getLogger().trace(MessageFormat.format("genders={0} - EXIT!", genders)); //NOI18N
@@ -62,4 +82,11 @@ public class PizzaServiceDataWebBean extends BaseFrameworkBean implements DataWe
                // Return it
                return genders;
        }
+
+       /**
+        * @return the remote
+        */
+       private ShopDataBeanRemote getRemote () {
+               return this.remote;
+       }
 }