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