1 package edu.rice.rubis.beans; 2 3 import java.rmi.*; 4 import javax.ejb.*; 5 import javax.naming.Context ; 6 import javax.naming.InitialContext ; 7 import javax.rmi.PortableRemoteObject ; 8 9 28 29 public class BuyNowBean implements EntityBean 30 { 31 private EntityContext entityContext; 32 private transient boolean isDirty; 34 35 36 public Integer id; 37 public Integer buyerId; 38 public Integer itemId; 39 public int qty; 40 public String date; 41 42 43 49 public Integer getId() throws RemoteException 50 { 51 return id; 52 } 53 54 60 public Integer getBuyerId() throws RemoteException 61 { 62 return buyerId; 63 } 64 65 71 public Integer getItemId() throws RemoteException 72 { 73 return itemId; 74 } 75 76 82 public int getQuantity() throws RemoteException 83 { 84 return qty; 85 } 86 87 93 public String getDate() throws RemoteException 94 { 95 return date; 96 } 97 98 105 public void setBuyerId(Integer id) throws RemoteException 106 { 107 buyerId = id; 108 isDirty = true; } 110 111 118 public void setItemId(Integer id) throws RemoteException 119 { 120 itemId = id; 121 isDirty = true; } 123 124 130 public void setQuantity(int Qty) throws RemoteException 131 { 132 qty = Qty; 133 isDirty = true; } 135 136 142 public void setDate(String newDate) throws RemoteException 143 { 144 date = newDate; 145 isDirty = true; } 147 148 149 162 public BuyNowPK ejbCreate(Integer BuyNowUserId, Integer BuyNowItemId, int quantity) throws CreateException, RemoteException, RemoveException 163 { 164 IDManagerHome home = null; 166 IDManager idManager = null; 167 168 try 169 { 170 InitialContext initialContext = new InitialContext (); 171 home = (IDManagerHome)PortableRemoteObject.narrow(initialContext.lookup( 172 "java:comp/env/ejb/IDManager"), IDManagerHome.class); 173 } 174 catch (Exception e) 175 { 176 throw new EJBException("Cannot lookup IDManager: " +e); 177 } 178 try 179 { 180 IDManagerPK idPK = new IDManagerPK(); 181 idManager = home.findByPrimaryKey(idPK); 182 id = idManager.getNextBuyNowID(); 183 buyerId = BuyNowUserId; 184 itemId = BuyNowItemId; 185 qty = quantity; 186 date = TimeManagement.currentDateToString(); 187 } 188 catch (Exception e) 189 { 190 throw new EJBException("Cannot create buyNow: " +e); 191 } 192 return null; 193 } 194 195 197 public void ejbPostCreate(Integer BuyNowUserId, Integer BuyNowItemId, int quantity) 198 { 199 isDirty = true; } 201 202 204 public void ejbLoad() throws RemoteException 205 { 206 isDirty = false; 207 } 208 209 211 public void ejbStore() throws RemoteException 212 { 213 isDirty = false; 214 } 215 216 217 public void ejbActivate() throws RemoteException {} 218 219 public void ejbPassivate() throws RemoteException {} 220 221 public void ejbRemove() throws RemoteException, RemoveException {} 222 223 240 public void setEntityContext(EntityContext context) throws RemoteException 241 { 242 entityContext = context; 243 } 244 245 262 public void unsetEntityContext() throws RemoteException 263 { 264 entityContext = null; 265 } 266 267 274 public boolean isModified() 275 { 276 return isDirty; 277 } 278 } 279 | Popular Tags |