KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtests > beans > relation > cascade > AddressBean


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: AddressBean.java,v 1.5 2004/07/01 11:53:33 durieuxp Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.jtests.beans.relation.cascade;
27
28 import java.rmi.RemoteException JavaDoc;
29 import javax.ejb.CreateException JavaDoc;
30 import javax.ejb.EntityContext JavaDoc;
31 import javax.ejb.EntityBean JavaDoc;
32
33 import org.objectweb.jonas.common.Log;
34 import org.objectweb.util.monolog.api.BasicLevel;
35 import org.objectweb.util.monolog.api.Logger;
36
37 /**
38  * Implementation for bean Address
39  * @author Ph Durieux
40  */

41 public abstract class AddressBean implements EntityBean JavaDoc {
42    
43     static protected Logger logger = null;
44     protected EntityContext JavaDoc ejbContext = null;
45
46     public Integer JavaDoc ejbCreate(String JavaDoc street, String JavaDoc city, String JavaDoc state, String JavaDoc zip) throws CreateException JavaDoc {
47         logger.log(BasicLevel.DEBUG, "");
48         setStreet(street);
49         setCity(city);
50         setState(state);
51         setZip(zip);
52         return null;
53     }
54
55     public void ejbPostCreate(String JavaDoc street, String JavaDoc city, String JavaDoc state, String JavaDoc zip) {
56         logger.log(BasicLevel.DEBUG, "");
57     }
58
59     public Integer JavaDoc ejbCreate(AddressDO addr, CustomerL customer) throws CreateException JavaDoc {
60         setStreet(addr.getStreet());
61         setCity(addr.getCity());
62         setState(addr.getState());
63         setZip(addr.getZip());
64         return null;
65     }
66
67     public void ejbPostCreate(AddressDO addr, CustomerL customer) throws CreateException JavaDoc {
68         // Sould we do this ? Actually, it doesn't work.
69
// SInce this is a 1-1 relation, when setting the cmr in customer it should set
70
// this also, by coherence ? (to be confirmed)
71
//setCustomer(customer);
72
}
73
74     public Integer JavaDoc getCustomerId() throws RemoteException JavaDoc {
75         logger.log(BasicLevel.DEBUG, "");
76         CustomerL c = getCustomer();
77         Integer JavaDoc ret = null;
78         if (c != null) {
79             ret = c.getId();
80         }
81         return ret;
82     }
83     
84
85     // relationship fields (if defined in ejb-relationship-role only)
86
public abstract CustomerL getCustomer();
87     public abstract void setCustomer(CustomerL cust);
88
89     // persistent fields
90
public abstract Integer JavaDoc getId();
91     public abstract void setId(Integer JavaDoc id);
92     public abstract String JavaDoc getStreet();
93     public abstract void setStreet(String JavaDoc street);
94     public abstract String JavaDoc getCity();
95     public abstract void setCity(String JavaDoc city);
96     public abstract String JavaDoc getState();
97     public abstract void setState(String JavaDoc state);
98     public abstract String JavaDoc getZip();
99     public abstract void setZip(String JavaDoc zip);
100
101     // standard call back methods
102

103     public void setEntityContext(EntityContext JavaDoc ec) {
104         if (logger == null)
105             logger = Log.getLogger(Log.JONAS_TESTS_PREFIX);
106         logger.log(BasicLevel.DEBUG, "");
107         ejbContext = ec;
108     }
109
110     public void unsetEntityContext() {
111         logger.log(BasicLevel.DEBUG, "");
112         ejbContext = null;
113     }
114
115     public void ejbLoad() {
116         logger.log(BasicLevel.DEBUG, "");
117     }
118
119     public void ejbStore() {
120         logger.log(BasicLevel.DEBUG, "");
121     }
122
123     public void ejbActivate() {
124         logger.log(BasicLevel.DEBUG, "");
125     }
126
127     public void ejbPassivate() {
128         logger.log(BasicLevel.DEBUG, "");
129     }
130
131     public void ejbRemove() throws javax.ejb.RemoveException JavaDoc {
132         logger.log(BasicLevel.DEBUG, "");
133     }
134 }
135
Popular Tags