KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openejb > test > entity > bmp > RmiIiopBmpBean


1 /**
2  * Redistribution and use of this software and associated documentation
3  * ("Software"), with or without modification, are permitted provided
4  * that the following conditions are met:
5  *
6  * 1. Redistributions of source code must retain copyright
7  * statements and notices. Redistributions must also contain a
8  * copy of this document.
9  *
10  * 2. Redistributions in binary form must reproduce the
11  * above copyright notice, this list of conditions and the
12  * following disclaimer in the documentation and/or other
13  * materials provided with the distribution.
14  *
15  * 3. The name "Exolab" must not be used to endorse or promote
16  * products derived from this Software without prior written
17  * permission of Exoffice Technologies. For written permission,
18  * please contact info@exolab.org.
19  *
20  * 4. Products derived from this Software may not be called "Exolab"
21  * nor may "Exolab" appear in their names without prior written
22  * permission of Exoffice Technologies. Exolab is a registered
23  * trademark of Exoffice Technologies.
24  *
25  * 5. Due credit should be given to the Exolab Project
26  * (http://www.exolab.org/).
27  *
28  * THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
29  * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
30  * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
31  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
32  * EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
33  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
35  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
37  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
39  * OF THE POSSIBILITY OF SUCH DAMAGE.
40  *
41  * Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved.
42  *
43  * $Id: RmiIiopBmpBean.java 1096 2004-03-26 21:41:16Z dblevins $
44  */

45 package org.openejb.test.entity.bmp;
46
47 import java.rmi.RemoteException JavaDoc;
48
49 import javax.ejb.EJBException JavaDoc;
50 import javax.ejb.EJBHome JavaDoc;
51 import javax.ejb.EJBMetaData JavaDoc;
52 import javax.ejb.EJBObject JavaDoc;
53 import javax.ejb.EntityContext JavaDoc;
54 import javax.ejb.Handle JavaDoc;
55 import javax.ejb.RemoveException JavaDoc;
56 import javax.naming.InitialContext JavaDoc;
57
58 import org.openejb.test.object.ObjectGraph;
59
60 /**
61  *
62  * @author <a HREF="mailto:david.blevins@visi.com">David Blevins</a>
63  * @author <a HREF="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
64  */

