KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > j2ee > blueprints > opc > purchaseorder > ejb > ContactInfoBean


1 /*
2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * - Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * - Redistribution in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * Neither the name of Sun Microsystems, Inc. or the names of
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * This software is provided "AS IS," without a warranty of any
21 * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
22 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
24 * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
25 * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
26 * DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
27 * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
28 * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
29 * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
30 * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE,
31 * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32 *
33 * You acknowledge that Software is not designed, licensed or intended
34 * for use in the design, construction, operation or maintenance of
35 * any nuclear facility.
36 */

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 /**
48  * Implementation class for the ContactInfoBean .
49  * ContactInfoBean is a CMP Entity Bean .
50  **/

51
52 public abstract class ContactInfoBean implements EntityBean {
53
54   private EntityContext entityContext = null;
55
56   public Object JavaDoc 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   //getters and setters for CMP fields
93
public abstract void setFamilyName(String JavaDoc familyName);
94
95   public abstract void setGivenName(String JavaDoc givenName);
96
97   public abstract void setEmail(String JavaDoc email);
98
99   public abstract void setPhone(String JavaDoc phone);
100
101   public abstract String JavaDoc getFamilyName();
102
103   public abstract String JavaDoc getGivenName();
104
105   public abstract String JavaDoc getEmail();
106
107   public abstract String JavaDoc getPhone();
108
109   //getters and setters for CMR fields
110
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