* Remote bean
*/
@EJB
- private final ShopSessionBeanRemote remote;
+ private final ShopSessionBeanRemote shop;
/**
* Initializer block
InitialContext context = new InitialContext();
// Try to lookup the bean
- this.remote = (ShopSessionBeanRemote) context.lookup("ejb/stateless-shop"); //NOI18N
+ this.shop = (ShopSessionBeanRemote) context.lookup("ejb/stateless-shop"); //NOI18N
}
@Override
@Override
public Iterator<Product> getAvailableProductsIterator () throws FacesException {
try {
- return this.remote.getAvailableProductsIterator();
+ return this.getShop().getAvailableProductsIterator();
} catch (final RemoteException ex) {
// Continue to throw
throw new FacesException(ex);
@Override
public Iterator<Product> getAllProductsIterator () throws FacesException {
try {
- return this.remote.getAllProductsIterator();
+ return this.getShop().getAllProductsIterator();
} catch (final RemoteException ex) {
// Continue to throw
throw new FacesException(ex);
@Override
public Deque<Product> getAvailableProducts () throws FacesException {
try {
- return this.remote.getAvailableProducts();
+ return this.getShop().getAvailableProducts();
} catch (final RemoteException ex) {
// Continue to throw
throw new FacesException(ex);
@Override
public Deque<Product> getAllProducts () throws FacesException {
try {
- return this.remote.getAllProducts();
+ return this.getShop().getAllProducts();
} catch (final RemoteException ex) {
// Continue to throw
throw new FacesException(ex);
@Override
public Iterator<Category> getAllCategoriesIterator () throws FacesException {
try {
- return this.remote.getAllCategoriesIterator();
+ return this.getShop().getAllCategoriesIterator();
} catch (final RemoteException ex) {
// Continue to throw
throw new FacesException(ex);
@Override
public Deque<Category> getAllCategories () throws FacesException {
try {
- return this.remote.getAllCategories();
+ return this.getShop().getAllCategories();
} catch (final RemoteException ex) {
// Continue to throw
throw new FacesException(ex);
@Override
public void doAdminAddCategory (final Category category) throws FacesException {
try {
- this.remote.doAdminAddCategory(category);
+ this.getShop().doAdminAddCategory(category);
} catch (final IOException | CategoryTitleAlreadyUsedException ex) {
// Continue to throw
throw new FacesException(ex);
@Override
public void doAdminAddProduct (final Product product) throws FacesException {
try {
- this.remote.doAdminAddProduct(product);
+ this.getShop().doAdminAddProduct(product);
} catch (final IOException | ProductTitleAlreadyUsedException ex) {
// Continue to throw
throw new FacesException(ex);
}
}
+
+ /**
+ * Getter for shop remote bean
+ *
+ * @return Remote shop bean
+ */
+ private ShopSessionBeanRemote getShop () {
+ return this.shop;
+ }
}
import javax.ejb.EJB;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
import org.mxchange.jcoreee.beans.BaseFrameworkBean;
import org.mxchange.jshopeelib.beans.remote.customer.CustomerSessionBeanRemote;
* Remote customer bean
*/
@EJB
- private CustomerSessionBeanRemote customer;
+ private final CustomerSessionBeanRemote customer;
/**
* Default constructor
+ *
+ * @throws javax.naming.NamingException If something happens?
*/
- public PizzaServiceCustomerWebBean () {
+ public PizzaServiceCustomerWebBean () throws NamingException {
+ // Get initial context
+ InitialContext context = new InitialContext();
+
+ // Try to lookup
+ this.customer = (CustomerSessionBeanRemote) context.lookup("ejb/stateless-consumer");
}
@Override