KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtests > beans > fbasic > PersonEC2


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id:
23  * --------------------------------------------------------------------------
24  */

25
26 /**
27  * This is an entity bean with "container managed persistence version 2.x".
28  * This bean is used to test an entity with an unknown primary key class at the development phase.
29  * @author Helene Joanin
30  */

31
32 package org.objectweb.jonas.jtests.beans.fbasic;
33
34 import java.rmi.RemoteException JavaDoc;
35 import java.sql.Connection JavaDoc;
36 import java.sql.PreparedStatement JavaDoc;
37 import java.sql.ResultSet JavaDoc;
38 import java.sql.SQLException JavaDoc;
39 import java.sql.Statement JavaDoc;
40 import java.util.Collection JavaDoc;
41 import java.util.Vector JavaDoc;
42 import javax.ejb.CreateException JavaDoc;
43 import javax.ejb.DuplicateKeyException JavaDoc;
44 import javax.ejb.EJBObject JavaDoc;
45 import javax.ejb.EJBException JavaDoc;
46 import javax.ejb.EntityBean JavaDoc;
47 import javax.ejb.EntityContext JavaDoc;
48 import javax.ejb.FinderException JavaDoc;
49 import javax.ejb.ObjectNotFoundException JavaDoc;
50 import javax.ejb.RemoveException JavaDoc;
51 import javax.naming.Context JavaDoc;
52 import javax.naming.InitialContext JavaDoc;
53 import javax.naming.NamingException JavaDoc;
54 import javax.sql.DataSource JavaDoc;
55 import javax.transaction.NotSupportedException JavaDoc;
56 import javax.transaction.Status JavaDoc;
57 import javax.transaction.SystemException JavaDoc;
58 import javax.transaction.UserTransaction JavaDoc;
59
60
61
62 /**
63  *
64  */

65 public abstract class PersonEC2 implements EntityBean JavaDoc {
66
67
68     EntityContext JavaDoc ejbContext;
69
70     // ------------------------------------------------------------------
71
// Get and Set accessor methods of the bean's abstract schema
72
// ------------------------------------------------------------------
73
public abstract Integer JavaDoc getNumber();
74     public abstract void setNumber(Integer JavaDoc num);
75
76     public abstract String JavaDoc getName();
77     public abstract void setName(String JavaDoc name);
78
79     // ------------------------------------------------------------------
80
// EntityBean implementation
81
// ------------------------------------------------------------------
82

83     /**
84      * Set the associated entity context. The container invokes this method
85      * on an instance after the instance has been created.
86      * This method is called in an unspecified transaction context.
87      *
88      * @param ctx - An EntityContext interface for the instance. The instance
89      * should store the reference to the context in an instance variable.
90      * @throws EJBException Thrown by the method to indicate a failure caused by a
91      * system-level error.
92      */

93     public void setEntityContext(EntityContext JavaDoc ctx) {
94        
95     ejbContext = ctx;
96     }
97
98     /**
99      * Unset the associated entity context. The container calls this method
100      * before removing the instance.
101      * This is the last method that the container invokes on the instance.
102      * The Java garbage collector will eventually invoke the finalize() method
103      * on the instance.
104      * This method is called in an unspecified transaction context.
105      *
106      * @throws EJBException Thrown by the method to indicate a failure caused by a
107      * system-level error.
108      */

109     public void unsetEntityContext() {
110     
111     ejbContext = null;
112     }
113
114     /**
115      * A container invokes this method before it removes the EJB object
116      * that is currently associated with the instance. This method is
117      * invoked when a client invokes a remove operation on the enterprise Bean's
118      * home interface or the EJB object's remote interface. This method
119      * transitions the instance from the ready state to the pool of available
120      * instances.
121      *
122      * This method is called in the transaction context of the remove operation.
123      * @throws RemoveException The enterprise Bean does not allow destruction of the object.
124      * @throws EJBException - Thrown by the method to indicate a failure caused by a system-level
125      * error.
126      */

127     public void ejbRemove() throws RemoveException JavaDoc {
128        
129     }
130
131     /**
132      * A container invokes this method to instruct the instance to synchronize
133      * its state by loading it state from the underlying database.
134      * This method always executes in the proper transaction context.
135      *
136      * @throws EJBException Thrown by the method to indicate a failure caused by
137      * a system-level error.
138      */

139     public void ejbLoad() {
140        
141     }
142
143     /**
144      * A container invokes this method to instruct the instance to synchronize
145      * its state by storing it to the underlying database.
146      * This method always executes in the proper transaction context.
147      *
148      * @throws EJBException Thrown by the method to indicate a failure caused by
149      * a system-level error.
150      */

151     public void ejbStore() {
152       
153     }
154     
155     /**
156      * The Entity bean can define 0 or more ejbCreate methods.
157      *
158      * @throws CreateException Failure to create an entity EJB object.
159      * @throws DuplicateKeyException An object with the same key already exists.
160      */

161     public java.lang.Object JavaDoc ejbCreate(int i, String JavaDoc s) throws CreateException JavaDoc, DuplicateKeyException JavaDoc {
162       
163
164     // Init here the bean fields
165
setNumber(new Integer JavaDoc(i));
166     setName(new String JavaDoc(s));
167
168     // In CMP, should return null.
169
return null;
170     }
171     
172     /**
173      * There must be an ejbPostCreate par ejbCreate method
174      *
175      * @throws CreateException Failure to create an entity EJB object.
176      */

177     public void ejbPostCreate(int i, String JavaDoc s) throws CreateException JavaDoc {
178       
179     }
180
181     /**
182      * A container invokes this method on an instance before the instance
183      * becomes disassociated with a specific EJB object.
184      */

185     public void ejbPassivate() {
186        
187     }
188
189     /**
190      * A container invokes this method when the instance is taken out of
191      * the pool of available instances to become associated with a specific
192      * EJB object.
193      */

194     public void ejbActivate() {
195         
196     }
197     
198     // ------------------------------------------------------------------
199
// Person implementation
200
// ------------------------------------------------------------------
201

202     /**
203      * getNumberPrimitive
204      */

205     public int getNumberPrimitive() {
206        
207     return getNumber().intValue();
208     }
209
210 }
211
Popular Tags