KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtests > beans > fannuaire > PersonneEC2


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: PersonneEC2.java,v 1.1 2003/12/05 14:16:52 legrasi Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 // PersonneEC2.java
27

28 package org.objectweb.jonas.jtests.beans.fannuaire;
29
30 import java.rmi.RemoteException JavaDoc;
31 import java.sql.Connection JavaDoc;
32 import java.sql.SQLException JavaDoc;
33 import java.sql.Statement JavaDoc;
34 import javax.ejb.CreateException JavaDoc;
35 import javax.ejb.DuplicateKeyException JavaDoc;
36 import javax.ejb.EJBException JavaDoc;
37 import javax.ejb.FinderException JavaDoc;
38 import javax.ejb.RemoveException JavaDoc;
39 import javax.ejb.EJBObject JavaDoc;
40 import javax.ejb.EntityBean JavaDoc;
41 import javax.ejb.EntityContext JavaDoc;
42 import javax.naming.Context JavaDoc;
43 import javax.naming.InitialContext JavaDoc;
44 import javax.naming.NamingException JavaDoc;
45 import javax.sql.DataSource JavaDoc;
46 import javax.transaction.NotSupportedException JavaDoc;
47 import javax.transaction.Status JavaDoc;
48 import javax.transaction.SystemException JavaDoc;
49 import javax.transaction.UserTransaction JavaDoc;
50
51
52 /**
53  * This is an entity bean with "container managed persistence version 2.x".
54  * @author Philippe Durieux, Helene Joanin (jonas team)
55  */

