KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtests > beans > relation > mou > 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.2 2002/12/24 13:43:33 durieuxp Exp $
23  * --------------------------------------------------------------------------
24  */

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

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

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

65     public String JavaDoc ejbCreate(String JavaDoc id) throws CreateException JavaDoc, DuplicateKeyException JavaDoc {
66         logger.log(BasicLevel.DEBUG, "");
67
68         // Init here the bean fields
69
setId(id);
70
71         // In CMP, should return null.
72
return null;
73     }
74
75     /**
76      * Set the associated entity context. The container invokes this method
77      * on an instance after the instance has been created.
78      * This method is called in an unspecified transaction context.
79      *
80      * @param ctx - An EntityContext interface for the instance. The instance
81      * should store the reference to the context in an instance variable.
82      * @throws EJBException Thrown by the method to indicate a failure caused by a
83      * system-level error.
84      */

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

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

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

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

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

154     public void ejbPostCreate(String JavaDoc id) throws CreateException JavaDoc {
155         logger.log(BasicLevel.DEBUG, "id=" + id);
156     }
157
158     /**
159      * A container invokes this method on an instance before the instance
160      * becomes disassociated with a specific EJB object.
161      */

162     public void ejbPassivate() {
163         logger.log(BasicLevel.DEBUG, "");
164     }
165
166     /**
167      * A container invokes this method when the instance is taken out of
168      * the pool of available instances to become associated with a specific
169      * EJB object.
170      */

171     public void ejbActivate() {
172         logger.log(BasicLevel.DEBUG, "");
173     }
174
175 }
176
177
Popular Tags