1
2
3 package com.service.customer.web;
4
5 import com.service.customer.ejb.Customer;
6 import com.service.customer.ejb.ProcessCustomerSessionLocal;
7
8 import java.util.Locale;
9 import java.util.ResourceBundle;
10 import java.util.List;
11 import javax.naming.InitialContext;
12
13
14 public class CustomerServiceJavaBean
15 {
16 private ProcessCustomerSessionLocal process = null;
17 private ResourceBundle bundle = null;
18 private String JNDI_PROCESS_EJB = null;
19
20 private String action = "";
21 private String customerID = "";
22 private String fullName = "";
23 private String emailAddress = "";
24 private String interests = "";
25
26
27 public CustomerServiceJavaBean()
28 {
29 InitialContext initial = null;
30
31 bundle = ResourceBundle.getBundle("customer", Locale.getDefault(), CustomerServiceJavaBean.class.getClassLoader());
32 JNDI_PROCESS_EJB = bundle.getString("jndi.process.ejb");
33
34 try
35 {
36 initial = new InitialContext();
37 process = (ProcessCustomerSessionLocal) initial.lookup(JNDI_PROCESS_EJB.trim());
38 System.out.println("Successful looking up: '" + JNDI_PROCESS_EJB.trim() + "'");
39 }
40
41 catch (Exception e)
42 {
43 e.printStackTrace();
44 }
45 }
46
47
48 public List<Customer> getAllCustomers()
49 {
50 List<Customer> customerList = null;
51
52 try
53 {
54 customerList = process.findAllCustomers();
55 }
56
57 catch (Exception e)
58 {
59 customerList = null;
60 e.printStackTrace();
61 }
62
63 return customerList;
64 }
65 }