KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtests > beans > relation > dass > P4EC2


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: P4EC2.java,v 1.1 2004/06/22 16:06:08 durieuxp Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.jtests.beans.relation.dass;
27
28 import java.util.Collection JavaDoc;
29 import javax.ejb.CreateException JavaDoc;
30 import javax.ejb.DuplicateKeyException JavaDoc;
31 import javax.ejb.EJBException JavaDoc;
32 import javax.ejb.EntityContext JavaDoc;
33 import javax.ejb.FinderException JavaDoc;
34 import javax.ejb.RemoveException JavaDoc;
35 import javax.naming.Context JavaDoc;
36 import javax.naming.InitialContext JavaDoc;
37 import javax.naming.NamingException 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  * @author Ph Durieux
45  */

46 public abstract class P4EC2 implements javax.ejb.EntityBean JavaDoc {
47
48
49     // ------------------------------------------------------------------
50
// Get and Set accessor methods of the bean's abstract schema
51
// ------------------------------------------------------------------
52
public abstract String JavaDoc getId();
53     public abstract void setId(String JavaDoc id);
54     public abstract String JavaDoc getPf4();
55     public abstract void setPf4(String JavaDoc pf4);
56
57     public abstract Collection JavaDoc getP3();
58     public abstract void setP3(Collection JavaDoc p3);
59
60     // ------------------------------------------------------------------
61
// EntityBean implementation
62
// ------------------------------------------------------------------
63

64     static protected Logger logger = null;
65     EntityContext JavaDoc ejbContext;
66
67     /**
68      * The Entity bean can define 0 or more ejbCreate methods.
69      *
70      * @throws CreateException Failure to create an entity EJB object.
71      * @throws DuplicateKeyException An object with the same key already exists.
72      */

73     public String JavaDoc ejbCreate(String JavaDoc id, String JavaDoc pf4) throws CreateException JavaDoc, DuplicateKeyException JavaDoc {
74         logger.log(BasicLevel.DEBUG, "");
75
76         // Init here the bean fields
77
setId(id);
78         setPf4(pf4);
79
80         // In CMP, should return null.
81
return null;
82     }
83
84     /**
85      * There must be an ejbPostCreate par ejbCreate method
86      *
87      * @throws CreateException Failure to create an entity EJB object.
88      */

89     public void ejbPostCreate(String JavaDoc id, String JavaDoc pf4) throws CreateException JavaDoc {
90         logger.log(BasicLevel.DEBUG, "id=" + id);
91     }
92
93     /**
94      * Set the associated entity context. The container invokes this method
95      * on an instance after the instance has been created.
96      * This method is called in an unspecified transaction context.
97      *
98      * @param ctx - An EntityContext interface for the instance. The instance
99      * should store the reference to the context in an instance variable.
100      * @throws EJBException Thrown by the method to indicate a failure caused by a
101      * system-level error.
102      */

103     public void setEntityContext(EntityContext JavaDoc ctx) {
104         if (logger == null)
105             logger = Log.getLogger(Log.JONAS_TESTS_PREFIX);
106         logger.log(BasicLevel.DEBUG, "");
107         ejbContext = ctx;
108     }
109
110     /**
111      * Unset the associated entity context. The container calls this method
112      * before removing the instance.
113      * This is the last method that the container invokes on the instance.
114      * The Java garbage collector will eventually invoke the finalize() method
115      * on the instance.
116      * This method is called in an unspecified transaction context.
117      *
118      * @throws EJBException Thrown by the method to indicate a failure caused by a
119      * system-level error.
120      */

121     public void unsetEntityContext() {
122         logger.log(BasicLevel.DEBUG, "");
123         ejbContext = null;
124     }
125
126     /**
127      * A container invokes this method before it removes the EJB object
128      * that is currently associated with the instance. This method is
129      * invoked when a client invokes a remove operation on the enterprise Bean's
130      * home interface or the EJB object's remote interface. This method
131      * transitions the instance from the ready state to the pool of available
132      * instances.
133      *
134      * This method is called in the transaction context of the remove operation.
135      * @throws RemoveException The enterprise Bean does not allow destruction of the object.
136      * @throws EJBException - Thrown by the method to indicate a failure caused by a system-level
137      * error.
138      */

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

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

163     public void ejbStore() {
164         logger.log(BasicLevel.DEBUG, "");
165     }
166
167     /**
168      * A container invokes this method on an instance before the instance
169      * becomes disassociated with a specific EJB object.
170      */

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

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