56 public abstract class PersonneEC2 implements EntityBean JavaDoc {
57
58     //static protected Logger logger = null;
59
EntityContext JavaDoc ejbContext;
60
61     // ------------------------------------------------------------------
62
// Get and Set accessor methods of the bean's abstract schema
63
// ------------------------------------------------------------------
64
public abstract String JavaDoc getNom();
65     public abstract void setNom(String JavaDoc n);
66
67     public abstract String JavaDoc getNumero(); // Tx Attribute = Required
68
public abstract void setNumero(String JavaDoc n); // Tx Attribute = Required
69

70     // ------------------------------------------------------------------
71
// EntityBean implementation
72
// ------------------------------------------------------------------
73

74     /**
75      * Set the associated entity context. The container invokes this method
76      * on an instance after the instance has been created.
77      * This method is called in an unspecified transaction context.
78      *
79      * @param ctx - An EntityContext interface for the instance. The instance
80      * should store the reference to the context in an instance variable.
81      * @throws EJBException Thrown by the method to indicate a failure caused by a
82      * system-level error.
83      */

84     public void setEntityContext(EntityContext JavaDoc ctx) {
85         //if (logger == null)
86
// logger = Log.getLogger(Log.JONAS_TESTS_PREFIX);
87
// logger.log(BasicLevel.DEBUG, "");
88
ejbContext = ctx;
89     }
90
91     /**
92      * Unset the associated entity context. The container calls this method
93      * before removing the instance.
94      * This is the last method that the container invokes on the instance.
95      * The Java garbage collector will eventually invoke the finalize() method
96      * on the instance.
97      * This method is called in an unspecified transaction context.
98      *
99      * @throws EJBException Thrown by the method to indicate a failure caused by a
100      * system-level error.
101      */

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

120     public void ejbRemove() throws RemoveException JavaDoc {
121         // logger.log(BasicLevel.DEBUG, "");
122
}
123
124     /**
125      * A container invokes this method to instruct the instance to synchronize
126      * its state by loading it state from the underlying database.
127      * This method always executes in the proper transaction context.
128      *
129      * @throws EJBException Thrown by the method to indicate a failure caused by
130      * a system-level error.
131      */

132     public void ejbLoad() {
133         //logger.log(BasicLevel.DEBUG, "");
134
}
135
136     /**
137      * A container invokes this method to instruct the instance to synchronize
138      * its state by storing it to the underlying database.
139      * This method always executes in the proper transaction context.
140      *
141      * @throws EJBException Thrown by the method to indicate a failure caused by
142      * a system-level error.
143      */

144     public void ejbStore() {
145         //logger.log(BasicLevel.DEBUG, "");
146
}
147         
148     /**
149      * There must be an ejbPostCreate par ejbCreate method
150      *
151      * @throws CreateException Failure to create an entity EJB object.
152      */

153     public void ejbPostCreate(String JavaDoc nom, String JavaDoc numero) throws CreateException JavaDoc {
154         // logger.log(BasicLevel.DEBUG, "");
155
}
156     public void ejbPostCreate(String JavaDoc nom, String JavaDoc numero, boolean t) throws CreateException JavaDoc {
157         //logger.log(BasicLevel.DEBUG, "");
158
}
159         
160
161     public java.lang.String JavaDoc ejbCreate(String JavaDoc nom, String JavaDoc numero) throws CreateException JavaDoc, DuplicateKeyException JavaDoc {
162         //logger.log(BasicLevel.DEBUG, "ejbCreate(" + nom + ", " + numero + ")");
163

164         // Init here the bean fields
165
setNom(nom);
166         setNumero(numero);
167
168         // In CMP, should return null.
169
return null;
170     }
171
172     public java.lang.String JavaDoc ejbCreate(String JavaDoc nom, String JavaDoc numero, boolean t) throws CreateException JavaDoc, DuplicateKeyException JavaDoc {
173         // logger.log(BasicLevel.DEBUG, "ejbCreate nom numero boolean");
174

175         // Init here the bean fields
176
setNom(nom);
177         setNumero(numero);
178
179         // In CMP, should return null.
180
return null;
181     }
182
183     /**
184      * This method is called before the instance enters the "passive" state.
185      * The instance should release any resources that it can re-acquire later in the
186      * ejbActivate() method.
187      * After the passivate method completes, the instance must be in a state that
188      * allows the container to use the Java Serialization protocol to externalize
189      * and store away the instance's state.
190      * This method is called with no transaction context.
191      *
192      * @exception EJBException - Thrown if the instance could not perform the
193      * function requested by the container
194      */

195     public void ejbPassivate() {
196         //logger.log(BasicLevel.DEBUG, "");
197
}
198
199     /**
200      * This method is called when the instance is activated from its "passive" state.
201      * The instance should acquire any resource that it has released earlier in the
202      * ejbPassivate() method.
203      * This method is called with no transaction context.
204      *
205      * @exception EJBException - Thrown if the instance could not perform the
206      * function requested by the container
207      */

208     public void ejbActivate() {
209         // logger.log(BasicLevel.DEBUG, "");
210
}
211     
212     // ------------------------------------------------------------------
213
// Personne implementation
214
// ------------------------------------------------------------------
215

216     /**
217      * getNumeroNTX / Tx Attribute = Supports
218      */

219     public String JavaDoc getNumeroNTX() {
220         // logger.log(BasicLevel.DEBUG, "");
221
return getNumero();
222     }
223
224     /**
225      * setNumeroNTX / Tx Attribute = Supports
226      */

227     public void setNumeroNTX(String JavaDoc s) {
228         //ogger.log(BasicLevel.DEBUG, "");
229
setNumero(s);
230     }
231
232     //
233
// Methods only implemented in the entity bean with "CMP version 1.x"
234
// used to test the isModified extension for CMP version 1 Entity Bean.
235
// (defined here to have a common interface)
236
//
237

238     public boolean isModified() {
239         throw new UnsupportedOperationException JavaDoc();
240     }
241
242     public void reset() {
243         throw new UnsupportedOperationException JavaDoc();
244     }
245
246     public boolean isModifiedCalled() {
247         throw new UnsupportedOperationException JavaDoc();
248     }
249
250     public boolean ejbStoreCalled() {
251         throw new UnsupportedOperationException JavaDoc();
252     }
253
254     public boolean isDirty() {
255         throw new UnsupportedOperationException JavaDoc();
256     }
257
258         
259 }
260
Popular Tags