001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.openejb.test.entity.bmp;
017:
018: import java.rmi.RemoteException;
019:
020: import javax.ejb.EJBException;
021: import javax.ejb.EJBHome;
022: import javax.ejb.EJBMetaData;
023: import javax.ejb.EJBObject;
024: import javax.ejb.EntityContext;
025: import javax.ejb.Handle;
026: import javax.ejb.RemoveException;
027: import javax.naming.InitialContext;
028:
029: import org.apache.openejb.test.object.ObjectGraph;
030:
031: /**
032: *
033: * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
034: * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
035: */
036: public class RmiIiopBmpBean implements javax.ejb.EntityBean {
037: private int primaryKey;
038: private String firstName;
039: private String lastName;
040: private EntityContext ejbContext;
041:
042: //=============================
043: // Home interface methods
044: //
045:
046: /**
047: * Maps to RmiIiopBmpHome.findEmptyCollection
048: *
049: * @param primaryKey
050: * @return
051: * @exception javax.ejb.FinderException
052: * @see RmiIiopBmpHome#sum
053: */
054: public java.util.Collection ejbFindEmptyCollection()
055: throws javax.ejb.FinderException, java.rmi.RemoteException {
056: return new java.util.Vector();
057: }
058:
059: /**
060: * Maps to RmiIiopBmpHome.findByPrimaryKey
061: *
062: * @param primaryKey
063: * @return
064: * @exception javax.ejb.FinderException
065: * @see RmiIiopBmpHome#sum
066: */
067: public Integer ejbFindByPrimaryKey(Integer primaryKey)
068: throws javax.ejb.FinderException {
069: return new Integer(-1);
070: }
071:
072: /**
073: * Maps to RmiIiopBmpHome.create
074: *
075: * @param name
076: * @return
077: * @exception javax.ejb.CreateException
078: * @see RmiIiopBmpHome#create
079: */
080: public Integer ejbCreate(String name)
081: throws javax.ejb.CreateException {
082: return new Integer(-1);
083: }
084:
085: public void ejbPostCreate(String name)
086: throws javax.ejb.CreateException {
087: }
088:
089: //
090: // Home interface methods
091: //=============================
092:
093: //=============================
094: // Remote interface methods
095: //
096: /*-------------------------------------------------*/
097: /* String */
098: /*-------------------------------------------------*/
099:
100: public String returnStringObject(String data) {
101: return data;
102: }
103:
104: public String[] returnStringObjectArray(String[] data) {
105: return data;
106: }
107:
108: /*-------------------------------------------------*/
109: /* Character */
110: /*-------------------------------------------------*/
111:
112: public Character returnCharacterObject(Character data) {
113: return data;
114: }
115:
116: public char returnCharacterPrimitive(char data) {
117: return data;
118: }
119:
120: public Character[] returnCharacterObjectArray(Character[] data) {
121: return data;
122: }
123:
124: public char[] returnCharacterPrimitiveArray(char[] data) {
125: return data;
126: }
127:
128: /*-------------------------------------------------*/
129: /* Boolean */
130: /*-------------------------------------------------*/
131:
132: public Boolean returnBooleanObject(Boolean data) {
133: return data;
134: }
135:
136: public boolean returnBooleanPrimitive(boolean data) {
137: return data;
138: }
139:
140: public Boolean[] returnBooleanObjectArray(Boolean[] data) {
141: return data;
142: }
143:
144: public boolean[] returnBooleanPrimitiveArray(boolean[] data) {
145: return data;
146: }
147:
148: /*-------------------------------------------------*/
149: /* Byte */
150: /*-------------------------------------------------*/
151:
152: public Byte returnByteObject(Byte data) {
153: return data;
154: }
155:
156: public byte returnBytePrimitive(byte data) {
157: return data;
158: }
159:
160: public Byte[] returnByteObjectArray(Byte[] data) {
161: return data;
162: }
163:
164: public byte[] returnBytePrimitiveArray(byte[] data) {
165: return data;
166: }
167:
168: /*-------------------------------------------------*/
169: /* Short */
170: /*-------------------------------------------------*/
171:
172: public Short returnShortObject(Short data) {
173: return data;
174: }
175:
176: public short returnShortPrimitive(short data) {
177: return data;
178: }
179:
180: public Short[] returnShortObjectArray(Short[] data) {
181: return data;
182: }
183:
184: public short[] returnShortPrimitiveArray(short[] data) {
185: return data;
186: }
187:
188: /*-------------------------------------------------*/
189: /* Integer */
190: /*-------------------------------------------------*/
191:
192: public Integer returnIntegerObject(Integer data) {
193: return data;
194: }
195:
196: public int returnIntegerPrimitive(int data) {
197: return data;
198: }
199:
200: public Integer[] returnIntegerObjectArray(Integer[] data) {
201: return data;
202: }
203:
204: public int[] returnIntegerPrimitiveArray(int[] data) {
205: return data;
206: }
207:
208: /*-------------------------------------------------*/
209: /* Long */
210: /*-------------------------------------------------*/
211:
212: public Long returnLongObject(Long data) {
213: return data;
214: }
215:
216: public long returnLongPrimitive(long data) {
217: return data;
218: }
219:
220: public Long[] returnLongObjectArray(Long[] data) {
221: return data;
222: }
223:
224: public long[] returnLongPrimitiveArray(long[] data) {
225: return data;
226: }
227:
228: /*-------------------------------------------------*/
229: /* Float */
230: /*-------------------------------------------------*/
231:
232: public Float returnFloatObject(Float data) {
233: return data;
234: }
235:
236: public float returnFloatPrimitive(float data) {
237: return data;
238: }
239:
240: public Float[] returnFloatObjectArray(Float[] data) {
241: return data;
242: }
243:
244: public float[] returnFloatPrimitiveArray(float[] data) {
245: return data;
246: }
247:
248: /*-------------------------------------------------*/
249: /* Double */
250: /*-------------------------------------------------*/
251:
252: public Double returnDoubleObject(Double data) {
253: return data;
254: }
255:
256: public double returnDoublePrimitive(double data) {
257: return data;
258: }
259:
260: public Double[] returnDoubleObjectArray(Double[] data) {
261: return data;
262: }
263:
264: public double[] returnDoublePrimitiveArray(double[] data) {
265: return data;
266: }
267:
268: /*-------------------------------------------------*/
269: /* EJBHome */
270: /*-------------------------------------------------*/
271:
272: public EJBHome returnEJBHome(EJBHome data) {
273: return data;
274: }
275:
276: public EJBHome returnEJBHome() throws javax.ejb.EJBException {
277: EJBHome data = null;
278:
279: try {
280: InitialContext ctx = new InitialContext();
281:
282: data = (EJBHome) ctx
283: .lookup("java:comp/env/bmp/rmi-iiop/home");
284:
285: } catch (Exception e) {
286: e.printStackTrace();
287: throw new javax.ejb.EJBException(e);
288: }
289: return data;
290: }
291:
292: public ObjectGraph returnNestedEJBHome()
293: throws javax.ejb.EJBException {
294: ObjectGraph data = null;
295:
296: try {
297: InitialContext ctx = new InitialContext();
298:
299: Object object = ctx
300: .lookup("java:comp/env/bmp/rmi-iiop/home");
301: data = new ObjectGraph(object);
302:
303: } catch (Exception e) {
304: throw new javax.ejb.EJBException(e);
305: }
306: return data;
307: }
308:
309: public EJBHome[] returnEJBHomeArray(EJBHome[] data) {
310: return data;
311: }
312:
313: /*-------------------------------------------------*/
314: /* EJBObject */
315: /*-------------------------------------------------*/
316:
317: public EJBObject returnEJBObject(EJBObject data) {
318: return data;
319: }
320:
321: public EJBObject returnEJBObject() throws javax.ejb.EJBException {
322: EncBmpObject data = null;
323:
324: try {
325: InitialContext ctx = new InitialContext();
326:
327: EncBmpHome home = (EncBmpHome) ctx
328: .lookup("java:comp/env/bmp/rmi-iiop/home");
329: data = home.create("Test01 BmpBean");
330:
331: } catch (Exception e) {
332: throw new javax.ejb.EJBException(e);
333: }
334: return data;
335: }
336:
337: public ObjectGraph returnNestedEJBObject()
338: throws javax.ejb.EJBException {
339: ObjectGraph data = null;
340:
341: try {
342: InitialContext ctx = new InitialContext();
343:
344: EncBmpHome home = (EncBmpHome) ctx
345: .lookup("java:comp/env/bmp/rmi-iiop/home");
346: EncBmpObject object = home.create("Test02 BmpBean");
347: data = new ObjectGraph(object);
348:
349: } catch (Exception e) {
350: throw new javax.ejb.EJBException(e);
351: }
352: return data;
353: }
354:
355: public EJBObject[] returnEJBObjectArray(EJBObject[] data) {
356: return data;
357: }
358:
359: /*-------------------------------------------------*/
360: /* EJBMetaData */
361: /*-------------------------------------------------*/
362:
363: public EJBMetaData returnEJBMetaData(EJBMetaData data) {
364: return data;
365: }
366:
367: public EJBMetaData returnEJBMetaData()
368: throws javax.ejb.EJBException {
369: EJBMetaData data = null;
370:
371: try {
372: InitialContext ctx = new InitialContext();
373:
374: EncBmpHome home = (EncBmpHome) ctx
375: .lookup("java:comp/env/bmp/rmi-iiop/home");
376: data = home.getEJBMetaData();
377:
378: } catch (Exception e) {
379: throw new javax.ejb.EJBException(e);
380: }
381: return data;
382: }
383:
384: public ObjectGraph returnNestedEJBMetaData()
385: throws javax.ejb.EJBException {
386: ObjectGraph data = null;
387:
388: try {
389: InitialContext ctx = new InitialContext();
390:
391: EncBmpHome home = (EncBmpHome) ctx
392: .lookup("java:comp/env/bmp/rmi-iiop/home");
393: EJBMetaData object = home.getEJBMetaData();
394: data = new ObjectGraph(object);
395:
396: } catch (Exception e) {
397: throw new javax.ejb.EJBException(e);
398: }
399: return data;
400: }
401:
402: public EJBMetaData[] returnEJBMetaDataArray(EJBMetaData[] data) {
403: return data;
404: }
405:
406: /*-------------------------------------------------*/
407: /* Handle */
408: /*-------------------------------------------------*/
409:
410: public Handle returnHandle(Handle data) {
411: return data;
412: }
413:
414: public Handle returnHandle() throws javax.ejb.EJBException {
415: Handle data = null;
416:
417: try {
418: InitialContext ctx = new InitialContext();
419:
420: EncBmpHome home = (EncBmpHome) ctx
421: .lookup("java:comp/env/bmp/rmi-iiop/home");
422: EncBmpObject object = home.create("Test03 BmpBean");
423: data = object.getHandle();
424:
425: } catch (Exception e) {
426: throw new javax.ejb.EJBException(e);
427: }
428: return data;
429: }
430:
431: public ObjectGraph returnNestedHandle()
432: throws javax.ejb.EJBException {
433: ObjectGraph data = null;
434:
435: try {
436: InitialContext ctx = new InitialContext();
437:
438: EncBmpHome home = (EncBmpHome) ctx
439: .lookup("java:comp/env/bmp/rmi-iiop/home");
440: EncBmpObject object = home.create("Test04 BmpBean");
441: data = new ObjectGraph(object.getHandle());
442:
443: } catch (Exception e) {
444: throw new javax.ejb.EJBException(e);
445: }
446: return data;
447: }
448:
449: public Handle[] returnHandleArray(Handle[] data) {
450: return data;
451: }
452:
453: /*-------------------------------------------------*/
454: /* ObjectGraph */
455: /*-------------------------------------------------*/
456:
457: public ObjectGraph returnObjectGraph(ObjectGraph data) {
458: return data;
459: }
460:
461: public ObjectGraph[] returnObjectGraphArray(ObjectGraph[] data) {
462: return data;
463: }
464:
465: //
466: // Remote interface methods
467: //=============================
468:
469: //================================
470: // EntityBean interface methods
471: //
472:
473: /**
474: * A container invokes this method to instruct the
475: * instance to synchronize its state by loading it state from the
476: * underlying database.
477: */
478: public void ejbLoad() throws EJBException, RemoteException {
479: }
480:
481: /**
482: * Set the associated entity context. The container invokes this method
483: * on an instance after the instance has been created.
484: */
485: public void setEntityContext(EntityContext ctx)
486: throws EJBException, RemoteException {
487: ejbContext = ctx;
488: }
489:
490: /**
491: * Unset the associated entity context. The container calls this method
492: * before removing the instance.
493: */
494: public void unsetEntityContext() throws EJBException,
495: RemoteException {
496: }
497:
498: /**
499: * A container invokes this method to instruct the
500: * instance to synchronize its state by storing it to the underlying
501: * database.
502: */
503: public void ejbStore() throws EJBException, RemoteException {
504: }
505:
506: /**
507: * A container invokes this method before it removes the EJB object
508: * that is currently associated with the instance. This method
509: * is invoked when a client invokes a remove operation on the
510: * enterprise Bean's home interface or the EJB object's remote interface.
511: * This method transitions the instance from the ready state to the pool
512: * of available instances.
513: */
514: public void ejbRemove() throws RemoveException, EJBException,
515: RemoteException {
516: }
517:
518: /**
519: * A container invokes this method when the instance
520: * is taken out of the pool of available instances to become associated
521: * with a specific EJB object. This method transitions the instance to
522: * the ready state.
523: */
524: public void ejbActivate() throws EJBException, RemoteException {
525: }
526:
527: /**
528: * A container invokes this method on an instance before the instance
529: * becomes disassociated with a specific EJB object. After this method
530: * completes, the container will place the instance into the pool of
531: * available instances.
532: */
533: public void ejbPassivate() throws EJBException, RemoteException {
534: }
535:
536: //
537: // EntityBean interface methods
538: //================================
539: }
|