KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > stests > appli > CustomerEC2R


1 // CustomerEC2R.java
2
package org.objectweb.jonas.stests.appli;
3
4 import org.objectweb.jonas.common.Log;
5 import org.objectweb.util.monolog.api.Logger;
6 import org.objectweb.util.monolog.api.BasicLevel;
7
8 /**
9  *
10  */

11 public abstract class CustomerEC2R implements javax.ejb.EntityBean JavaDoc {
12
13     static private Logger logger = null;
14     javax.ejb.EntityContext JavaDoc ejbContext;
15
16     /**
17      * Create a new Customer with minimal information.
18      * <p>
19      * @param id Customer ID for the customer being created, must be unique
20      * @param fN First name of the customer
21      * @param lN Last name of the customer
22      * @param phone Phone number of the customer
23      * @return Customer
24      * @exception javax.ejb.CreateException Creation Exception
25      * @exception java.rmi.RemoteException Remote Exception
26      */

27
28     public String JavaDoc ejbCreate(Integer JavaDoc custID, String JavaDoc fN, String JavaDoc lN, String JavaDoc phone)
29         throws javax.ejb.CreateException JavaDoc{
30         setCustomerID(custID);
31         setFirstName(fN);
32         setLastName(lN);
33         setPhone(phone);
34         setAddressLine1("unknown");
35         setAddressLine2("unknown");
36         setCity("unknown");
37         setState("unknown");
38         setZip("unknown");
39         setCreditLimit(0);
40         setBalance(0);
41         setYearToDateBalance(0);
42         return null;
43     }
44
45     /**
46      * Create a new Customer with all parameters, except balances which will automatically
47      * be initialized to zero
48      * <p>
49      * @param id Customer ID for the customer being created, must be unique
50      * @param fN First name of the customer
51      * @param lN Last name of the customer
52      * @param inits Middle initials of the customer
53      * @param phone Phone number of the customer
54      * @param addr1 First address line of the customer
55      * @param addr2 Second address line of the customer
56      * @param city City of the customer's mailing address
57      * @param state State of the customer's mailing address
58      * @param zip Zip code of the customer's mailing address
59      * @param creditLimit Credit limit allowed for this cusomter
60      * @return Customer
61      * @exception javax.ejb.CreateException Creation Exception
62      * @exception java.rmi.RemoteException Remote Exception
63      */

64     public String JavaDoc ejbCreate(Integer JavaDoc Id, String JavaDoc fN, String JavaDoc lN, String JavaDoc inits,
65                             String JavaDoc addr1, String JavaDoc addr2,
66                             String JavaDoc city, String JavaDoc state, String JavaDoc zip,
67                             String JavaDoc phone,
68                            float creditLimit) throws javax.ejb.CreateException JavaDoc{
69         logger.log(BasicLevel.DEBUG, "");
70
71         // Init here the bean fields
72
setCustomerID(Id);
73         setFirstName(fN);
74         setLastName(lN);
75         setPhone(phone);
76         setAddressLine1(addr1);
77         setAddressLine2(addr2);
78         setCity(city);
79         setState(state);
80         setZip(zip);
81         setCreditLimit(creditLimit);
82         setBalance(0);
83         setYearToDateBalance(0);
84         return null;
85     }
86
87     public void ejbPostCreate(Integer JavaDoc custID, String JavaDoc fN, String JavaDoc lN, String JavaDoc phone) {
88         logger.log(BasicLevel.DEBUG, "");
89     }
90
91     public void ejbPostCreate(Integer JavaDoc Id, String JavaDoc fN, String JavaDoc lN, String JavaDoc inits,
92                               String JavaDoc addr1, String JavaDoc addr2,
93                               String JavaDoc city, String JavaDoc state, String JavaDoc zip,
94                               String JavaDoc phone,
95                               float creditLimit) {
96         logger.log(BasicLevel.DEBUG, "");
97     }
98
99     // ------------------------------------------------------------------
100
// Persistent fields
101
//
102
// ------------------------------------------------------------------
103
public abstract Integer JavaDoc getCustomerID();
104     public abstract void setCustomerID(Integer JavaDoc id);
105     public abstract String JavaDoc getFirstName();
106     public abstract void setFirstName(String JavaDoc fn);
107     public abstract String JavaDoc getLastName();
108     public abstract void setLastName(String JavaDoc ln);
109     public abstract String JavaDoc getMiddleInitials();
110     public abstract void setMiddleInitials(String JavaDoc mi);
111     public abstract String JavaDoc getPhone();
112     public abstract void setPhone(String JavaDoc phone);
113     public abstract String JavaDoc getAddressLine1();
114     public abstract void setAddressLine1(String JavaDoc line);
115     public abstract String JavaDoc getAddressLine2();
116     public abstract void setAddressLine2(String JavaDoc line);
117     public abstract String JavaDoc getCity();
118     public abstract void setCity(String JavaDoc city);
119     public abstract String JavaDoc getState();
120     public abstract void setState(String JavaDoc state);
121     public abstract String JavaDoc getZip();
122     public abstract void setZip(String JavaDoc zip);
123     public abstract float getBalance();
124     public abstract void setBalance(float balance);
125     public abstract float getYearToDateBalance();
126     public abstract void setYearToDateBalance(float ytdBalance);
127     public abstract float getCreditLimit();
128     public abstract void setCreditLimit(float limit);
129     // ------------------------------------------------------------------
130
// Standard call back methods
131
// ------------------------------------------------------------------
132

133  
134     public void setEntityContext(javax.ejb.EntityContext JavaDoc ctx) {
135         if (logger == null) {
136             logger = Log.getLogger("org.objectweb.jonas_tests");
137         }
138         logger.log(BasicLevel.DEBUG, "");
139         ejbContext = ctx;
140     }
141
142
143     public void unsetEntityContext() {
144         logger.log(BasicLevel.DEBUG, "");
145         ejbContext = null;
146     }
147
148     public void ejbRemove() throws javax.ejb.RemoveException JavaDoc {
149         logger.log(BasicLevel.DEBUG, "");
150     }
151
152  
153     public void ejbLoad() {
154         logger.log(BasicLevel.DEBUG, "");
155     }
156
157
158     public void ejbStore() {
159         logger.log(BasicLevel.DEBUG, "");
160     }
161         
162
163     public void ejbPassivate() {
164         logger.log(BasicLevel.DEBUG, "");
165     }
166
167
168     public void ejbActivate() {
169         logger.log(BasicLevel.DEBUG, "");
170     }
171  
172     /**
173      * Update the balance and year to date balance with the total amount from an order.
174      * <p>
175      * @param orderAmount Order amount to update the balances with <i>(Mandatory)</i>
176      * @return void
177      * @exception java.rmi.RemoteException Remote exception
178      */

179     /*------------------------------------------------------------------*/
180     public void updateBalance(float orderAmount) {
181         float ytd = getYearToDateBalance();
182         setYearToDateBalance(ytd + orderAmount);
183         float balance = getBalance();
184         setBalance(balance + orderAmount);
185     }
186 }
187
188
189
190
Popular Tags