KickJava   Java API By Example, From Geeks To Geeks.

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


1 // StockEC2R.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 StockEC2R implements javax.ejb.EntityBean JavaDoc {
12
13     static private Logger logger = null;
14     javax.ejb.EntityContext JavaDoc ejbContext;
15
16  
17     public StockID ejbCreate(String JavaDoc whID, Integer JavaDoc itemID, int stockQty)
18         throws javax.ejb.CreateException JavaDoc{
19         logger.log(BasicLevel.DEBUG, "");
20
21         // Init here the bean fields
22
setWarehouseID(whID);
23         setItemID(itemID);
24         setStockQuantity(stockQty);
25         setYearToDate(0);
26         setOrderQuantity(0);
27         setRemOrderQuantity(0);
28         return null;
29     }
30
31     public void ejbPostCreate(String JavaDoc whID, Integer JavaDoc itemID, int stockQty) {
32         logger.log(BasicLevel.DEBUG, "");
33     }
34
35     // ------------------------------------------------------------------
36
// Persistent fields
37
//
38
// ------------------------------------------------------------------
39
public abstract String JavaDoc getWarehouseID();
40     public abstract void setWarehouseID(String JavaDoc id);
41     public abstract Integer JavaDoc getItemID();
42     public abstract void setItemID(Integer JavaDoc id);
43     public abstract int getStockQuantity();
44     public abstract void setStockQuantity(int qty);
45     public abstract int getYearToDate();
46     public abstract void setYearToDate(int ytd);
47     public abstract int getOrderQuantity();
48     public abstract void setOrderQuantity(int oqty);
49     public abstract int getRemOrderQuantity();
50     public abstract void setRemOrderQuantity(int roqty);
51
52     // ------------------------------------------------------------------
53
// Standard call back methods
54
// ------------------------------------------------------------------
55

56  
57     public void setEntityContext(javax.ejb.EntityContext JavaDoc ctx) {
58         if (logger == null) {
59             logger = Log.getLogger("org.objectweb.jonas_tests");
60         }
61         logger.log(BasicLevel.DEBUG, "");
62         ejbContext = ctx;
63     }
64
65
66     public void unsetEntityContext() {
67         logger.log(BasicLevel.DEBUG, "");
68         ejbContext = null;
69     }
70
71     public void ejbRemove() throws javax.ejb.RemoveException JavaDoc {
72         logger.log(BasicLevel.DEBUG, "");
73     }
74
75  
76     public void ejbLoad() {
77         logger.log(BasicLevel.DEBUG, "");
78     }
79
80
81     public void ejbStore() {
82         logger.log(BasicLevel.DEBUG, "");
83     }
84         
85
86     public void ejbPassivate() {
87         logger.log(BasicLevel.DEBUG, "");
88     }
89
90
91     public void ejbActivate() {
92         logger.log(BasicLevel.DEBUG, "");
93     }
94
95     public void increaseYearToDate(int qty) {
96         logger.log(BasicLevel.DEBUG,"StockBean: increaseYearToDate quantity = "+qty);
97         int ytd = getYearToDate();
98         setYearToDate(ytd + qty);
99     }
100     public void decreaseYearToDate(int qty) {
101         logger.log(BasicLevel.DEBUG,"StockBean: decreaseYearToDate quantity = "+qty);
102         int ytd = getYearToDate();
103         setYearToDate(ytd - qty);
104  
105     }
106
107
108     public void increaseStockQuantity(int qty) {
109         logger.log(BasicLevel.DEBUG,"StockBean: increaseStockQuantity quantity = "+qty);
110         int s = getStockQuantity();
111         setStockQuantity(s + qty);
112     }
113     public void decreaseStockQuantity(int qty) {
114         logger.log(BasicLevel.DEBUG,"StockBean: decreaseStockQuantity quantity = "+qty);
115         int s = getStockQuantity();
116         setStockQuantity(s - qty);
117
118     }
119
120     public void increaseRemOrderQuantity(int qty) {
121         logger.log(BasicLevel.DEBUG,"StockBean: increaseRemOrderQuantity quantity = = "+qty);
122         int s = getRemOrderQuantity();
123         setOrderQuantity(s + qty);
124     }
125     public void decreaseRemOrderQuantity(int qty) {
126         logger.log(BasicLevel.DEBUG,"StockBean: decreaseRemOrderQuantity quantity = = "+qty);
127         int s = getRemOrderQuantity();
128         setOrderQuantity(s - qty);
129     }
130
131
132     public void increaseOrderQuantity(int qty) {
133         logger.log(BasicLevel.DEBUG,"StockBean: increaseOrderQuantity quantity = "+qty);
134         int s = getOrderQuantity();
135         setOrderQuantity(s + qty);
136     }
137     public void decreaseOrderQuantity(int qty) {
138         logger.log(BasicLevel.DEBUG,"StockBean: decreaseOrderQuantity quantity = "+qty);
139         int s = getOrderQuantity();
140         setOrderQuantity(s - qty);
141     }
142 }
143
144
145
146
Popular Tags