1 27 28 29 package com.sun.ebank.web; 30 31 import javax.ejb.*; 32 import javax.naming.*; 33 import javax.rmi.PortableRemoteObject ; 34 import java.rmi.RemoteException ; 35 import com.sun.ebank.ejb.exception.*; 36 import com.sun.ebank.util.*; 37 import com.sun.ebank.ejb.account.*; 38 import com.sun.ebank.ejb.customer.*; 39 import com.sun.ebank.ejb.tx.*; 40 import java.util.*; 41 42 43 public class BeanManager { 44 private CustomerController custctl = null; 45 private AccountController acctctl = null; 46 private TxController txctl = null; 47 48 public BeanManager() { 49 if (custctl == null) { 50 try { 51 CustomerControllerHome home = 52 EJBGetter.getCustomerControllerHome(); 53 custctl = home.create(); 54 } catch (RemoteException ex) { 55 Debug.print("Couldn't create customer bean." + ex.getMessage()); 56 } catch (CreateException ex) { 57 Debug.print("Couldn't create customer bean." + ex.getMessage()); 58 } catch (NamingException ex) { 59 Debug.print("Unable to look up home: " + 60 CodedNames.CUSTOMER_CONTROLLER_EJBHOME + ex.getMessage()); 61 } 62 } 63 64 if (acctctl == null) { 65 try { 66 AccountControllerHome home = 67 EJBGetter.getAccountControllerHome(); 68 acctctl = home.create(); 69 } catch (RemoteException ex) { 70 Debug.print("Couldn't create account bean." + ex.getMessage()); 71 } catch (CreateException ex) { 72 Debug.print("Couldn't create account bean." + ex.getMessage()); 73 } catch (NamingException ex) { 74 Debug.print("Unable to look up home: " + 75 CodedNames.ACCOUNT_CONTROLLER_EJBHOME + ex.getMessage()); 76 } 77 } 78 79 if (txctl == null) { 80 try { 81 TxControllerHome home = EJBGetter.getTxControllerHome(); 82 txctl = home.create(); 83 } catch (RemoteException ex) { 84 Debug.print("Couldn't create transaction bean." + 85 ex.getMessage()); 86 } catch (CreateException ex) { 87 Debug.print("Couldn't create transaction bean." + 88 ex.getMessage()); 89 } catch (NamingException ex) { 90 Debug.print("Unable to look up home: " + 91 CodedNames.TX_CONTROLLER_EJBHOME + ex.getMessage()); 92 } 93 } 94 } 95 96 public CustomerController getCustomerController() { 97 return custctl; 98 } 99 100 public AccountController getAccountController() { 101 return acctctl; 102 } 103 104 public TxController getTxController() { 105 return txctl; 106 } 107 108 public void destroy() { 109 custctl = null; 110 acctctl = null; 111 txctl = null; 112 } 113 } 114 | Popular Tags |