Source Code Cross Referenced for ReservationBean.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » jtests » beans » ejbql » 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 » JOnAS 4.8.6 » org.objectweb.jonas.jtests.beans.ejbql 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.objectweb.jonas.jtests.beans.ejbql;
002:
003:        import java.util.ArrayList;
004:        import java.util.Collection;
005:        import java.util.Date;
006:        import java.util.Iterator;
007:        import java.util.Set;
008:
009:        import javax.ejb.CreateException;
010:        import javax.ejb.EntityContext;
011:        import javax.ejb.FinderException;
012:        import javax.ejb.RemoveException;
013:        import javax.naming.InitialContext;
014:
015:        public abstract class ReservationBean implements  javax.ejb.EntityBean {
016:
017:            private SequenceSessionLocalHome seqHome = null;
018:
019:            private SequenceSessionLocal seqLocal = null;
020:
021:            private CustomerHomeLocal customerhl = null;
022:
023:            private CruiseHomeLocal cruisehl = null;
024:
025:            private CabinHomeLocal cabinhl = null;
026:
027:            public Object ejbCreate(Integer cruiseId, Collection customers)
028:                    throws CreateException {
029:                int id = seqLocal.getNextNumberInSequence("Reservation");
030:                setId(new Integer(id));
031:                return null;
032:            }
033:
034:            public void ejbPostCreate(Integer cruiseId, Collection customers) {
035:
036:                try {
037:                    CruiseLocal cruise = cruisehl.findByPrimaryKey(cruiseId);
038:                    setCruise(cruise);
039:                } catch (FinderException e) {
040:                    System.out.println("Cruise not find :" + cruiseId);
041:                }
042:
043:                Collection myCustomers = this .getCustomers();
044:
045:                ArrayList al;
046:                if (customers == null)
047:                    al = new ArrayList();
048:                else {
049:                    if (customers.size() == -1)
050:                        al = new ArrayList();
051:                    else {
052:                        al = new ArrayList(customers.size());
053:                        for (Iterator it = customers.iterator(); it.hasNext();) {
054:                            Integer customerid = new Integer("-1");
055:                            try {
056:                                customerid = (Integer) it.next();
057:                                CustomerLocal customer = customerhl
058:                                        .findByPrimaryKey(customerid);
059:                                al.add(customer);
060:                            } catch (FinderException e) {
061:                                System.out.println("Customer not found "
062:                                        + customerid);
063:                            }
064:                        }
065:                    }
066:                }
067:                myCustomers.addAll(al);
068:            }
069:
070:            // relationship fields
071:            public void setAllCabins(Set cabins) {
072:
073:                ArrayList al;
074:                if (cabins == null)
075:                    al = new ArrayList();
076:                else {
077:                    if (cabins.size() == -1)
078:                        al = new ArrayList();
079:                    else {
080:                        al = new ArrayList(cabins.size());
081:                        for (Iterator it = cabins.iterator(); it.hasNext();) {
082:                            Integer cabinid = new Integer("-1");
083:                            try {
084:                                cabinid = (Integer) it.next();
085:                                CabinLocal cabin = cabinhl
086:                                        .findByPrimaryKey(cabinid);
087:                                al.add(cabin);
088:                            } catch (FinderException e) {
089:                                System.out
090:                                        .println("Cabin not found " + cabinid);
091:                            }
092:                        }
093:                    }
094:                }
095:                this .getCabins().addAll(al);
096:            }
097:
098:            // persistent fields getter and setter
099:            public abstract CruiseLocal getCruise();
100:
101:            public abstract void setCruise(CruiseLocal cruise);
102:
103:            public abstract Set getCabins();
104:
105:            public abstract void setCabins(Set cabins);
106:
107:            public abstract Set getCustomers();
108:
109:            public abstract void setCustomers(Set customers);
110:
111:            public abstract Integer getId();
112:
113:            public abstract void setId(Integer id);
114:
115:            public abstract Date getDate();
116:
117:            public abstract void setDate(Date date);
118:
119:            public abstract double getAmountPaid();
120:
121:            public abstract void setAmountPaid(double amount);
122:
123:            // abstract ejbSelect() methods
124:            public abstract long ejbSelectCountOfReservations()
125:                    throws FinderException;
126:
127:            public abstract double ejbSelectMinAmountOfReservations()
128:                    throws FinderException;
129:
130:            public abstract double ejbSelectMinAmountForCruise(String cName)
131:                    throws FinderException;
132:
133:            public abstract Collection ejbSelectAmountsForCruise(String cName)
134:                    throws FinderException;
135:
136:            public abstract double ejbSelectMaxAmountOfReservations()
137:                    throws FinderException;
138:
139:            public abstract long ejbSelectCountOfReservationsForCustomer(
140:                    CustomerLocal c) throws FinderException;
141:
142:            public abstract long ejbSelectAmountOfReservationsForCustomer(
143:                    CustomerLocal c) throws FinderException;
144:
145:            // Public Home method required to test the private ejbSelectXXXX method
146:            public long ejbHomeGetCountOfReservations() throws FinderException {
147:                return this .ejbSelectCountOfReservations();
148:            }
149:
150:            public double ejbHomeGetMinAmountOfReservations()
151:                    throws FinderException {
152:                return this .ejbSelectMinAmountOfReservations();
153:            }
154:
155:            public double ejbHomeGetMinAmountForCruise(String cName)
156:                    throws FinderException {
157:                return this .ejbSelectMinAmountForCruise(cName);
158:            }
159:
160:            public double ejbHomeGetMaxAmountOfReservations()
161:                    throws FinderException {
162:                return this .ejbSelectMaxAmountOfReservations();
163:            }
164:
165:            public Collection ejbHomeGetAmountsForCruise(String cName)
166:                    throws FinderException {
167:                return this .ejbSelectAmountsForCruise(cName);
168:            }
169:
170:            public long ejbHomeGetCountOfReservationsForCustomer(Integer custId)
171:                    throws FinderException {
172:                return this .ejbSelectCountOfReservationsForCustomer(customerhl
173:                        .findByPrimaryKey(custId));
174:            }
175:
176:            public double ejbHomeGetAmountOfReservationsForCustomer(
177:                    Integer custId) throws FinderException {
178:                return this .ejbSelectAmountOfReservationsForCustomer(customerhl
179:                        .findByPrimaryKey(custId));
180:            }
181:
182:            // standard call back methods
183:            public void setEntityContext(EntityContext ec) {
184:                try {
185:                    InitialContext cntx = new InitialContext();
186:                    seqHome = (SequenceSessionLocalHome) cntx
187:                            .lookup("java:comp/env/ejb/SequenceSessionLocalHome");
188:                    customerhl = (CustomerHomeLocal) cntx
189:                            .lookup("java:comp/env/ejb/CustomerLocalHome");
190:                    cruisehl = (CruiseHomeLocal) cntx
191:                            .lookup("java:comp/env/ejb/CruiseLocalHome");
192:                    cabinhl = (CabinHomeLocal) cntx
193:                            .lookup("java:comp/env/ejb/CabinLocalHome");
194:                    seqLocal = seqHome.create();
195:                } catch (Exception e) {
196:                    throw new javax.ejb.EJBException(e);
197:                }
198:            }
199:
200:            public void unsetEntityContext() {
201:            }
202:
203:            public void ejbLoad() {
204:            }
205:
206:            public void ejbStore() {
207:            }
208:
209:            public void ejbActivate() {
210:            }
211:
212:            public void ejbPassivate() {
213:            }
214:
215:            public void ejbRemove() throws RemoveException {
216:            }
217:
218:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.