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: P4EC2.java 4984 2004-06-22 16:06:08Z durieuxp $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.jtests.beans.relation.dass;
027:
028: import java.util.Collection;
029: import javax.ejb.CreateException;
030: import javax.ejb.DuplicateKeyException;
031: import javax.ejb.EJBException;
032: import javax.ejb.EntityContext;
033: import javax.ejb.FinderException;
034: import javax.ejb.RemoveException;
035: import javax.naming.Context;
036: import javax.naming.InitialContext;
037: import javax.naming.NamingException;
038:
039: import org.objectweb.jonas.common.Log;
040: import org.objectweb.util.monolog.api.BasicLevel;
041: import org.objectweb.util.monolog.api.Logger;
042:
043: /**
044: * @author Ph Durieux
045: */
046: public abstract class P4EC2 implements javax.ejb.EntityBean {
047:
048: // ------------------------------------------------------------------
049: // Get and Set accessor methods of the bean's abstract schema
050: // ------------------------------------------------------------------
051: public abstract String getId();
052:
053: public abstract void setId(String id);
054:
055: public abstract String getPf4();
056:
057: public abstract void setPf4(String pf4);
058:
059: public abstract Collection getP3();
060:
061: public abstract void setP3(Collection p3);
062:
063: // ------------------------------------------------------------------
064: // EntityBean implementation
065: // ------------------------------------------------------------------
066:
067: static protected Logger logger = null;
068: EntityContext ejbContext;
069:
070: /**
071: * The Entity bean can define 0 or more ejbCreate methods.
072: *
073: * @throws CreateException Failure to create an entity EJB object.
074: * @throws DuplicateKeyException An object with the same key already exists.
075: */
076: public String ejbCreate(String id, String pf4)
077: throws CreateException, DuplicateKeyException {
078: logger.log(BasicLevel.DEBUG, "");
079:
080: // Init here the bean fields
081: setId(id);
082: setPf4(pf4);
083:
084: // In CMP, should return null.
085: return null;
086: }
087:
088: /**
089: * There must be an ejbPostCreate par ejbCreate method
090: *
091: * @throws CreateException Failure to create an entity EJB object.
092: */
093: public void ejbPostCreate(String id, String pf4)
094: throws CreateException {
095: logger.log(BasicLevel.DEBUG, "id=" + id);
096: }
097:
098: /**
099: * Set the associated entity context. The container invokes this method
100: * on an instance after the instance has been created.
101: * This method is called in an unspecified transaction context.
102: *
103: * @param ctx - An EntityContext interface for the instance. The instance
104: * should store the reference to the context in an instance variable.
105: * @throws EJBException Thrown by the method to indicate a failure caused by a
106: * system-level error.
107: */
108: public void setEntityContext(EntityContext ctx) {
109: if (logger == null)
110: logger = Log.getLogger(Log.JONAS_TESTS_PREFIX);
111: logger.log(BasicLevel.DEBUG, "");
112: ejbContext = ctx;
113: }
114:
115: /**
116: * Unset the associated entity context. The container calls this method
117: * before removing the instance.
118: * This is the last method that the container invokes on the instance.
119: * The Java garbage collector will eventually invoke the finalize() method
120: * on the instance.
121: * This method is called in an unspecified transaction context.
122: *
123: * @throws EJBException Thrown by the method to indicate a failure caused by a
124: * system-level error.
125: */
126: public void unsetEntityContext() {
127: logger.log(BasicLevel.DEBUG, "");
128: ejbContext = null;
129: }
130:
131: /**
132: * A container invokes this method before it removes the EJB object
133: * that is currently associated with the instance. This method is
134: * invoked when a client invokes a remove operation on the enterprise Bean's
135: * home interface or the EJB object's remote interface. This method
136: * transitions the instance from the ready state to the pool of available
137: * instances.
138: *
139: * This method is called in the transaction context of the remove operation.
140: * @throws RemoveException The enterprise Bean does not allow destruction of the object.
141: * @throws EJBException - Thrown by the method to indicate a failure caused by a system-level
142: * error.
143: */
144: public void ejbRemove() throws RemoveException {
145: logger.log(BasicLevel.DEBUG, "");
146: }
147:
148: /**
149: * A container invokes this method to instruct the instance to synchronize
150: * its state by loading it state from the underlying database.
151: * This method always executes in the proper transaction context.
152: *
153: * @throws EJBException Thrown by the method to indicate a failure caused by
154: * a system-level error.
155: */
156: public void ejbLoad() {
157: logger.log(BasicLevel.DEBUG, "");
158: }
159:
160: /**
161: * A container invokes this method to instruct the instance to synchronize
162: * its state by storing it to the underlying database.
163: * This method always executes in the proper transaction context.
164: *
165: * @throws EJBException Thrown by the method to indicate a failure caused by
166: * a system-level error.
167: */
168: public void ejbStore() {
169: logger.log(BasicLevel.DEBUG, "");
170: }
171:
172: /**
173: * A container invokes this method on an instance before the instance
174: * becomes disassociated with a specific EJB object.
175: */
176: public void ejbPassivate() {
177: logger.log(BasicLevel.DEBUG, "");
178: }
179:
180: /**
181: * A container invokes this method when the instance is taken out of
182: * the pool of available instances to become associated with a specific
183: * EJB object.
184: */
185: public void ejbActivate() {
186: logger.log(BasicLevel.DEBUG, "");
187: }
188:
189: }
|