1 37 package com.sun.j2ee.blueprints.opc.purchaseorder.ejb; 38 39 import javax.ejb.*; 40 41 import com.sun.j2ee.blueprints.opc.purchaseorder.*; 42 43 import com.sun.j2ee.blueprints.servicelocator.*; 44 import com.sun.j2ee.blueprints.servicelocator.ejb.*; 45 46 47 51 52 public abstract class ContactInfoBean implements EntityBean { 53 54 private EntityContext entityContext = null; 55 56 public Object ejbCreate(ContactInfo contactInfo) throws CreateException { 57 58 setGivenName(contactInfo.getGivenName()); 59 setFamilyName(contactInfo.getFamilyName()); 60 setPhone(contactInfo.getPhone()); 61 setEmail(contactInfo.getEmail()); 62 63 return null; 64 } 65 66 public void ejbPostCreate(ContactInfo contactInfo) throws CreateException { 67 68 try { 69 ServiceLocator sl = new ServiceLocator(); 70 AddressLocalHome alh = (AddressLocalHome) sl.getLocalHome(JNDINames. 71 ADDR_EJB); 72 AddressLocal address = alh.create(contactInfo.getAddress()); 73 setAddress(address); 74 } 75 catch (ServiceLocatorException se) { 76 throw new CreateException("Exception saving PO:" + 77 se.getMessage()); 78 } 79 } 80 81 public ContactInfo getDetails() { 82 ContactInfo contactInfo = new ContactInfo(); 83 contactInfo.setGivenName(getGivenName()); 84 contactInfo.setFamilyName(getFamilyName()); 85 contactInfo.setPhone(getPhone()); 86 contactInfo.setEmail(getEmail()); 87 contactInfo.setAddress(getAddress().getDetails()); 88 return contactInfo; 89 90 } 91 92 public abstract void setFamilyName(String familyName); 94 95 public abstract void setGivenName(String givenName); 96 97 public abstract void setEmail(String email); 98 99 public abstract void setPhone(String phone); 100 101 public abstract String getFamilyName(); 102 103 public abstract String getGivenName(); 104 105 public abstract String getEmail(); 106 107 public abstract String getPhone(); 108 109 public abstract void setAddress(AddressLocal address); 111 112 public abstract AddressLocal getAddress(); 113 114 115 public void ejbLoad() { 116 } 117 118 public void ejbRemove() throws RemoveException { 119 } 120 121 public void ejbStore() { 122 } 123 124 public void ejbActivate() { 125 } 126 127 public void ejbPassivate() { 128 } 129 130 public void unsetEntityContext() { 131 this.entityContext = null; 132 } 133 134 public void setEntityContext(EntityContext entityContext) { 135 this.entityContext = entityContext; 136 } 137 } 138 | Popular Tags |