KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtests > beans > relatives > RelativeEC2


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: RelativeEC2.java,v 1.4 2004/03/19 11:57:20 benoitf Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 // PersonneEC2.java
27

28 package org.objectweb.jonas.jtests.beans.relatives;
29
30 import java.util.Date JavaDoc;
31 import java.util.Set JavaDoc;
32
33 import javax.ejb.CreateException JavaDoc;
34 import javax.ejb.DuplicateKeyException JavaDoc;
35 import javax.ejb.EntityBean JavaDoc;
36 import javax.ejb.EntityContext JavaDoc;
37 import javax.ejb.RemoveException JavaDoc;
38
39 import org.objectweb.jonas.common.Log;
40 import org.objectweb.util.monolog.api.BasicLevel;
41 import org.objectweb.util.monolog.api.Logger;
42
43 /**
44  * This is an entity bean with "container managed persistence version 2.x".
45  * @author Christophe Ney - cney@batisseurs.com
46  */

47 public abstract class RelativeEC2 implements EntityBean JavaDoc {
48
49     static protected Logger logger = null;
50     EntityContext JavaDoc ejbContext;
51
52     // ------------------------------------------------------------------
53
// Get and Set accessor methods of the bean's abstract schema
54
// ------------------------------------------------------------------
55
public abstract String JavaDoc getFullName();
56
57     public abstract void setFullName(String JavaDoc name);
58
59     public abstract int getLuckyNumber();
60
61     public abstract void setLuckyNumber(int age);
62
63     public abstract Date JavaDoc getBirthdate();
64
65     public abstract void setBirthdate(Date JavaDoc birthdate);
66
67     public abstract RelativeLocal getSpouse();
68
69     public abstract void setSpouse(RelativeLocal spouse);
70
71     public abstract Set JavaDoc getSibblings();
72
73     public abstract void setSibblings(Set JavaDoc sibblings);
74
75     public abstract Set JavaDoc getVisitedRelatives();
76
77     public abstract void setVisitedRelatives(Set JavaDoc sibblings);
78
79     public abstract boolean getIsMale();
80
81     public abstract void setIsMale(boolean isMale);
82
83     public abstract double getAverageAnnualVisits();
84
85     public abstract void setAverageAnnualVisits(double averageAnnualVisits);
86
87     // ------------------------------------------------------------------
88
// EntityBean implementation
89
// ------------------------------------------------------------------
90

91     /**
92      * Set the associated entity context.
93      */

94     public void setEntityContext(EntityContext JavaDoc ctx) {
95         if (logger == null)
96             logger = Log.getLogger(Log.JONAS_TESTS_PREFIX);
97         logger.log(BasicLevel.DEBUG, "");
98         ejbContext = ctx;
99     }
100
101     /**
102      * Unset the associated entity context.
103      */

104     public void unsetEntityContext() {
105         logger.log(BasicLevel.DEBUG, "");
106         ejbContext = null;
107     }
108
109     /**
110      * A container invokes this method before it removes the EJB object
111      * that is currently associated with the instance.
112      */

113     public void ejbRemove() throws RemoveException JavaDoc {
114         logger.log(BasicLevel.DEBUG, "");
115     }
116
117     /**
118      * A container invokes this method to instruct the instance to synchronize
119      * its state by loading it state from the underlying database.
120      */

121     public void ejbLoad() {
122         logger.log(BasicLevel.DEBUG, "");
123     }
124
125     /**
126      * A container invokes this method to instruct the instance to synchronize
127      * its state by storing it to the underlying database.
128      */

129     public void ejbStore() {
130         logger.log(BasicLevel.DEBUG, "");
131     }
132
133     /**
134      * A container invokes this instance before creating the EJBObject
135      */

136     public String JavaDoc ejbCreate(String JavaDoc fullName, Date JavaDoc birthdate, int luckyNumber) throws CreateException JavaDoc, DuplicateKeyException JavaDoc {
137         logger.log(BasicLevel.DEBUG, "");
138
139         setFullName(fullName);
140         setBirthdate(birthdate);
141         setLuckyNumber(luckyNumber);
142
143         // In CMP, should return null.
144
return null;
145     }
146
147     /**
148      * There must be an ejbPostCreate par ejbCreate method
149      *
150      * @throws CreateException Failure to create an entity EJB object.
151      */

152     public void ejbPostCreate(String JavaDoc fullName, Date JavaDoc birthdate, int luckyNumber) throws CreateException JavaDoc {
153         logger.log(BasicLevel.DEBUG, "");
154     }
155
156
157     /**
158      * This method is called before the instance enters the "passive" state.
159      * The instance should release any resources that it can re-acquire later in the
160      * ejbActivate() method.
161      * After the passivate method completes, the instance must be in a state that
162      * allows the container to use the Java Serialization protocol to externalize
163      * and store away the instance's state.
164      * This method is called with no transaction context.
165      *
166      * @exception EJBException - Thrown if the instance could not perform the
167      * function requested by the container
168      */

169     public void ejbPassivate() {
170         logger.log(BasicLevel.DEBUG, "");
171     }
172
173     /**
174      * This method is called when the instance is activated from its "passive" state.
175      * The instance should acquire any resource that it has released earlier in the
176      * ejbPassivate() method.
177      * This method is called with no transaction context.
178      *
179      * @exception EJBException - Thrown if the instance could not perform the
180      * function requested by the container
181      */

182     public void ejbActivate() {
183         logger.log(BasicLevel.DEBUG, "");
184     }
185
186 }
187
Popular Tags