<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>
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;
*/
private static final long serialVersionUID = 58137539530279L;
+ /**
+ * Remote bean
+ */
+ private final ShopSessionBeanRemote remote;
+
/**
* Initializer block
*/
/**
* 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
// 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);
@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);
@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);
@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);
@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);
@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);
@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);
@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);
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
*/
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
// Return it
return genders;
}
+
+ /**
+ * @return the remote
+ */
+ private ShopDataBeanRemote getRemote () {
+ return this.remote;
+ }
}