KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > ipanema > store > StoreManagerBean


1 /*
2  * Created on 27.09.2004
3  *
4  */

5 package com.nightlabs.ipanema.store;
6
7 import java.rmi.RemoteException JavaDoc;
8
9 import javax.ejb.CreateException JavaDoc;
10 import javax.ejb.EJBException JavaDoc;
11 import javax.ejb.SessionBean JavaDoc;
12 import javax.ejb.SessionContext JavaDoc;
13
14 import org.apache.log4j.Logger;
15
16 import com.nightlabs.ipanema.base.BaseSessionBeanImpl;
17
18 /**
19  *
20  * @ejb.bean name="StoreManager"
21  * jndi-name="StoreManager"
22  * type="Stateful"
23  * transaction-type="Container"
24  *
25  */

26 public abstract class StoreManagerBean
27 extends BaseSessionBeanImpl
28 implements SessionBean JavaDoc
29 {
30     public static final Logger LOGGER = Logger.getLogger(StoreManagerBean.class);
31     
32     ////////////////////// EJB "constuctor" ////////////////////////////
33

34     /**
35      * @ejb.create-method
36      * @ejb.permission role-name="StoreManager-read"
37      */

38     public void ejbCreate()
39     throws CreateException JavaDoc
40     {
41         try
42         {
43             LOGGER.debug("StoreManagerBean created by " + this.getPrincipalString());
44         }
45         catch (Exception JavaDoc e)
46         {
47             throw new CreateException JavaDoc(e.getMessage());
48         }
49     }
50     
51     public void setSessionContext(SessionContext JavaDoc sessionContext)
52     throws EJBException JavaDoc, RemoteException JavaDoc
53     {
54         super.setSessionContext(sessionContext);
55     }
56     public void unsetSessionContext()
57     {
58         super.unsetSessionContext();
59     }
60     
61 // ////////////////////// product types ////////////////////////////
62
//
63
// /**
64
// * Adds a product type. If the productID is null, a new one
65
// * will be created.
66
// *
67
// * @throws ModuleException
68
// *
69
// * @ejb.interface-method
70
// * @ejb.permission role-name="StoreManager-addProductType"
71
// * @ejb.transaction type = "Required"
72
// **/
73
// public void addProductType(Product productType)
74
// throws StoreException
75
// {
76
// try {
77
// PersistenceManager pm = getPersistenceManager();
78
// try {
79
// IDGenerator idgen = IDGeneratorUtil.getHome().create();
80
// try {
81
// String compID = productType.getProductID();
82
// if(compID == null)
83
// {
84
// long newID = idgen.generateIDLong(Product.class.getName());
85
// compID = this.getOrganisationID() + "/" + new Long(newID);
86
// }
87
// Product pt = new Product(compID);
88
// pm.makePersistent(pt);
89
// } finally {
90
// idgen.remove();
91
// }
92
// } finally {
93
// pm.close();
94
// }
95
// } catch (Exception e) {
96
// throw new StoreException(e);
97
// }
98
// }
99
//
100
// /**
101
// * update a product type
102
// * @throws ModuleException
103
// *
104
// * @ejb.interface-method
105
// * @ejb.permission role-name="StoreManager-updateProductType"
106
// * @ejb.transaction type = "Required"
107
// **/
108
// public void updateProductType(Product productType)
109
// throws StoreException
110
// {
111
// try {
112
// PersistenceManager pm = getPersistenceManager();
113
// try {
114
// pm.attachCopy(productType, false);
115
//// pm.getExtent(Product.class, true);
116
//// try {
117
//// Product pt = (Product)pm.getObjectId(productType.getProductTypeID());
118
//// // TO_DO: implement update with detach/attach
119
//// // pm.attachCopy(productType, true);
120
//// throw new StoreException("NYI");
121
//// }
122
//// catch (JDOObjectNotFoundException e)
123
//// {
124
//// throw new StoreException("Could not find product type whith ID " + productType.getProductTypeID(), e);
125
//// }
126
// } finally {
127
// pm.close();
128
// }
129
// } catch (Exception x) {
130
// throw new StoreException(x);
131
// }
132
// }
133
//
134
//// /**
135
//// * add a product type
136
//// * @throws ModuleException
137
//// *
138
//// * @ejb.interface-method
139
//// * @ejb.permission role-name="StoreManager-remove-producttype"
140
//// * @ejb.transaction type = "Required"
141
//// **/
142
//// public void removeProductType(String productID)
143
//// throws StoreException
144
//// {
145
//// initialize();
146
//// pm.getExtent(Product.class, true);
147
//// try
148
//// {
149
//// Product pt = (Product)pm.getObjectId(productID);
150
//// pm.deletePersistent(pt);
151
//// }
152
//// catch (JDOObjectNotFoundException e)
153
//// {
154
//// // do nothing
155
//// }
156
//// }
157
//
158
// ////////////////////// products ////////////////////////////
159
//
160
// /**
161
// * add a product
162
// * @throws ModuleException
163
// *
164
// * @ejb.interface-method
165
// * @ejb.permission role-name="StoreManager-add-product"
166
// * @ejb.transaction type = "Required"
167
// **/
168
// public void addProduct(OldProduct product)
169
// throws StoreException
170
// {
171
// if (product == null)
172
// throw new NullPointerException("product must not be null!");
173
//
174
// if(product.getProductType() == null)
175
// throw new NullPointerException("product.productType must not be null!");
176
//
177
// try {
178
// PersistenceManager pm = getPersistenceManager();
179
// try {
180
// IDGenerator idgen = IDGeneratorUtil.getHome().create();
181
// try {
182
// if (product.getProductID() == null)
183
// product.setProductID(this.getOrganisationID() + "/" + new Long(idgen.generateIDLong(OldProduct.class.getName())));
184
//
185
// ProductStatus pw = new ProductStatus(product.getProductID(), product);
186
// pm.makePersistent(pw);
187
// } finally {
188
// idgen.remove();
189
// }
190
// } finally {
191
// pm.close();
192
// }
193
// } catch (Exception e) {
194
// throw new StoreException(e);
195
// }
196
// }
197
//
198
//
199
// /**
200
// * update a product type
201
// * @throws ModuleException
202
// *
203
// * @ejb.interface-method
204
// * @ejb.permission role-name="StoreManager-update-product"
205
// * @ejb.transaction type = "Required"
206
// **/
207
// public void updateProduct(OldProduct product)
208
// throws StoreException
209
// {
210
// try {
211
// PersistenceManager pm = getPersistenceManager();
212
// try {
213
// pm.attachCopy(product, false);
214
//// pm.getExtent(OldProduct.class, true);
215
//// try
216
//// {
217
//// OldProduct p = (OldProduct)pm.getObjectId(product.getProductID());
218
//// // TO DO: implement update with detach/attach
219
//// throw new StoreException("NYI");
220
//// }
221
//// catch (JDOObjectNotFoundException e)
222
//// {
223
//// throw new StoreException("Could not find product whith ID " + product.getProductID(), e);
224
//// }
225
// } finally {
226
// pm.close();
227
// }
228
// } catch (Exception x) {
229
// throw new StoreException(x);
230
// }
231
// }
232
//
233
//// /**
234
//// * remove a product
235
//// * @throws ModuleException
236
//// *
237
//// * @ejb.interface-method
238
//// * @ejb.permission role-name="StoreManager-remove-product"
239
//// * @ejb.transaction type = "Required"
240
//// **/
241
//// public void removeProduct(String productID)
242
//// throws StoreException
243
//// {
244
//// initialize();
245
//// pm.getExtent(OldProduct.class, true);
246
//// try
247
//// {
248
//// ProductStatus pw = (ProductStatus)pm.getObjectId(productID);
249
//// pm.deletePersistent(pw);
250
//// }
251
//// catch (JDOObjectNotFoundException e)
252
//// {
253
//// // do nothing
254
//// }
255
//// }
256
//
257
// /**
258
// * remove a product
259
// * @throws ModuleException
260
// *
261
// * @ejb.interface-method
262
// * @ejb.permission role-name="_Guest_"
263
// * @ejb.transaction type = "Required"
264
// **/
265
// public void test()
266
// throws StoreException
267
// {
268
// try {
269
// PersistenceManager pm = getPersistenceManager();
270
// try {
271
// Product productType = new Product(getOrganisationID()+"/"+"productType"+System.currentTimeMillis());
272
// pm.makePersistent(productType);
273
//
274
//
275
// } finally {
276
// pm.close();
277
// }
278
// } catch (Exception x) {
279
// throw new StoreException(x);
280
// }
281
// }
282
//
283
// ////////////////////// operations ////////////////////////////
284
//
285
//
286
//
287
// ////////////////////// EJB stuff ////////////////////////////
288
//
289
// public void ejbActivate() throws EJBException, RemoteException
290
// {
291
//// try
292
//// {
293
//// initialize();
294
//// }
295
//// catch (StoreException e)
296
//// {
297
//// throw new EJBException(e);
298
//// }
299
// }
300
//
301
// public void ejbPassivate() throws EJBException, RemoteException
302
// {
303
// ejbRemove();
304
// }
305
//
306
// public void ejbRemove() throws EJBException, RemoteException
307
// {
308
// }
309
//
310
////////////////////// internal ////////////////////////////
311

312 }
Popular Tags