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: RelativeEC2.java 4406 2004-03-19 11:57:20Z benoitf $
023: * --------------------------------------------------------------------------
024: */
025:
026: // PersonneEC2.java
027: package org.objectweb.jonas.jtests.beans.relatives;
028:
029: import java.util.Date;
030: import java.util.Set;
031:
032: import javax.ejb.CreateException;
033: import javax.ejb.DuplicateKeyException;
034: import javax.ejb.EntityBean;
035: import javax.ejb.EntityContext;
036: import javax.ejb.RemoveException;
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: * This is an entity bean with "container managed persistence version 2.x".
044: * @author Christophe Ney - cney@batisseurs.com
045: */
046: public abstract class RelativeEC2 implements EntityBean {
047:
048: static protected Logger logger = null;
049: EntityContext ejbContext;
050:
051: // ------------------------------------------------------------------
052: // Get and Set accessor methods of the bean's abstract schema
053: // ------------------------------------------------------------------
054: public abstract String getFullName();
055:
056: public abstract void setFullName(String name);
057:
058: public abstract int getLuckyNumber();
059:
060: public abstract void setLuckyNumber(int age);
061:
062: public abstract Date getBirthdate();
063:
064: public abstract void setBirthdate(Date birthdate);
065:
066: public abstract RelativeLocal getSpouse();
067:
068: public abstract void setSpouse(RelativeLocal spouse);
069:
070: public abstract Set getSibblings();
071:
072: public abstract void setSibblings(Set sibblings);
073:
074: public abstract Set getVisitedRelatives();
075:
076: public abstract void setVisitedRelatives(Set sibblings);
077:
078: public abstract boolean getIsMale();
079:
080: public abstract void setIsMale(boolean isMale);
081:
082: public abstract double getAverageAnnualVisits();
083:
084: public abstract void setAverageAnnualVisits(
085: double averageAnnualVisits);
086:
087: // ------------------------------------------------------------------
088: // EntityBean implementation
089: // ------------------------------------------------------------------
090:
091: /**
092: * Set the associated entity context.
093: */
094: public void setEntityContext(EntityContext ctx) {
095: if (logger == null)
096: logger = Log.getLogger(Log.JONAS_TESTS_PREFIX);
097: logger.log(BasicLevel.DEBUG, "");
098: ejbContext = ctx;
099: }
100:
101: /**
102: * Unset the associated entity context.
103: */
104: public void unsetEntityContext() {
105: logger.log(BasicLevel.DEBUG, "");
106: ejbContext = null;
107: }
108:
109: /**
110: * A container invokes this method before it removes the EJB object
111: * that is currently associated with the instance.
112: */
113: public void ejbRemove() throws RemoveException {
114: logger.log(BasicLevel.DEBUG, "");
115: }
116:
117: /**
118: * A container invokes this method to instruct the instance to synchronize
119: * its state by loading it state from the underlying database.
120: */
121: public void ejbLoad() {
122: logger.log(BasicLevel.DEBUG, "");
123: }
124:
125: /**
126: * A container invokes this method to instruct the instance to synchronize
127: * its state by storing it to the underlying database.
128: */
129: public void ejbStore() {
130: logger.log(BasicLevel.DEBUG, "");
131: }
132:
133: /**
134: * A container invokes this instance before creating the EJBObject
135: */
136: public String ejbCreate(String fullName, Date birthdate,
137: int luckyNumber) throws CreateException,
138: DuplicateKeyException {
139: logger.log(BasicLevel.DEBUG, "");
140:
141: setFullName(fullName);
142: setBirthdate(birthdate);
143: setLuckyNumber(luckyNumber);
144:
145: // In CMP, should return null.
146: return null;
147: }
148:
149: /**
150: * There must be an ejbPostCreate par ejbCreate method
151: *
152: * @throws CreateException Failure to create an entity EJB object.
153: */
154: public void ejbPostCreate(String fullName, Date birthdate,
155: int luckyNumber) throws CreateException {
156: logger.log(BasicLevel.DEBUG, "");
157: }
158:
159: /**
160: * This method is called before the instance enters the "passive" state.
161: * The instance should release any resources that it can re-acquire later in the
162: * ejbActivate() method.
163: * After the passivate method completes, the instance must be in a state that
164: * allows the container to use the Java Serialization protocol to externalize
165: * and store away the instance's state.
166: * This method is called with no transaction context.
167: *
168: * @exception EJBException - Thrown if the instance could not perform the
169: * function requested by the container
170: */
171: public void ejbPassivate() {
172: logger.log(BasicLevel.DEBUG, "");
173: }
174:
175: /**
176: * This method is called when the instance is activated from its "passive" state.
177: * The instance should acquire any resource that it has released earlier in the
178: * ejbPassivate() method.
179: * This method is called with no transaction context.
180: *
181: * @exception EJBException - Thrown if the instance could not perform the
182: * function requested by the container
183: */
184: public void ejbActivate() {
185: logger.log(BasicLevel.DEBUG, "");
186: }
187:
188: }
|