From: Roland Haeder Date: Mon, 7 Sep 2015 08:55:36 +0000 (+0200) Subject: Removed thrown exceptions + added EJB call X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=825135bc54cdf29cd16e3a149e3ae29d413eba28;p=pizzaservice-war.git Removed thrown exceptions + added EJB call Signed-off-by:Roland Häder --- diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index cd59461d..5002b9e3 100644 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -881,11 +881,17 @@ exists or setup the property manually. For example like this: + + + + + + @@ -1040,6 +1046,7 @@ exists or setup the property manually. For example like this: + @@ -1054,6 +1061,7 @@ exists or setup the property manually. For example like this: + @@ -1468,6 +1476,7 @@ exists or setup the property manually. For example like this: --> + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index 2ae24f4c..fd79f48e 100644 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -build.xml.data.CRC32=1edfee4e +build.xml.data.CRC32=e1e3912d 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. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=1edfee4e -nbproject/build-impl.xml.script.CRC32=055d9dec +nbproject/build-impl.xml.data.CRC32=e1e3912d +nbproject/build-impl.xml.script.CRC32=c4215d75 nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.68.1.1 diff --git a/nbproject/project.properties b/nbproject/project.properties index a21586fd..76570c08 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -68,7 +68,8 @@ javac.classpath=\ ${file.reference.gf-client.jar}:\ ${file.reference.log4j-api-2.3.jar}:\ ${file.reference.log4j-core-2.3.jar}:\ - ${file.reference.log4j-web-2.3.jar} + ${file.reference.log4j-web-2.3.jar}:\ + ${reference.jshop-ee-lib.jar} # Space-separated list of extra javac options javac.compilerargs=-Xlint:unchecked -Xlint:deprecation javac.debug=true @@ -97,8 +98,10 @@ javadoc.windowtitle=Pizza-Service Application lib.dir=${web.docbase.dir}/WEB-INF/lib persistence.xml.dir=${conf.dir} platform.active=default_platform +project.jshop-ee-lib=../jshop-ee-lib project.license=gpl30 project.PizzaService-lib=../pizzaservice-lib +reference.jshop-ee-lib.jar=${project.jshop-ee-lib}/dist/jshop-ee-lib.jar reference.PizzaService-lib.jar=${project.PizzaService-lib}/dist/PizzaService-lib.jar resource.dir=setup run.test.classpath=\ diff --git a/nbproject/project.xml b/nbproject/project.xml index dee8330a..158fd82f 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -46,6 +46,10 @@ ${file.reference.log4j-web-2.3.jar} WEB-INF/lib + + ${reference.jshop-ee-lib.jar} + WEB-INF/lib + @@ -67,6 +71,14 @@ clean jar + + jshop-ee-lib + jar + + jar + clean + jar + diff --git a/src/java/org/mxchange/pizzaapplication/beans/basket/PizzaServiceBasketWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/basket/PizzaServiceBasketWebBean.java index ef1f8d5b..e8da93ea 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/basket/PizzaServiceBasketWebBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/basket/PizzaServiceBasketWebBean.java @@ -16,10 +16,16 @@ */ package org.mxchange.pizzaapplication.beans.basket; +import java.rmi.RemoteException; import javax.annotation.PostConstruct; +import javax.ejb.EJB; 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.jshopeelib.beans.remote.basket.BasketSessionBeanRemote; /** * A bean for the basket @@ -29,14 +35,39 @@ import org.mxchange.jcoreee.beans.BaseFrameworkBean; @Named("basket") @SessionScoped public class PizzaServiceBasketWebBean extends BaseFrameworkBean implements PizzaBasketWebBean { + /** + * Basket bean + */ + @EJB + private final BasketSessionBeanRemote basket; + /** * Serial number */ private static final long serialVersionUID = 5476347320198L; + /** + * Default constructor + * + * @throws javax.naming.NamingException If something happened? + */ + public PizzaServiceBasketWebBean () throws NamingException { + // Get initial context + InitialContext context = new InitialContext(); + + // Try to lookup + this.basket = (BasketSessionBeanRemote) context.lookup("ejb/stateless-basket"); //NOI18N + } + @Override public boolean isEmpty () { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + try { + // Call remote bean + return this.basket.isEmpty(); + } catch (final RemoteException ex) { + // Continued to throw + throw new FacesException(ex); + } } @Override diff --git a/src/java/org/mxchange/pizzaapplication/beans/controller/PizzaServiceWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/controller/PizzaServiceWebBean.java index 57ad75aa..3b815a8f 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/controller/PizzaServiceWebBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/controller/PizzaServiceWebBean.java @@ -17,7 +17,7 @@ package org.mxchange.pizzaapplication.beans.controller; import java.io.IOException; -import java.sql.SQLException; +import java.rmi.RemoteException; import java.util.Deque; import java.util.Iterator; import javax.annotation.PostConstruct; @@ -87,7 +87,7 @@ public class PizzaServiceWebBean extends BaseFrameworkBean implements PizzaWebBe public Iterator getAvailableProductsIterator () throws FacesException { try { return this.remote.getAvailableProductsIterator(); - } catch (final IOException | SQLException ex) { + } catch (final RemoteException ex) { // Continue to throw throw new FacesException(ex); } @@ -97,7 +97,7 @@ public class PizzaServiceWebBean extends BaseFrameworkBean implements PizzaWebBe public Iterator getAllProductsIterator () throws FacesException { try { return this.remote.getAllProductsIterator(); - } catch (final IOException | SQLException ex) { + } catch (final RemoteException ex) { // Continue to throw throw new FacesException(ex); } @@ -107,7 +107,7 @@ public class PizzaServiceWebBean extends BaseFrameworkBean implements PizzaWebBe public Deque getAvailableProducts () throws FacesException { try { return this.remote.getAvailableProducts(); - } catch (final IOException | SQLException ex) { + } catch (final RemoteException ex) { // Continue to throw throw new FacesException(ex); } @@ -117,7 +117,7 @@ public class PizzaServiceWebBean extends BaseFrameworkBean implements PizzaWebBe public Deque getAllProducts () throws FacesException { try { return this.remote.getAllProducts(); - } catch (final IOException | SQLException ex) { + } catch (final RemoteException ex) { // Continue to throw throw new FacesException(ex); } @@ -127,7 +127,7 @@ public class PizzaServiceWebBean extends BaseFrameworkBean implements PizzaWebBe public Iterator getAllCategoriesIterator () throws FacesException { try { return this.remote.getAllCategoriesIterator(); - } catch (final IOException | SQLException ex) { + } catch (final RemoteException ex) { // Continue to throw throw new FacesException(ex); } @@ -137,7 +137,7 @@ public class PizzaServiceWebBean extends BaseFrameworkBean implements PizzaWebBe public Deque getAllCategories () throws FacesException { try { return this.remote.getAllCategories(); - } catch (final IOException | SQLException ex) { + } catch (final RemoteException ex) { // Continue to throw throw new FacesException(ex); } @@ -147,7 +147,7 @@ public class PizzaServiceWebBean extends BaseFrameworkBean implements PizzaWebBe public void doAdminAddCategory (final Category category) throws FacesException { try { this.remote.doAdminAddCategory(category); - } catch (final IOException | SQLException | CategoryTitleAlreadyUsedException ex) { + } catch (final IOException | CategoryTitleAlreadyUsedException ex) { // Continue to throw throw new FacesException(ex); } @@ -157,7 +157,7 @@ public class PizzaServiceWebBean extends BaseFrameworkBean implements PizzaWebBe public void doAdminAddProduct (final Product product) throws FacesException { try { this.remote.doAdminAddProduct(product); - } catch (final IOException | SQLException | ProductTitleAlreadyUsedException ex) { + } catch (final IOException | ProductTitleAlreadyUsedException ex) { // Continue to throw throw new FacesException(ex); } diff --git a/src/java/org/mxchange/pizzaapplication/beans/data/PizzaServiceDataWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/data/PizzaServiceDataWebBean.java index 33318ee7..dd4f0d86 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/data/PizzaServiceDataWebBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/data/PizzaServiceDataWebBean.java @@ -19,6 +19,7 @@ package org.mxchange.pizzaapplication.beans.data; import java.text.MessageFormat; import java.util.List; import javax.annotation.PostConstruct; +import javax.ejb.EJB; import javax.enterprise.context.ApplicationScoped; import javax.inject.Named; import javax.naming.InitialContext; @@ -44,7 +45,8 @@ public class PizzaServiceDataWebBean extends BaseFrameworkBean implements DataWe /** * Remote bean */ - private final ShopDataBeanRemote remote; + @EJB + private final ShopDataBeanRemote data; /** * Default constructor @@ -56,16 +58,16 @@ public class PizzaServiceDataWebBean extends BaseFrameworkBean implements DataWe InitialContext context = new InitialContext(); // Try to lookup bean - this.remote = (ShopDataBeanRemote) context.lookup("ejb/stateless-data"); + this.data = (ShopDataBeanRemote) context.lookup("ejb/stateless-data"); //NOI18N } @Override public Gender[] allGenders () { // Trace message - this.getLogger().trace("CALLED!"); + this.getLogger().trace("CALLED!"); //NOI18N // Return it - return this.getRemote().allGenders(); + return this.getData().allGenders(); } @Override @@ -75,7 +77,7 @@ public class PizzaServiceDataWebBean extends BaseFrameworkBean implements DataWe // Init array // TODO Call EJB here? - List genders = this.getRemote().selectableGenders(); + List genders = this.getData().selectableGenders(); // Trace message this.getLogger().trace(MessageFormat.format("genders={0} - EXIT!", genders)); //NOI18N @@ -85,10 +87,12 @@ public class PizzaServiceDataWebBean extends BaseFrameworkBean implements DataWe } /** - * @return the remote + * Getter for data remote bean + * + * @return data remote bean */ - private ShopDataBeanRemote getRemote () { - return this.remote; + private ShopDataBeanRemote getData () { + return this.data; } @Override