001: /*
002: * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions
006: * are met:
007: *
008: * - Redistributions of source code must retain the above copyright
009: * notice, this list of conditions and the following disclaimer.
010: *
011: * - Redistribution in binary form must reproduce the above copyright
012: * notice, this list of conditions and the following disclaimer in
013: * the documentation and/or other materials provided with the
014: * distribution.
015: *
016: * Neither the name of Sun Microsystems, Inc. or the names of
017: * contributors may be used to endorse or promote products derived
018: * from this software without specific prior written permission.
019: *
020: * This software is provided "AS IS," without a warranty of any
021: * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
022: * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
023: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
024: * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
025: * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
026: * DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
027: * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
028: * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
029: * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
030: * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE,
031: * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
032: *
033: * You acknowledge that Software is not designed, licensed or intended
034: * for use in the design, construction, operation or maintenance of
035: * any nuclear facility.
036: */
037: package com.sun.j2ee.blueprints.lineitem.ejb;
038:
039: import java.lang.Object;
040:
041: import javax.ejb.EntityBean;
042: import javax.ejb.EntityContext;
043: import javax.ejb.CreateException;
044: import javax.ejb.RemoveException;
045:
046: /**
047: * This is the main Entity Bean class for LineItemEJB
048: */
049:
050: public abstract class LineItemEJB implements EntityBean {
051:
052: private EntityContext context = null;
053:
054: /**
055: * Accessor for line item's category id
056: * @return String the category id
057: */
058: public abstract String getCategoryId();
059:
060: /**
061: * Setter for line item's category id
062: * @param String the category id
063: */
064: public abstract void setCategoryId(String id);
065:
066: /**
067: * Accessor for line item's product id
068: * @return String the product id
069: */
070: public abstract String getProductId();
071:
072: /**
073: * Setter for line item's product id
074: * @param String the product id
075: */
076: public abstract void setProductId(String id);
077:
078: /**
079: * Accessor for line item's item id
080: * @return String the item id
081: */
082: public abstract String getItemId();
083:
084: /**
085: * Setter for line item's item id
086: * @param String the item id
087: */
088: public abstract void setItemId(String id);
089:
090: /**
091: * Accessor for line item's line number
092: * @return String the linenumber
093: */
094: public abstract String getLineNumber();
095:
096: /**
097: * Setter for line item's line number
098: * @param String the line number
099: */
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,
155: String itemId, String lineNo, int qty, float price,
156: int qtyShipped) throws CreateException {
157: }
158:
159: public Object ejbCreate(LineItem lineItem, int qty)
160: throws CreateException {
161: setCategoryId(lineItem.getCategoryId());
162: setProductId(lineItem.getProductId());
163: setItemId(lineItem.getItemId());
164: setLineNumber(lineItem.getLineNumber());
165: setQuantity(lineItem.getQuantity());
166: setUnitPrice(lineItem.getUnitPrice());
167: setQuantityShipped(qty);
168: return null;
169: }
170:
171: public void ejbPostCreate(LineItem lineItem, int qty)
172: throws CreateException {
173: }
174:
175: public LineItem getData() {
176: LineItem lineItem = new LineItem();
177: lineItem.setCategoryId(getCategoryId());
178: lineItem.setProductId(getProductId());
179: lineItem.setItemId(getItemId());
180: lineItem.setLineNumber(getLineNumber());
181: lineItem.setQuantity(getQuantity());
182: lineItem.setUnitPrice(getUnitPrice());
183: return lineItem;
184: }
185:
186: /**
187: * Other life cycle methods
188: */
189: public void setEntityContext(EntityContext c) {
190: context = c;
191: }
192:
193: public void unsetEntityContext() {
194: }
195:
196: public void ejbRemove() throws RemoveException {
197: }
198:
199: public void ejbActivate() {
200: }
201:
202: public void ejbPassivate() {
203: }
204:
205: public void ejbStore() {
206: }
207:
208: public void ejbLoad() {
209: }
210: }
|