1 32 33 34 42 package stockonline.ejb.entity.cmp.stockholding; 43 44 45 import javax.naming.*; 46 import javax.rmi.*; 47 import javax.ejb.*; 48 import javax.sql.*; 49 50 import java.sql.*; 51 import java.util.*; 52 import java.rmi.*; 53 54 import stockonline.util.*; 55 import stockonline.ejb.entity.interf.*; 56 57 61 public class StockHoldingBean implements EntityBean 62 { 63 final static boolean verbose = false; 64 final static String BEAN_NAME = "cmpStockHolding"; 65 66 private transient boolean isDirty; 68 public int sub_accno; 70 public int stock_id; 71 public int amount; 72 73 protected EntityContext ctx; 74 75 public StockHoldingBean() 76 { 77 if (verbose) 78 System.out.println(BEAN_NAME + " instantiated"); 79 } 80 81 85 88 public void increase(int amount) 89 { 90 if (verbose) 91 System.out.println(BEAN_NAME + ".increase(" + amount + ") called."); 92 93 this.amount += amount; 94 95 setModified(true); 96 } 97 98 101 public void decrease(int amount) 102 { 103 if (verbose) 104 System.out.println(BEAN_NAME + ".decrease(" + amount + ") called."); 105 106 this.amount -= amount; 107 108 setModified(true); 109 } 110 111 114 public int getAmount() 115 { 116 if (verbose) 117 System.out.println(BEAN_NAME + ".getAmount() called."); 118 119 return amount; 120 } 121 122 125 public Holding getHolding() 126 { 127 if (verbose) 128 System.out.println(BEAN_NAME + ".getHolding() called."); 129 130 Holding holding = new Holding(); 131 132 holding.stock_id = stock_id; 133 holding.amount = amount; 134 135 return holding; 136 } 137 138 142 147 151 public void setEntityContext(EntityContext ctx) 152 { 153 if (verbose) 154 System.out.println(BEAN_NAME + ".setEntityContext called"); 155 156 this.ctx = ctx; 157 } 158 159 163 public void unsetEntityContext() 164 { 165 if (verbose) 166 System.out.println(BEAN_NAME + ".unsetEntityContext called"); 167 168 this.ctx = null; 169 } 170 171 174 public void ejbActivate() 175 { 176 if (verbose) 177 System.out.println(BEAN_NAME + ".ejbActivate() called."); 178 179 setModified(true); 180 } 181 182 185 public void ejbPassivate() 186 { 187 if (verbose) 188 System.out.println(BEAN_NAME + ".ejbPassivate () called."); 189 } 190 191 197 public StockHoldingPK ejbCreate(int sub_accno, int stock_id, int amount) throws CreateException 198 { 199 if (verbose) 200 System.out.println(BEAN_NAME + ".ejbCreate() called."); 201 202 this.sub_accno = sub_accno; 203 this.stock_id = stock_id; 204 this.amount = amount; 205 206 return null; 207 } 208 209 213 public void ejbPostCreate(int sub_accno, int stock_id, int amount) 214 { 215 setModified(false); 216 } 217 218 222 public void ejbRemove() throws RemoteException 223 { 224 if (verbose) 225 System.out.println(BEAN_NAME + ".ejbRemove() called."); 226 } 227 228 232 public void ejbLoad() 233 { 234 if (verbose) 235 System.out.println(BEAN_NAME + ".ejbLoad() called."); 236 237 if (!isModified()) 238 { 239 return; 240 } 241 242 setModified(false); 243 } 244 245 249 public void ejbStore() 250 { 251 if (verbose) 252 System.out.println(BEAN_NAME + ".ejbStore() called."); 253 254 if (!isModified()) 255 { 256 return; 257 } 258 259 setModified(false); 260 } 261 262 267 public boolean isModified() 268 { 269 if (verbose) 270 System.out.println (BEAN_NAME + ".isModified(): isDirty = " + (isDirty ? "true" : "false")); 271 272 return isDirty; 273 } 274 275 280 public void setModified(boolean flag) 281 { 282 isDirty = flag; 283 } 284 285 } 289 | Popular Tags |