KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > j2ee > blueprints > address > ejb > AddressEJB


1 /*
2  * Copyright 2002 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
38 package com.sun.j2ee.blueprints.address.ejb;
39
40 import javax.ejb.EntityBean;
41 import javax.ejb.EntityContext;
42 import javax.ejb.RemoveException;
43 import javax.ejb.CreateException;
44 import javax.naming.NamingException;
45 import javax.naming.InitialContext;
46
47 public abstract class AddressEJB implements EntityBean {
48
49   private EntityContext context = null;
50
51   // getters and setters for CMP fields
52
//====================================
53
public abstract String getStreetName1();
54   public abstract void setStreetName1(String streetName1);
55
56   public abstract String getStreetName2();
57   public abstract void setStreetName2(String streetName2);
58
59   public abstract String getCity();
60   public abstract void setCity(String city);
61
62   public abstract String getState();
63   public abstract void setState(String state);
64
65   public abstract String getZipCode();
66   public abstract void setZipCode(String zipCode);
67
68   public abstract String getCountry();
69   public abstract void setCountry(String country);
70
71   // EJB create method
72
//===================
73
public Object ejbCreate(String streetName1, String streetName2, String city,
74                           String state, String zipCode, String country) throws CreateException {
75                             setStreetName1(streetName1);
76                             setStreetName2(streetName2);
77                             setCity(city);
78                             setState(state);
79                             setZipCode(zipCode);
80                             setCountry(country);
81                             return null;
82   }
83
84   public void ejbPostCreate(String streetName1, String streetName2, String city,
85                             String state, String zipCode, String country) throws CreateException { }
86
87   public Object ejbCreate(Address address) throws CreateException {
88     setStreetName1(address.getStreetName1());
89     setStreetName2(address.getStreetName2());
90     setCity(address.getCity());
91     setState(address.getState());
92     setZipCode(address.getZipCode());
93     setCountry(address.getCountry());
94     return null;
95   }
96
97   public void ejbPostCreate(Address address) throws CreateException { }
98
99   public Object ejbCreate() throws CreateException {
100     return null;
101   }
102
103   public void ejbPostCreate() throws CreateException { }
104
105   public Address getData() {
106     Address address = new Address();
107     address.setStreetName1(getStreetName1());
108     address.setStreetName2(getStreetName2());
109     address.setCity(getCity());
110     address.setState(getState());
111     address.setZipCode(getZipCode());
112     address.setCountry(getCountry());
113     return address;
114   }
115
116   // Misc Method
117
//=============
118
public void setEntityContext(EntityContext c) {
119     context = c;
120   }
121
122   public void unsetEntityContext() {
123     context = null;
124   }
125
126   public void ejbRemove() throws RemoveException { }
127   public void ejbActivate() { }
128   public void ejbPassivate() { }
129   public void ejbStore() { }
130   public void ejbLoad() { }
131 }
132
Popular Tags