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: AttributeEC2.java 5020 2004-06-29 08:34:28Z durieuxp $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.jtests.beans.relation.remon;
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 AttributeEC2 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: // ------------------------------------------------------------------
055: // EntityBean implementation
056: // ------------------------------------------------------------------
057:
058: static protected Logger logger = null;
059: EntityContext ejbContext;
060:
061: /**
062: * The Entity bean can define 0 or more ejbCreate methods.
063: *
064: * @throws CreateException Failure to create an entity EJB object.
065: * @throws DuplicateKeyException An object with the same key already exists.
066: */
067: public String ejbCreate(String id) throws CreateException,
068: DuplicateKeyException {
069: logger.log(BasicLevel.DEBUG, "");
070:
071: // Init here the bean fields
072: setId(id);
073:
074: // In CMP, should return null.
075: return null;
076: }
077:
078: /**
079: * There must be an ejbPostCreate par ejbCreate method
080: * @throws CreateException Failure to create an entity EJB object.
081: */
082: public void ejbPostCreate(String id) throws CreateException {
083: logger.log(BasicLevel.DEBUG, "id=" + id);
084: }
085:
086: /**
087: * Set the associated entity context. The container invokes this method
088: * on an instance after the instance has been created.
089: * This method is called in an unspecified transaction context.
090: *
091: * @param ctx - An EntityContext interface for the instance. The instance
092: * should store the reference to the context in an instance variable.
093: * @throws EJBException Thrown by the method to indicate a failure caused by a
094: * system-level error.
095: */
096: public void setEntityContext(EntityContext ctx) {
097: if (logger == null)
098: logger = Log.getLogger(Log.JONAS_TESTS_PREFIX);
099: logger.log(BasicLevel.DEBUG, "");
100: ejbContext = ctx;
101: }
102:
103: /**
104: * Unset the associated entity context. The container calls this method
105: * before removing the instance.
106: * This is the last method that the container invokes on the instance.
107: * The Java garbage collector will eventually invoke the finalize() method
108: * on the instance.
109: * This method is called in an unspecified transaction context.
110: *
111: * @throws EJBException Thrown by the method to indicate a failure caused by a
112: * system-level error.
113: */
114: public void unsetEntityContext() {
115: logger.log(BasicLevel.DEBUG, "");
116: ejbContext = null;
117: }
118:
119: /**
120: * A container invokes this method before it removes the EJB object
121: * that is currently associated with the instance. This method is
122: * invoked when a client invokes a remove operation on the enterprise Bean's
123: * home interface or the EJB object's remote interface. This method
124: * transitions the instance from the ready state to the pool of available
125: * instances.
126: *
127: * This method is called in the transaction context of the remove operation.
128: * @throws RemoveException The enterprise Bean does not allow destruction of the object.
129: * @throws EJBException - Thrown by the method to indicate a failure caused by a system-level
130: * error.
131: */
132: public void ejbRemove() throws RemoveException {
133: logger.log(BasicLevel.DEBUG, "");
134: }
135:
136: /**
137: * A container invokes this method to instruct the instance to synchronize
138: * its state by loading it state from 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 ejbLoad() {
145: logger.log(BasicLevel.DEBUG, "");
146: }
147:
148: /**
149: * A container invokes this method to instruct the instance to synchronize
150: * its state by storing it to 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 ejbStore() {
157: logger.log(BasicLevel.DEBUG, "");
158: }
159:
160: /**
161: * A container invokes this method on an instance before the instance
162: * becomes disassociated with a specific EJB object.
163: */
164: public void ejbPassivate() {
165: logger.log(BasicLevel.DEBUG, "");
166: }
167:
168: /**
169: * A container invokes this method when the instance is taken out of
170: * the pool of available instances to become associated with a specific
171: * EJB object.
172: */
173: public void ejbActivate() {
174: logger.log(BasicLevel.DEBUG, "");
175: }
176:
177: }
|