001: /*
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: PersonneEC2.java 3845 2003-12-05 14:19:55Z legrasi $
023: * --------------------------------------------------------------------------
024: */
025:
026: // PersonneEC2.java
027: package org.objectweb.jonas.jtests.beans.fannuaire;
028:
029: import java.rmi.RemoteException;
030: import java.sql.Connection;
031: import java.sql.SQLException;
032: import java.sql.Statement;
033: import javax.ejb.CreateException;
034: import javax.ejb.DuplicateKeyException;
035: import javax.ejb.EJBException;
036: import javax.ejb.FinderException;
037: import javax.ejb.RemoveException;
038: import javax.ejb.EJBObject;
039: import javax.ejb.EntityBean;
040: import javax.ejb.EntityContext;
041: import javax.naming.Context;
042: import javax.naming.InitialContext;
043: import javax.naming.NamingException;
044: import javax.sql.DataSource;
045: import javax.transaction.NotSupportedException;
046: import javax.transaction.Status;
047: import javax.transaction.SystemException;
048: import javax.transaction.UserTransaction;
049:
050: /**
051: * This is an entity bean with "container managed persistence version 2.x".
052: * @author Philippe Durieux, Helene Joanin (jonas team)
053: */
054: public abstract class PersonneEC2 implements EntityBean {
055:
056: //static protected Logger logger = null;
057: EntityContext ejbContext;
058:
059: // ------------------------------------------------------------------
060: // Get and Set accessor methods of the bean's abstract schema
061: // ------------------------------------------------------------------
062: public abstract String getNom();
063:
064: public abstract void setNom(String n);
065:
066: public abstract String getNumero(); // Tx Attribute = Required
067:
068: public abstract void setNumero(String n); // Tx Attribute = Required
069:
070: // ------------------------------------------------------------------
071: // EntityBean implementation
072: // ------------------------------------------------------------------
073:
074: /**
075: * Set the associated entity context. The container invokes this method
076: * on an instance after the instance has been created.
077: * This method is called in an unspecified transaction context.
078: *
079: * @param ctx - An EntityContext interface for the instance. The instance
080: * should store the reference to the context in an instance variable.
081: * @throws EJBException Thrown by the method to indicate a failure caused by a
082: * system-level error.
083: */
084: public void setEntityContext(EntityContext ctx) {
085: //if (logger == null)
086: // logger = Log.getLogger(Log.JONAS_TESTS_PREFIX);
087: // logger.log(BasicLevel.DEBUG, "");
088: ejbContext = ctx;
089: }
090:
091: /**
092: * Unset the associated entity context. The container calls this method
093: * before removing the instance.
094: * This is the last method that the container invokes on the instance.
095: * The Java garbage collector will eventually invoke the finalize() method
096: * on the instance.
097: * This method is called in an unspecified transaction context.
098: *
099: * @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: /**
108: * A container invokes this method before it removes the EJB object
109: * that is currently associated with the instance. This method is
110: * invoked when a client invokes a remove operation on the enterprise Bean's
111: * home interface or the EJB object's remote interface. This method
112: * transitions the instance from the ready state to the pool of available
113: * instances.
114: *
115: * This method is called in the transaction context of the remove operation.
116: * @throws RemoveException The enterprise Bean does not allow destruction of the object.
117: * @throws EJBException - Thrown by the method to indicate a failure caused by a system-level
118: * error.
119: */
120: public void ejbRemove() throws RemoveException {
121: // logger.log(BasicLevel.DEBUG, "");
122: }
123:
124: /**
125: * A container invokes this method to instruct the instance to synchronize
126: * its state by loading it state from the underlying database.
127: * This method always executes in the proper transaction context.
128: *
129: * @throws EJBException Thrown by the method to indicate a failure caused by
130: * a system-level error.
131: */
132: public void ejbLoad() {
133: //logger.log(BasicLevel.DEBUG, "");
134: }
135:
136: /**
137: * A container invokes this method to instruct the instance to synchronize
138: * its state by storing it to the underlying database.
139: * This method always executes in the proper transaction context.
140: *
141: * @throws EJBException Thrown by the method to indicate a failure caused by
142: * a system-level error.
143: */
144: public void ejbStore() {
145: //logger.log(BasicLevel.DEBUG, "");
146: }
147:
148: /**
149: * There must be an ejbPostCreate par ejbCreate method
150: *
151: * @throws CreateException Failure to create an entity EJB object.
152: */
153: public void ejbPostCreate(String nom, String numero)
154: throws CreateException {
155: // logger.log(BasicLevel.DEBUG, "");
156: }
157:
158: public void ejbPostCreate(String nom, String numero, boolean t)
159: throws CreateException {
160: //logger.log(BasicLevel.DEBUG, "");
161: }
162:
163: public java.lang.String ejbCreate(String nom, String numero)
164: throws CreateException, DuplicateKeyException {
165: //logger.log(BasicLevel.DEBUG, "ejbCreate(" + nom + ", " + numero + ")");
166:
167: // Init here the bean fields
168: setNom(nom);
169: setNumero(numero);
170:
171: // In CMP, should return null.
172: return null;
173: }
174:
175: public java.lang.String ejbCreate(String nom, String numero,
176: boolean t) throws CreateException, DuplicateKeyException {
177: // logger.log(BasicLevel.DEBUG, "ejbCreate nom numero boolean");
178:
179: // Init here the bean fields
180: setNom(nom);
181: setNumero(numero);
182:
183: // In CMP, should return null.
184: return null;
185: }
186:
187: /**
188: * This method is called before the instance enters the "passive" state.
189: * The instance should release any resources that it can re-acquire later in the
190: * ejbActivate() method.
191: * After the passivate method completes, the instance must be in a state that
192: * allows the container to use the Java Serialization protocol to externalize
193: * and store away the instance's state.
194: * This method is called with no transaction context.
195: *
196: * @exception EJBException - Thrown if the instance could not perform the
197: * function requested by the container
198: */
199: public void ejbPassivate() {
200: //logger.log(BasicLevel.DEBUG, "");
201: }
202:
203: /**
204: * This method is called when the instance is activated from its "passive" state.
205: * The instance should acquire any resource that it has released earlier in the
206: * ejbPassivate() method.
207: * This method is called with no transaction context.
208: *
209: * @exception EJBException - Thrown if the instance could not perform the
210: * function requested by the container
211: */
212: public void ejbActivate() {
213: // logger.log(BasicLevel.DEBUG, "");
214: }
215:
216: // ------------------------------------------------------------------
217: // Personne implementation
218: // ------------------------------------------------------------------
219:
220: /**
221: * getNumeroNTX / Tx Attribute = Supports
222: */
223: public String getNumeroNTX() {
224: // logger.log(BasicLevel.DEBUG, "");
225: return getNumero();
226: }
227:
228: /**
229: * setNumeroNTX / Tx Attribute = Supports
230: */
231: public void setNumeroNTX(String s) {
232: //ogger.log(BasicLevel.DEBUG, "");
233: setNumero(s);
234: }
235:
236: //
237: // Methods only implemented in the entity bean with "CMP version 1.x"
238: // used to test the isModified extension for CMP version 1 Entity Bean.
239: // (defined here to have a common interface)
240: //
241:
242: public boolean isModified() {
243: throw new UnsupportedOperationException();
244: }
245:
246: public void reset() {
247: throw new UnsupportedOperationException();
248: }
249:
250: public boolean isModifiedCalled() {
251: throw new UnsupportedOperationException();
252: }
253:
254: public boolean ejbStoreCalled() {
255: throw new UnsupportedOperationException();
256: }
257:
258: public boolean isDirty() {
259: throw new UnsupportedOperationException();
260: }
261:
262: }
|