65 public class RmiIiopBmpBean implements javax.ejb.EntityBean JavaDoc{
66     private int primaryKey;
67     private String JavaDoc firstName;
68     private String JavaDoc lastName;
69     private EntityContext JavaDoc ejbContext;
70     
71     
72     //=============================
73
// Home interface methods
74
//
75

76     /**
77      * Maps to RmiIiopBmpHome.findEmptyCollection
78      *
79      * @param primaryKey
80      * @return
81      * @exception javax.ejb.FinderException
82      * @see RmiIiopBmpHome.sum
83      */

84     public java.util.Collection JavaDoc ejbFindEmptyCollection()
85     throws javax.ejb.FinderException JavaDoc, java.rmi.RemoteException JavaDoc {
86         return new java.util.Vector JavaDoc();
87     }
88
89     /**
90      * Maps to RmiIiopBmpHome.findByPrimaryKey
91      *
92      * @param primaryKey
93      * @return
94      * @exception javax.ejb.FinderException
95      * @see RmiIiopBmpHome.sum
96      */

97     public Integer JavaDoc ejbFindByPrimaryKey(Integer JavaDoc primaryKey)
98     throws javax.ejb.FinderException JavaDoc{
99         return new Integer JavaDoc(-1);
100     }
101
102     /**
103      * Maps to RmiIiopBmpHome.create
104      *
105      * @param name
106      * @return
107      * @exception javax.ejb.CreateException
108      * @see RmiIiopBmpHome.create
109      */

110     public Integer JavaDoc ejbCreate(String JavaDoc name)
111     throws javax.ejb.CreateException JavaDoc{
112         return new Integer JavaDoc(-1);
113     }
114     
115     public void ejbPostCreate(String JavaDoc name)
116     throws javax.ejb.CreateException JavaDoc{
117     }
118     
119     
120     //
121
// Home interface methods
122
//=============================
123

124
125     //=============================
126
// Remote interface methods
127
//
128
/*-------------------------------------------------*/
129     /* String */
130     /*-------------------------------------------------*/
131     
132     public String JavaDoc returnStringObject(String JavaDoc data) {
133         return data;
134     }
135     
136     public String JavaDoc[] returnStringObjectArray(String JavaDoc[] data) {
137         return data;
138     }
139     
140     /*-------------------------------------------------*/
141     /* Character */
142     /*-------------------------------------------------*/
143     
144     public Character JavaDoc returnCharacterObject(Character JavaDoc data) {
145         return data;
146     }
147     
148     public char returnCharacterPrimitive(char data) {
149         return data;
150     }
151     
152     public Character JavaDoc[] returnCharacterObjectArray(Character JavaDoc[] data) {
153         return data;
154     }
155     
156     public char[] returnCharacterPrimitiveArray(char[] data) {
157         return data;
158     }
159
160     /*-------------------------------------------------*/
161     /* Boolean */
162     /*-------------------------------------------------*/
163     
164     public Boolean JavaDoc returnBooleanObject(Boolean JavaDoc data) {
165         return data;
166     }
167     
168     public boolean returnBooleanPrimitive(boolean data) {
169         return data;
170     }
171     
172     public Boolean JavaDoc[] returnBooleanObjectArray(Boolean JavaDoc[] data) {
173         return data;
174     }
175     
176     public boolean[] returnBooleanPrimitiveArray(boolean[] data) {
177         return data;
178     }
179     
180     /*-------------------------------------------------*/
181     /* Byte */
182     /*-------------------------------------------------*/
183     
184     public Byte JavaDoc returnByteObject(Byte JavaDoc data) {
185         return data;
186     }
187     
188     public byte returnBytePrimitive(byte data) {
189         return data;
190     }
191     
192     public Byte JavaDoc[] returnByteObjectArray(Byte JavaDoc[] data) {
193         return data;
194     }
195     
196     public byte[] returnBytePrimitiveArray(byte[] data) {
197         return data;
198     }
199     
200     /*-------------------------------------------------*/
201     /* Short */
202     /*-------------------------------------------------*/
203     
204     public Short JavaDoc returnShortObject(Short JavaDoc data) {
205         return data;
206     }
207     
208     public short returnShortPrimitive(short data) {
209         return data;
210     }
211     
212     public Short JavaDoc[] returnShortObjectArray(Short JavaDoc[] data) {
213         return data;
214     }
215     
216     public short[] returnShortPrimitiveArray(short[] data) {
217         return data;
218     }
219     
220     /*-------------------------------------------------*/
221     /* Integer */
222     /*-------------------------------------------------*/
223     
224     public Integer JavaDoc returnIntegerObject(Integer JavaDoc data) {
225         return data;
226     }
227     
228     public int returnIntegerPrimitive(int data) {
229         return data;
230     }
231     
232     public Integer JavaDoc[] returnIntegerObjectArray(Integer JavaDoc[] data) {
233         return data;
234     }
235     
236     public int[] returnIntegerPrimitiveArray(int[] data) {
237         return data;
238     }
239     
240     /*-------------------------------------------------*/
241     /* Long */
242     /*-------------------------------------------------*/
243     
244     public Long JavaDoc returnLongObject(Long JavaDoc data) {
245         return data;
246     }
247     
248     public long returnLongPrimitive(long data) {
249         return data;
250     }
251     
252     public Long JavaDoc[] returnLongObjectArray(Long JavaDoc[] data) {
253         return data;
254     }
255     
256     public long[] returnLongPrimitiveArray(long[] data) {
257         return data;
258     }
259     
260     /*-------------------------------------------------*/
261     /* Float */
262     /*-------------------------------------------------*/
263     
264     public Float JavaDoc returnFloatObject(Float JavaDoc data) {
265         return data;
266     }
267     
268     public float returnFloatPrimitive(float data) {
269         return data;
270     }
271     
272     public Float JavaDoc[] returnFloatObjectArray(Float JavaDoc[] data) {
273         return data;
274     }
275     
276     public float[] returnFloatPrimitiveArray(float[] data) {
277         return data;
278     }
279     
280     /*-------------------------------------------------*/
281     /* Double */
282     /*-------------------------------------------------*/
283     
284     public Double JavaDoc returnDoubleObject(Double JavaDoc data) {
285         return data;
286     }
287     
288     public double returnDoublePrimitive(double data) {
289         return data;
290     }
291     
292     public Double JavaDoc[] returnDoubleObjectArray(Double JavaDoc[] data) {
293         return data;
294     }
295     
296     public double[] returnDoublePrimitiveArray(double[] data) {
297         return data;
298     }
299     
300     
301     /*-------------------------------------------------*/
302     /* EJBHome */
303     /*-------------------------------------------------*/
304     
305     public EJBHome JavaDoc returnEJBHome(EJBHome JavaDoc data) {
306         return data;
307     }
308     
309     public EJBHome JavaDoc returnEJBHome() throws javax.ejb.EJBException JavaDoc{
310         EJBHome JavaDoc data = null;
311
312         try{
313         InitialContext JavaDoc ctx = new InitialContext JavaDoc();
314
315         data = (EJBHome JavaDoc)ctx.lookup("java:comp/env/bmp/rmi-iiop/home");
316
317         } catch (Exception JavaDoc e){
318             e.printStackTrace();
319             throw new javax.ejb.EJBException JavaDoc(e);
320         }
321         return data;
322     }
323
324     public ObjectGraph returnNestedEJBHome() throws javax.ejb.EJBException JavaDoc{
325         ObjectGraph data = null;
326
327         try{
328         InitialContext JavaDoc ctx = new InitialContext JavaDoc();
329
330         Object JavaDoc object = ctx.lookup("java:comp/env/bmp/rmi-iiop/home");
331         data = new ObjectGraph(object);
332
333         } catch (Exception JavaDoc e){
334             throw new javax.ejb.EJBException JavaDoc(e);
335         }
336         return data;
337     }
338
339     public EJBHome JavaDoc[] returnEJBHomeArray(EJBHome JavaDoc[] data) {
340         return data;
341     }
342     
343     /*-------------------------------------------------*/
344     /* EJBObject */
345     /*-------------------------------------------------*/
346     
347     public EJBObject JavaDoc returnEJBObject(EJBObject JavaDoc data) {
348         return data;
349     }
350     
351     public EJBObject JavaDoc returnEJBObject() throws javax.ejb.EJBException JavaDoc{
352         EncBmpObject data = null;
353
354         try{
355         InitialContext JavaDoc ctx = new InitialContext JavaDoc();
356
357         EncBmpHome home = (EncBmpHome)ctx.lookup("java:comp/env/bmp/rmi-iiop/home");
358         data = home.create("Test01 BmpBean");
359
360         } catch (Exception JavaDoc e){
361             throw new javax.ejb.EJBException JavaDoc(e);
362         }
363         return data;
364     }
365     
366     public ObjectGraph returnNestedEJBObject() throws javax.ejb.EJBException JavaDoc{
367         ObjectGraph data = null;
368
369         try{
370         InitialContext JavaDoc ctx = new InitialContext JavaDoc();
371
372         EncBmpHome home = (EncBmpHome)ctx.lookup("java:comp/env/bmp/rmi-iiop/home");
373         EncBmpObject object = home.create("Test02 BmpBean");
374         data = new ObjectGraph(object);
375
376         } catch (Exception JavaDoc e){
377             throw new javax.ejb.EJBException JavaDoc(e);
378         }
379         return data;
380     }
381     
382     public EJBObject JavaDoc[] returnEJBObjectArray(EJBObject JavaDoc[] data) {
383         return data;
384     }
385     
386     /*-------------------------------------------------*/
387     /* EJBMetaData */
388     /*-------------------------------------------------*/
389     
390     public EJBMetaData JavaDoc returnEJBMetaData(EJBMetaData JavaDoc data) {
391         return data;
392     }
393     
394     public EJBMetaData JavaDoc returnEJBMetaData() throws javax.ejb.EJBException JavaDoc{
395         EJBMetaData JavaDoc data = null;
396
397         try{
398         InitialContext JavaDoc ctx = new InitialContext JavaDoc();
399
400         EncBmpHome home = (EncBmpHome)ctx.lookup("java:comp/env/bmp/rmi-iiop/home");
401         data = home.getEJBMetaData();
402
403         } catch (Exception JavaDoc e){
404             throw new javax.ejb.EJBException JavaDoc(e);
405         }
406         return data;
407     }
408     
409     public ObjectGraph returnNestedEJBMetaData() throws javax.ejb.EJBException JavaDoc{
410         ObjectGraph data = null;
411
412         try{
413         InitialContext JavaDoc ctx = new InitialContext JavaDoc();
414
415         EncBmpHome home = (EncBmpHome)ctx.lookup("java:comp/env/bmp/rmi-iiop/home");
416         EJBMetaData JavaDoc object = home.getEJBMetaData();
417         data = new ObjectGraph(object);
418
419         } catch (Exception JavaDoc e){
420             throw new javax.ejb.EJBException JavaDoc(e);
421         }
422         return data;
423     }
424     
425     public EJBMetaData JavaDoc[] returnEJBMetaDataArray(EJBMetaData JavaDoc[] data) {
426         return data;
427     }
428     
429     /*-------------------------------------------------*/
430     /* Handle */
431     /*-------------------------------------------------*/
432     
433     public Handle JavaDoc returnHandle(Handle JavaDoc data) {
434         return data;
435     }
436     
437     public Handle JavaDoc returnHandle() throws javax.ejb.EJBException JavaDoc{
438         Handle JavaDoc data = null;
439
440         try{
441         InitialContext JavaDoc ctx = new InitialContext JavaDoc();
442
443         EncBmpHome home = (EncBmpHome)ctx.lookup("java:comp/env/bmp/rmi-iiop/home");
444         EncBmpObject object = home.create("Test03 BmpBean");
445         data = object.getHandle();
446
447         } catch (Exception JavaDoc e){
448             throw new javax.ejb.EJBException JavaDoc(e);
449         }
450         return data;
451     }
452     
453     public ObjectGraph returnNestedHandle() throws javax.ejb.EJBException JavaDoc{
454         ObjectGraph data = null;
455
456         try{
457         InitialContext JavaDoc ctx = new InitialContext JavaDoc();
458
459         EncBmpHome home = (EncBmpHome)ctx.lookup("java:comp/env/bmp/rmi-iiop/home");
460         EncBmpObject object = home.create("Test04 BmpBean");
461         data = new ObjectGraph(object.getHandle());
462
463         } catch (Exception JavaDoc e){
464             throw new javax.ejb.EJBException JavaDoc(e);
465         }
466         return data;
467     }
468     
469     public Handle JavaDoc[] returnHandleArray(Handle JavaDoc[] data) {
470         return data;
471     }
472     
473     /*-------------------------------------------------*/
474     /* ObjectGraph */
475     /*-------------------------------------------------*/
476     
477     public ObjectGraph returnObjectGraph(ObjectGraph data) {
478         return data;
479     }
480     
481     public ObjectGraph[] returnObjectGraphArray(ObjectGraph[] data) {
482         return data;
483     }
484     //
485
// Remote interface methods
486
//=============================
487

488
489     //================================
490
// EntityBean interface methods
491
//
492

493     /**
494      * A container invokes this method to instruct the
495      * instance to synchronize its state by loading it state from the
496      * underlying database.
497      */

498     public void ejbLoad() throws EJBException JavaDoc,RemoteException JavaDoc {
499     }
500     
501     /**
502      * Set the associated entity context. The container invokes this method
503      * on an instance after the instance has been created.
504      */

505     public void setEntityContext(EntityContext JavaDoc ctx) throws EJBException JavaDoc,RemoteException JavaDoc {
506         ejbContext = ctx;
507     }
508     
509     /**
510      * Unset the associated entity context. The container calls this method
511      * before removing the instance.
512      */

513     public void unsetEntityContext() throws EJBException JavaDoc,RemoteException JavaDoc {
514     }
515     
516     /**
517      * A container invokes this method to instruct the
518      * instance to synchronize its state by storing it to the underlying
519      * database.
520      */

521     public void ejbStore() throws EJBException JavaDoc,RemoteException JavaDoc {
522     }
523     
524     /**
525      * A container invokes this method before it removes the EJB object
526      * that is currently associated with the instance. This method
527      * is invoked when a client invokes a remove operation on the
528      * enterprise Bean's home interface or the EJB object's remote interface.
529      * This method transitions the instance from the ready state to the pool
530      * of available instances.
531      */

532     public void ejbRemove() throws RemoveException JavaDoc,EJBException JavaDoc,RemoteException JavaDoc {
533     }
534     
535     /**
536      * A container invokes this method when the instance
537      * is taken out of the pool of available instances to become associated
538      * with a specific EJB object. This method transitions the instance to
539      * the ready state.
540      */

541     public void ejbActivate() throws EJBException JavaDoc,RemoteException JavaDoc {
542     }
543     
544     /**
545      * A container invokes this method on an instance before the instance
546      * becomes disassociated with a specific EJB object. After this method
547      * completes, the container will place the instance into the pool of
548      * available instances.
549      */

550     public void ejbPassivate() throws EJBException JavaDoc,RemoteException JavaDoc {
551     }
552
553     //
554
// EntityBean interface methods
555
//================================
556
}
557
Popular Tags