KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > stests > manyops > ProductEC2


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

25
26 // ProductEC2.java
27

28 package org.objectweb.jonas.stests.manyops;
29
30 import javax.ejb.CreateException JavaDoc;
31 import javax.ejb.DuplicateKeyException JavaDoc;
32 import javax.ejb.EntityBean JavaDoc;
33 import javax.ejb.EntityContext JavaDoc;
34 import javax.ejb.RemoveException JavaDoc;
35
36 import org.objectweb.jonas.common.Log;
37 import org.objectweb.util.monolog.api.BasicLevel;
38 import org.objectweb.util.monolog.api.Logger;
39
40
41 /**
42  * This is an entity bean with "container managed persistence version 2.x".
43  * @author Helene Joanin (jonas team)
44  */

45 public abstract class ProductEC2 implements EntityBean JavaDoc {
46
47     static protected Logger logger = null;
48     EntityContext JavaDoc ejbContext;
49
50     // ------------------------------------------------------------------
51
// Get and Set accessor methods of the bean's abstract schema
52
// ------------------------------------------------------------------
53
public abstract String JavaDoc getName();
54     public abstract void setName(String JavaDoc n);
55     public abstract int getNumber();
56     public abstract void setNumber(int n);
57     public abstract int getPrice();
58     public abstract void setPrice(int n);
59
60     // ------------------------------------------------------------------
61
// EntityBean implementation
62
// ------------------------------------------------------------------
63

64     /**
65      * Set the associated entity context. The container invokes this method
66      * on an instance after the instance has been created.
67      * This method is called in an unspecified transaction context.
68      *
69      * @param ctx - An EntityContext interface for the instance. The instance
70      * should store the reference to the context in an instance variable.
71      * @throws EJBException Thrown by the method to indicate a failure caused by a
72      * system-level error.
73      */

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

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

111     public void ejbRemove() throws RemoveException JavaDoc {
112     logger.log(BasicLevel.DEBUG, "");
113     }
114
115     /**
116      * A container invokes this method to instruct the instance to synchronize
117      * its state by loading it state from the underlying database.
118      * This method always executes in the proper transaction context.
119      *
120      * @throws EJBException Thrown by the method to indicate a failure caused by
121      * a system-level error.
122      */

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

135     public void ejbStore() {
136     logger.log(BasicLevel.DEBUG, "");
137     }
138     
139     /**
140      * There must be an ejbPostCreate par ejbCreate method
141      *
142      * @throws CreateException Failure to create an entity EJB object.
143      */

144     public void ejbPostCreate(String JavaDoc n, int nb, int p) throws CreateException JavaDoc {
145     logger.log(BasicLevel.DEBUG, "");
146     }
147     
148     /**
149      * The Entity bean can define 0 or more ejbCreate methods.
150      *
151      * @throws CreateException Failure to create an entity EJB object.
152      * @throws DuplicateKeyException An object with the same key already exists.
153      */

154     public java.lang.String JavaDoc ejbCreate(String JavaDoc n, int nb, int p) throws CreateException JavaDoc, DuplicateKeyException JavaDoc {
155     logger.log(BasicLevel.DEBUG, "");
156
157     // Init here the bean fields
158
setName(n);
159     setNumber(nb);
160     setPrice(p);
161
162     // In CMP, should return null.
163
return null;
164     }
165
166     /**
167      * A container invokes this method on an instance before the instance
168      * becomes disassociated with a specific EJB object.
169      */

170     public void ejbPassivate() {
171     logger.log(BasicLevel.DEBUG, "");
172     }
173
174     /**
175      * A container invokes this method when the instance is taken out of
176      * the pool of available instances to become associated with a specific
177      * EJB object.
178      */

179     public void ejbActivate() {
180     logger.log(BasicLevel.DEBUG, "");
181     }
182     
183     // ------------------------------------------------------------------
184
// Product implementation
185
// ------------------------------------------------------------------
186

187 }
188
Popular Tags