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