001: // StockEC2R.java
002: package org.objectweb.jonas.stests.appli;
003:
004: import org.objectweb.jonas.common.Log;
005: import org.objectweb.util.monolog.api.Logger;
006: import org.objectweb.util.monolog.api.BasicLevel;
007:
008: /**
009: *
010: */
011: public abstract class StockEC2R implements javax.ejb.EntityBean {
012:
013: static private Logger logger = null;
014: javax.ejb.EntityContext ejbContext;
015:
016: public StockID ejbCreate(String whID, Integer itemID, int stockQty)
017: throws javax.ejb.CreateException {
018: logger.log(BasicLevel.DEBUG, "");
019:
020: // Init here the bean fields
021: setWarehouseID(whID);
022: setItemID(itemID);
023: setStockQuantity(stockQty);
024: setYearToDate(0);
025: setOrderQuantity(0);
026: setRemOrderQuantity(0);
027: return null;
028: }
029:
030: public void ejbPostCreate(String whID, Integer itemID, int stockQty) {
031: logger.log(BasicLevel.DEBUG, "");
032: }
033:
034: // ------------------------------------------------------------------
035: // Persistent fields
036: //
037: // ------------------------------------------------------------------
038: public abstract String getWarehouseID();
039:
040: public abstract void setWarehouseID(String id);
041:
042: public abstract Integer getItemID();
043:
044: public abstract void setItemID(Integer id);
045:
046: public abstract int getStockQuantity();
047:
048: public abstract void setStockQuantity(int qty);
049:
050: public abstract int getYearToDate();
051:
052: public abstract void setYearToDate(int ytd);
053:
054: public abstract int getOrderQuantity();
055:
056: public abstract void setOrderQuantity(int oqty);
057:
058: public abstract int getRemOrderQuantity();
059:
060: public abstract void setRemOrderQuantity(int roqty);
061:
062: // ------------------------------------------------------------------
063: // Standard call back methods
064: // ------------------------------------------------------------------
065:
066: public void setEntityContext(javax.ejb.EntityContext ctx) {
067: if (logger == null) {
068: logger = Log.getLogger("org.objectweb.jonas_tests");
069: }
070: logger.log(BasicLevel.DEBUG, "");
071: ejbContext = ctx;
072: }
073:
074: public void unsetEntityContext() {
075: logger.log(BasicLevel.DEBUG, "");
076: ejbContext = null;
077: }
078:
079: public void ejbRemove() throws javax.ejb.RemoveException {
080: logger.log(BasicLevel.DEBUG, "");
081: }
082:
083: public void ejbLoad() {
084: logger.log(BasicLevel.DEBUG, "");
085: }
086:
087: public void ejbStore() {
088: logger.log(BasicLevel.DEBUG, "");
089: }
090:
091: public void ejbPassivate() {
092: logger.log(BasicLevel.DEBUG, "");
093: }
094:
095: public void ejbActivate() {
096: logger.log(BasicLevel.DEBUG, "");
097: }
098:
099: public void increaseYearToDate(int qty) {
100: logger.log(BasicLevel.DEBUG,
101: "StockBean: increaseYearToDate quantity = " + qty);
102: int ytd = getYearToDate();
103: setYearToDate(ytd + qty);
104: }
105:
106: public void decreaseYearToDate(int qty) {
107: logger.log(BasicLevel.DEBUG,
108: "StockBean: decreaseYearToDate quantity = " + qty);
109: int ytd = getYearToDate();
110: setYearToDate(ytd - qty);
111:
112: }
113:
114: public void increaseStockQuantity(int qty) {
115: logger.log(BasicLevel.DEBUG,
116: "StockBean: increaseStockQuantity quantity = " + qty);
117: int s = getStockQuantity();
118: setStockQuantity(s + qty);
119: }
120:
121: public void decreaseStockQuantity(int qty) {
122: logger.log(BasicLevel.DEBUG,
123: "StockBean: decreaseStockQuantity quantity = " + qty);
124: int s = getStockQuantity();
125: setStockQuantity(s - qty);
126:
127: }
128:
129: public void increaseRemOrderQuantity(int qty) {
130: logger.log(BasicLevel.DEBUG,
131: "StockBean: increaseRemOrderQuantity quantity = = "
132: + qty);
133: int s = getRemOrderQuantity();
134: setOrderQuantity(s + qty);
135: }
136:
137: public void decreaseRemOrderQuantity(int qty) {
138: logger.log(BasicLevel.DEBUG,
139: "StockBean: decreaseRemOrderQuantity quantity = = "
140: + qty);
141: int s = getRemOrderQuantity();
142: setOrderQuantity(s - qty);
143: }
144:
145: public void increaseOrderQuantity(int qty) {
146: logger.log(BasicLevel.DEBUG,
147: "StockBean: increaseOrderQuantity quantity = " + qty);
148: int s = getOrderQuantity();
149: setOrderQuantity(s + qty);
150: }
151:
152: public void decreaseOrderQuantity(int qty) {
153: logger.log(BasicLevel.DEBUG,
154: "StockBean: decreaseOrderQuantity quantity = " + qty);
155: int s = getOrderQuantity();
156: setOrderQuantity(s - qty);
157: }
158: }
|