KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtests > beans > relation > oob > BEC2


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: BEC2.java,v 1.3 2003/07/11 08:48:20 durieuxp Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.jtests.beans.relation.oob;
27
28 import org.objectweb.util.monolog.api.Logger;
29 import org.objectweb.util.monolog.api.BasicLevel;
30 import org.objectweb.jonas.common.Log;
31
32 import javax.ejb.EntityContext JavaDoc;
33 import javax.ejb.CreateException JavaDoc;
34 import javax.ejb.DuplicateKeyException JavaDoc;
35 import javax.ejb.RemoveException JavaDoc;
36
37 /**
38  * @author S.Chassande-Barrioz
39  */

40 public abstract class BEC2 implements javax.ejb.EntityBean JavaDoc {
41     public void m1(){
42     }
43
44     // ------------------------------------------------------------------
45
// Get and Set accessor methods of the bean's abstract schema
46
// ------------------------------------------------------------------
47
public abstract String JavaDoc getId();
48
49     public abstract void setId(String JavaDoc id);
50
51     // ------------------------------------------------------------------
52
// EntityBean implementation
53
// ------------------------------------------------------------------
54

55     static protected Logger logger = null;
56     EntityContext JavaDoc ejbContext;
57
58     /**
59      * The Entity bean can define 0 or more ejbCreate methods.
60      *
61      * @throws CreateException Failure to create an entity EJB object.
62      * @throws DuplicateKeyException An object with the same key already exists.
63      */

64     public String JavaDoc ejbCreate(String JavaDoc id) throws CreateException JavaDoc, DuplicateKeyException JavaDoc {
65         logger.log(BasicLevel.DEBUG, "");
66
67         // Init here the bean fields
68
setId(id);
69
70         // In CMP, should return null.
71
return null;
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     public abstract ALocal getA();
108     public abstract void setA(ALocal al);
109
110     public abstract ALocal getABis();
111     public abstract void setABis(ALocal al);
112
113     public String JavaDoc retrieveA() {
114       ALocal lejbA = getA();
115       if (lejbA==null)
116       return null;
117       else
118           return lejbA.getId();
119     }
120
121     public String JavaDoc retrieveAInNewTx() {
122         return retrieveA();
123     }
124
125     /**
126      * A container invokes this method before it removes the EJB object
127      * that is currently associated with the instance. This method is
128      * invoked when a client invokes a remove operation on the enterprise Bean's
129      * home interface or the EJB object's remote interface. This method
130      * transitions the instance from the ready state to the pool of available
131      * instances.
132      *
133      * This method is called in the transaction context of the remove operation.
134      * @throws RemoveException The enterprise Bean does not allow destruction of the object.
135      * @throws EJBException - Thrown by the method to indicate a failure caused by a system-level
136      * error.
137      */

138     public void ejbRemove() throws RemoveException JavaDoc {
139         logger.log(BasicLevel.DEBUG, "");
140     }
141
142     /**
143      * A container invokes this method to instruct the instance to synchronize
144      * its state by loading it state from the underlying database.
145      * This method always executes in the proper transaction context.
146      *
147      * @throws EJBException Thrown by the method to indicate a failure caused by
148      * a system-level error.
149      */

150     public void ejbLoad() {
151         logger.log(BasicLevel.DEBUG, "");
152     }
153
154     /**
155      * A container invokes this method to instruct the instance to synchronize
156      * its state by storing it to the underlying database.
157      * This method always executes in the proper transaction context.
158      *
159      * @throws EJBException Thrown by the method to indicate a failure caused by
160      * a system-level error.
161      */

162     public void ejbStore() {
163         logger.log(BasicLevel.DEBUG, "");
164     }
165
166     /**
167      * There must be an ejbPostCreate par ejbCreate method
168      *
169      * @throws CreateException Failure to create an entity EJB object.
170      */

171     public void ejbPostCreate(String JavaDoc id) throws CreateException JavaDoc {
172         logger.log(BasicLevel.DEBUG, "id=" + id);
173     }
174
175     /**
176      * A container invokes this method on an instance before the instance
177      * becomes disassociated with a specific EJB object.
178      */

179     public void ejbPassivate() {
180         logger.log(BasicLevel.DEBUG, "");
181     }
182
183     /**
184      * A container invokes this method when the instance is taken out of
185      * the pool of available instances to become associated with a specific
186      * EJB object.
187      */

188     public void ejbActivate() {
189         logger.log(BasicLevel.DEBUG, "");
190     }
191
192 }
193
194
Popular Tags