001    // CustomerServiceJavaBean.java
002    
003    package com.service.customer.web;
004    
005    import com.service.customer.ejb.Customer;
006    import com.service.customer.ejb.ProcessCustomerSessionLocal;
007    
008    import java.util.Locale;
009    import java.util.ResourceBundle;
010    import java.util.List;
011    import javax.naming.InitialContext;
012    
013    
014    public class CustomerServiceJavaBean
015    {
016       private ProcessCustomerSessionLocal process = null;
017       private ResourceBundle      bundle = null;
018       private String              JNDI_PROCESS_EJB = null;
019    
020       private String      action = "";
021       private String      customerID = "";
022       private String      fullName = "";
023       private String      emailAddress = "";
024       private String      interests = "";
025    
026    
027       public CustomerServiceJavaBean()
028       {
029          InitialContext initial = null;
030    
031          bundle = ResourceBundle.getBundle("customer", Locale.getDefault(), CustomerServiceJavaBean.class.getClassLoader());
032          JNDI_PROCESS_EJB = bundle.getString("jndi.process.ejb");
033    
034          try
035          {
036             initial = new InitialContext();
037                     process = (ProcessCustomerSessionLocal) initial.lookup(JNDI_PROCESS_EJB.trim());
038             System.out.println("Successful looking up: '" + JNDI_PROCESS_EJB.trim() + "'");
039          } // end try
040    
041          catch (Exception e)
042          {
043             e.printStackTrace();
044          } // end catch
045       } // end CustomerServiceJavaBean
046    
047    
048       public List<Customer> getAllCustomers()
049       {
050          List<Customer> customerList = null;
051    
052          try
053          {
054             customerList = process.findAllCustomers();
055          } // end try
056    
057          catch (Exception e)
058          {
059             customerList = null;
060             e.printStackTrace();
061          } // end catch
062    
063          return customerList;
064       } // end getAllCustomerss
065    } // end CustomerServiceJavaBean