KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > j2ee > blueprints > lineitem > ejb > LineItemEJB


1 /*
2  * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * - Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * - Redistribution in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in
13  * the documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Sun Microsystems, Inc. or the names of
17  * contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * This software is provided "AS IS," without a warranty of any
21  * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
22  * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
24  * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
25  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
26  * DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
27  * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
28  * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
29  * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
30  * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE,
31  * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32  *
33  * You acknowledge that Software is not designed, licensed or intended
34  * for use in the design, construction, operation or maintenance of
35  * any nuclear facility.
36  */

37 package com.sun.j2ee.blueprints.lineitem.ejb;
38
39 import java.lang.Object;
40
41 import javax.ejb.EntityBean;
42 import javax.ejb.EntityContext;
43 import javax.ejb.CreateException;
44 import javax.ejb.RemoveException;
45
46 /**
47  * This is the main Entity Bean class for LineItemEJB
48  */

49
50 public abstract class LineItemEJB implements EntityBean {
51
52   private EntityContext context = null;
53
54   /**
55    * Accessor for line item's category id
56    * @return String the category id
57    */

58   public abstract String getCategoryId();
59
60   /**
61    * Setter for line item's category id
62    * @param String the category id
63    */

64   public abstract void setCategoryId(String id);
65
66   /**
67    * Accessor for line item's product id
68    * @return String the product id
69    */

70   public abstract String getProductId();
71
72   /**
73    * Setter for line item's product id
74    * @param String the product id
75    */

76   public abstract void setProductId(String id);
77
78   /**
79    * Accessor for line item's item id
80    * @return String the item id
81    */

82   public abstract String getItemId();
83
84   /**
85    * Setter for line item's item id
86    * @param String the item id
87    */

88   public abstract void setItemId(String id);
89
90   /**
91    * Accessor for line item's line number
92    * @return String the linenumber
93    */

94   public abstract String getLineNumber();
95
96   /**
97    * Setter for line item's line number
98    * @param String the line number
99    */

100   public abstract void setLineNumber(String num);
101
102   /**
103    * Accessor for line item's quantity
104    * @return int the quantity
105    */

106   public abstract int getQuantity();
107
108   /**
109    * Setter for line item's quantity
110    * @param int the quantity
111    */

112   public abstract void setQuantity(int qty);
113
114   /**
115    * Accessor for line item's unit price
116    * @return float the unit price
117    */

118   public abstract float getUnitPrice();
119
120   /**
121    * Setter for line item's unit price
122    * @param float the unit price
123    */

124   public abstract void setUnitPrice(float price);
125
126   /**
127    * Accessor for line item's qty that is shipped
128    * @return int the qty already shipped
129    */

130   public abstract int getQuantityShipped();
131
132   /**
133    * Setter for line item's quantity that is already shipped
134    * @param int the qty already shipped
135    */

136   public abstract void setQuantityShipped(int qty);
137
138   /**
139    * The ejb create method - returns object because there is primary key
140    */

141   public Object ejbCreate(String catId, String prodId, String itemId,
142                           String lineNo, int qty, float price, int qtyShipped)
143     throws CreateException {
144       setCategoryId(catId);
145       setProductId(prodId);
146       setItemId(itemId);
147       setLineNumber(lineNo);
148       setQuantity(qty);
149       setUnitPrice(price);
150       setQuantityShipped(qtyShipped);
151       return null;
152   }
153
154   public void ejbPostCreate(String catId, String prodId, String itemId,
155                             String lineNo, int qty, float price, int qtyShipped)
156         throws CreateException{}
157
158   public Object ejbCreate(LineItem lineItem, int qty) throws CreateException {
159     setCategoryId(lineItem.getCategoryId());
160     setProductId(lineItem.getProductId());
161     setItemId(lineItem.getItemId());
162     setLineNumber(lineItem.getLineNumber());
163     setQuantity(lineItem.getQuantity());
164     setUnitPrice(lineItem.getUnitPrice());
165     setQuantityShipped(qty);
166     return null;
167   }
168
169   public void ejbPostCreate(LineItem lineItem, int qty) throws CreateException{}
170
171   public LineItem getData() {
172     LineItem lineItem = new LineItem();
173     lineItem.setCategoryId(getCategoryId());
174     lineItem.setProductId(getProductId());
175     lineItem.setItemId(getItemId());
176     lineItem.setLineNumber(getLineNumber());
177     lineItem.setQuantity(getQuantity());
178     lineItem.setUnitPrice(getUnitPrice());
179     return lineItem;
180   }
181
182   /**
183    * Other life cycle methods
184    */

185   public void setEntityContext(EntityContext c){ context = c; }
186   public void unsetEntityContext(){}
187   public void ejbRemove() throws RemoveException {}
188   public void ejbActivate() {}
189   public void ejbPassivate() {}
190   public void ejbStore() {}
191   public void ejbLoad() {}
192 }
193
194
Popular Tags