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: AddressBean.java 5033 2004-07-01 11:53:33Z durieuxp $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.jtests.beans.relation.cascade;
027:
028: import java.rmi.RemoteException;
029: import javax.ejb.CreateException;
030: import javax.ejb.EntityContext;
031: import javax.ejb.EntityBean;
032:
033: import org.objectweb.jonas.common.Log;
034: import org.objectweb.util.monolog.api.BasicLevel;
035: import org.objectweb.util.monolog.api.Logger;
036:
037: /**
038: * Implementation for bean Address
039: * @author Ph Durieux
040: */
041: public abstract class AddressBean implements EntityBean {
042:
043: static protected Logger logger = null;
044: protected EntityContext ejbContext = null;
045:
046: public Integer ejbCreate(String street, String city, String state,
047: String zip) throws CreateException {
048: logger.log(BasicLevel.DEBUG, "");
049: setStreet(street);
050: setCity(city);
051: setState(state);
052: setZip(zip);
053: return null;
054: }
055:
056: public void ejbPostCreate(String street, String city, String state,
057: String zip) {
058: logger.log(BasicLevel.DEBUG, "");
059: }
060:
061: public Integer ejbCreate(AddressDO addr, CustomerL customer)
062: throws CreateException {
063: setStreet(addr.getStreet());
064: setCity(addr.getCity());
065: setState(addr.getState());
066: setZip(addr.getZip());
067: return null;
068: }
069:
070: public void ejbPostCreate(AddressDO addr, CustomerL customer)
071: throws CreateException {
072: // Sould we do this ? Actually, it doesn't work.
073: // SInce this is a 1-1 relation, when setting the cmr in customer it should set
074: // this also, by coherence ? (to be confirmed)
075: //setCustomer(customer);
076: }
077:
078: public Integer getCustomerId() throws RemoteException {
079: logger.log(BasicLevel.DEBUG, "");
080: CustomerL c = getCustomer();
081: Integer ret = null;
082: if (c != null) {
083: ret = c.getId();
084: }
085: return ret;
086: }
087:
088: // relationship fields (if defined in ejb-relationship-role only)
089: public abstract CustomerL getCustomer();
090:
091: public abstract void setCustomer(CustomerL cust);
092:
093: // persistent fields
094: public abstract Integer getId();
095:
096: public abstract void setId(Integer id);
097:
098: public abstract String getStreet();
099:
100: public abstract void setStreet(String street);
101:
102: public abstract String getCity();
103:
104: public abstract void setCity(String city);
105:
106: public abstract String getState();
107:
108: public abstract void setState(String state);
109:
110: public abstract String getZip();
111:
112: public abstract void setZip(String zip);
113:
114: // standard call back methods
115:
116: public void setEntityContext(EntityContext ec) {
117: if (logger == null)
118: logger = Log.getLogger(Log.JONAS_TESTS_PREFIX);
119: logger.log(BasicLevel.DEBUG, "");
120: ejbContext = ec;
121: }
122:
123: public void unsetEntityContext() {
124: logger.log(BasicLevel.DEBUG, "");
125: ejbContext = null;
126: }
127:
128: public void ejbLoad() {
129: logger.log(BasicLevel.DEBUG, "");
130: }
131:
132: public void ejbStore() {
133: logger.log(BasicLevel.DEBUG, "");
134: }
135:
136: public void ejbActivate() {
137: logger.log(BasicLevel.DEBUG, "");
138: }
139:
140: public void ejbPassivate() {
141: logger.log(BasicLevel.DEBUG, "");
142: }
143:
144: public void ejbRemove() throws javax.ejb.RemoveException {
145: logger.log(BasicLevel.DEBUG, "");
146: }
147: }
|