1 22 package org.jboss.ejb3.test.bank; 23 24 import java.rmi.*; 25 import java.sql.Connection ; 26 27 import javax.naming.*; 28 import javax.ejb.Init ; 29 import javax.ejb.SessionContext ; 30 import javax.sql.DataSource ; 31 32 import org.jboss.logging.Logger; 33 34 39 public class BankBean21 implements javax.ejb.SessionBean 40 { 41 private static final Logger log = Logger.getLogger(BankBean21.class); 42 43 public DataSource customerDb; 44 45 static final String ID = "java:comp/env/id"; 46 47 String id; 48 49 String customerId = "defaultId"; 50 51 static long nextAccountId = System.currentTimeMillis(); 52 53 static long nextCustomerId = System.currentTimeMillis(); 54 55 String initialized = ""; 56 57 private String activated = ""; 58 59 public String getId() 60 { 61 return id; 62 } 63 64 public String createAccountId(Customer customer) throws RemoteException 65 { 66 return getId() + "." + customer.getName() + "." + (nextAccountId++); 67 } 68 69 public String createCustomerId() 70 { 71 return getId() + "." + (nextCustomerId++); 72 } 73 74 public void storeCustomerId(String customerId) 75 { 76 this.customerId = customerId; 77 } 78 79 public String retrieveCustomerId() 80 { 81 return customerId; 82 } 83 84 public String interceptCustomerId(String customerId) 85 { 86 return customerId; 87 } 88 89 public void testResource() throws Exception 90 { 91 if (customerDb == null) throw new Exception ("customerDb resource not set"); 92 Connection connection = customerDb.getConnection(); 93 connection.close(); 94 } 95 96 public void remove() 97 { 98 99 } 100 101 @Init 102 public void annotatedInit() 103 { 104 initialized += "YES"; 105 } 106 107 public void init() 108 { 109 initialized += "YES"; 110 } 111 112 public String isInitialized() 113 { 114 return initialized; 115 } 116 117 public String isActivated() 118 { 119 return activated; 120 } 121 122 public void ejbCreate() 123 { 124 activated += "_CREATED"; 125 } 126 127 public void ejbActivate() 128 { 129 activated += "_ACTIVATED"; 130 } 131 132 public void ejbPassivate() 133 { 134 135 } 136 137 public void ejbRemove() 138 { 139 140 } 141 142 public void setSessionContext(SessionContext context) 143 { 144 145 } 146 } 147 148 186 | Popular Tags |