1 37 38 package com.sun.j2ee.blueprints.customer.account.ejb; 39 40 import javax.ejb.EntityContext; 41 import javax.ejb.RemoveException; 42 import javax.ejb.CreateException; 43 import javax.naming.NamingException; 44 import javax.naming.InitialContext; 45 46 import com.sun.j2ee.blueprints.contactinfo.ejb.ContactInfoLocal; 47 import com.sun.j2ee.blueprints.contactinfo.ejb.ContactInfoLocalHome; 48 import com.sun.j2ee.blueprints.creditcard.ejb.CreditCardLocal; 49 import com.sun.j2ee.blueprints.creditcard.ejb.CreditCardLocalHome; 50 51 public abstract class AccountEJB implements javax.ejb.EntityBean { 52 53 private EntityContext context = null; 54 55 public abstract String getStatus(); 58 public abstract void setStatus(String status); 59 60 public abstract ContactInfoLocal getContactInfo(); 63 public abstract void setContactInfo(ContactInfoLocal contactInfo); 64 65 public abstract CreditCardLocal getCreditCard(); 66 public abstract void setCreditCard(CreditCardLocal creditCard); 67 68 public Object ejbCreate(String status, ContactInfoLocal contactInfo, CreditCardLocal creditCard) throws CreateException { 71 setStatus(status); 72 return null; 73 } 74 75 public Object ejbCreate(String status) throws CreateException { 76 setStatus(status); 77 return null; 78 } 79 80 public void ejbPostCreate(String status) throws CreateException { 81 setStatus(status); 82 try { 83 InitialContext ic = new InitialContext(); 84 ContactInfoLocalHome cih = (ContactInfoLocalHome) ic.lookup("java:comp/env/ejb/ContactInfo"); 85 ContactInfoLocal contactInfo = cih.create(); 86 setContactInfo(contactInfo); 87 CreditCardLocalHome cch = (CreditCardLocalHome) ic.lookup("java:comp/env/ejb/CreditCard"); 88 CreditCardLocal creditCard = cch.create(); 89 setCreditCard(creditCard); 90 } catch (javax.naming.NamingException ne) { 91 throw new CreateException("ContactInfoEJB error: naming exception looking up contact info or credit card"); 92 } 93 94 } 95 96 public void ejbPostCreate(String status, ContactInfoLocal contactInfo, CreditCardLocal creditCard) throws CreateException { 97 setContactInfo(contactInfo); 98 setCreditCard(creditCard); 99 } 100 101 102 public void setEntityContext(EntityContext c) { 105 context = c; 106 } 107 public void unsetEntityContext() { 108 context = null; 109 } 110 public void ejbRemove() throws RemoveException { } 111 public void ejbActivate() { } 112 public void ejbPassivate() { } 113 public void ejbStore() { } 114 public void ejbLoad() { } 115 } 116 | Popular Tags |