Source Code Cross Referenced for RmiIiopCmpBean.java in  » J2EE » openejb3 » org » apache » openejb » test » entity » cmp » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » openejb3 » org.apache.openejb.test.entity.cmp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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