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 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.jshopejb.beans.BaseFrameworkBean;
-import org.mxchange.jshopejb.model.category.Category;
-import org.mxchange.jshopejb.model.product.Product;
+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
*/
private static final long serialVersionUID = 58137539530279L;
+ /**
+ * Remote bean
+ */
+ @EJB
+ 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"); //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);
@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);
}
}
-
- @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);
- }
}