KickJava   Java API By Example, From Geeks To Geeks.

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


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

25
26 package org.objectweb.jonas.jtests.beans.relation.dass;
27
28 import javax.ejb.CreateException JavaDoc;
29 import javax.ejb.DuplicateKeyException JavaDoc;
30 import javax.ejb.EJBException JavaDoc;
31 import javax.ejb.EntityContext JavaDoc;
32 import javax.ejb.FinderException JavaDoc;
33 import javax.ejb.RemoveException JavaDoc;
34 import javax.naming.Context JavaDoc;
35 import javax.naming.InitialContext JavaDoc;
36 import javax.naming.NamingException JavaDoc;
37
38 import org.objectweb.jonas.common.Log;
39 import org.objectweb.util.monolog.api.BasicLevel;
40 import org.objectweb.util.monolog.api.Logger;
41
42 /**
43  * @author Ph Durieux
44  */

45 public abstract class P1EC2 implements javax.ejb.EntityBean JavaDoc {
46
47
48     // ------------------------------------------------------------------
49
// Get and Set accessor methods of the bean's abstract schema
50
// ------------------------------------------------------------------
51
public abstract String JavaDoc getId();
52     public abstract void setId(String JavaDoc id);
53     public abstract String JavaDoc getPf1();
54     public abstract void setPf1(String JavaDoc pf1);
55
56     // ------------------------------------------------------------------
57
// EntityBean implementation
58
// ------------------------------------------------------------------
59

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

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

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

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

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

138     public void ejbLoad() {
139         logger.log(BasicLevel.DEBUG, "");
140     }
141
142     /**
143      * A container invokes this method to instruct the instance to synchronize
144      * its state by storing it to 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 ejbStore() {
151         logger.log(BasicLevel.DEBUG, "");
152     }
153
154     /**
155      * There must be an ejbPostCreate par ejbCreate method
156      *
157      * @throws CreateException Failure to create an entity EJB object.
158      */

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

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

176     public void ejbActivate() {
177         logger.log(BasicLevel.DEBUG, "");
178     }
179
180 }
181
Popular Tags