Source Code Cross Referenced for TellerSessionBean.java in  » EJB-Server-JBoss-4.2.1 » testsuite » org » jboss » test » banknew » ejb » 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 » EJB Server JBoss 4.2.1 » testsuite » org.jboss.test.banknew.ejb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JBoss, Home of Professional Open Source.
003:         * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004:         * as indicated by the @author tags. See the copyright.txt file in the
005:         * distribution for a full listing of individual contributors.
006:         *
007:         * This is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU Lesser General Public License as
009:         * published by the Free Software Foundation; either version 2.1 of
010:         * the License, or (at your option) any later version.
011:         *
012:         * This software is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this software; if not, write to the Free
019:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021:         */
022:        package org.jboss.test.banknew.ejb;
023:
024:        import java.rmi.RemoteException;
025:        import java.util.Collection;
026:
027:        import javax.ejb.CreateException;
028:        import javax.ejb.EJBException;
029:        import javax.naming.InitialContext;
030:        import javax.naming.NamingException;
031:
032:        import org.jboss.test.banknew.interfaces.AccountData;
033:        import org.jboss.test.banknew.interfaces.AccountSession;
034:        import org.jboss.test.banknew.interfaces.AccountSessionHome;
035:        import org.jboss.test.banknew.interfaces.BankException;
036:        import org.jboss.test.banknew.interfaces.CustomerData;
037:        import org.jboss.test.banknew.interfaces.CustomerSession;
038:        import org.jboss.test.banknew.interfaces.CustomerSessionHome;
039:        import org.jboss.test.util.ejb.SessionSupport;
040:
041:        /**
042:         * The Session bean represents a bank.
043:         *
044:         * @author Andreas Schaefer
045:         * @version $Revision: 57211 $
046:         *
047:         * @ejb:bean name="bank/TellerSession"
048:         *           display-name="Teller Session"
049:         *           type="Stateless"
050:         *           view-type="remote"
051:         *           jndi-name="ejb/bank/TellerSession"
052:         *
053:         * @ejb:interface extends="javax.ejb.EJBObject"
054:         *
055:         * @ejb:home extends="javax.ejb.EJBHome"
056:         *
057:         * @ejb:transaction type="Required"
058:         *
059:         * @ejb:ejb-ref ejb-name="bank/AccountSession"
060:         *
061:         * @ejb:ejb-ref ejb-name="bank/BankSession"
062:         *
063:         * @ejb:ejb-ref ejb-name="bank/CustomerSession"
064:         */
065:        public class TellerSessionBean extends SessionSupport {
066:            /** The serialVersionUID */
067:            private static final long serialVersionUID = -1977212418836289874L;
068:
069:            // Constants -----------------------------------------------------
070:
071:            // Attributes ----------------------------------------------------
072:
073:            // Static --------------------------------------------------------
074:
075:            // Constructors --------------------------------------------------
076:
077:            // Public --------------------------------------------------------
078:
079:            /**
080:             * @ejb:interface-method view-type="remote"
081:             **/
082:            public void deposit(String pToAccountId, float pAmount)
083:                    throws BankException {
084:                try {
085:                    getAccountSession().deposit(pToAccountId, pAmount);
086:                } catch (Exception e) {
087:                    sessionCtx.setRollbackOnly();
088:                    throw new BankException("Could not deposit " + pAmount
089:                            + " to " + pToAccountId, e);
090:                }
091:            }
092:
093:            /**
094:             * @ejb:interface-method view-type="remote"
095:             **/
096:            public void transfer(String pFromAccountId, String pToAccountId,
097:                    float pAmount) throws BankException {
098:                try {
099:                    getAccountSession().transfer(pFromAccountId, pToAccountId,
100:                            pAmount);
101:                } catch (Exception e) {
102:                    sessionCtx.setRollbackOnly();
103:                    throw new BankException(
104:                            "Could not transfer " + pAmount + " from "
105:                                    + pFromAccountId + " to " + pToAccountId, e);
106:                }
107:            }
108:
109:            /**
110:             * @ejb:interface-method view-type="remote"
111:             **/
112:            public void withdraw(String pFromAccountId, float pAmount)
113:                    throws BankException {
114:                try {
115:                    getAccountSession().withdraw(pFromAccountId, pAmount);
116:                } catch (Exception e) {
117:                    sessionCtx.setRollbackOnly();
118:                    throw new BankException("Could not withdraw " + pAmount
119:                            + " from " + pFromAccountId, e);
120:                }
121:            }
122:
123:            /**
124:             * @ejb:interface-method view-type="remote"
125:             **/
126:            public AccountData createAccount(String pCustomerId, int pType,
127:                    float pInitialDeposit) throws BankException {
128:                try {
129:                    return getAccountSession().createAccount(pCustomerId,
130:                            pType, pInitialDeposit);
131:                } catch (Exception e) {
132:                    sessionCtx.setRollbackOnly();
133:                    e.printStackTrace();
134:                    throw new BankException("Could not create account", e);
135:                }
136:            }
137:
138:            /**
139:             * @ejb:interface-method view-type="remote"
140:             **/
141:            public void removeAccount(String pAccountId) throws BankException {
142:                try {
143:                    getAccountSession().removeAccount(pAccountId);
144:                } catch (Exception e) {
145:                    sessionCtx.setRollbackOnly();
146:                    e.printStackTrace();
147:                    throw new BankException("Could not remove account", e);
148:                }
149:            }
150:
151:            /**
152:             * @ejb:interface-method view-type="remote"
153:             **/
154:            public void removeAccount(String pCustomerId, int pType)
155:                    throws BankException {
156:                try {
157:                    getAccountSession().removeAccount(pCustomerId, pType);
158:                } catch (Exception e) {
159:                    sessionCtx.setRollbackOnly();
160:                    e.printStackTrace();
161:                    throw new BankException("Could not remove account", e);
162:                }
163:            }
164:
165:            /**
166:             * @ejb:interface-method view-type="remote"
167:             **/
168:            public Collection getAccounts(String pCustomerId)
169:                    throws BankException {
170:                try {
171:                    return getAccountSession().getAccounts(pCustomerId);
172:                } catch (Exception e) {
173:                    sessionCtx.setRollbackOnly();
174:                    e.printStackTrace();
175:                    throw new BankException("Could not remove account", e);
176:                }
177:            }
178:
179:            /**
180:             * @ejb:interface-method view-type="remote"
181:             **/
182:            public AccountData getAccount(String pCustomerId, int pType)
183:                    throws BankException {
184:                try {
185:                    return getAccountSession().getAccount(pCustomerId, pType);
186:                } catch (Exception e) {
187:                    sessionCtx.setRollbackOnly();
188:                    e.printStackTrace();
189:                    throw new BankException("Could not remove account", e);
190:                }
191:            }
192:
193:            /**
194:             * @ejb:interface-method view-type="remote"
195:             **/
196:            public AccountData getAccount(String pAccountId)
197:                    throws BankException {
198:                try {
199:                    return getAccountSession().getAccount(pAccountId);
200:                } catch (Exception e) {
201:                    sessionCtx.setRollbackOnly();
202:                    e.printStackTrace();
203:                    throw new BankException("Could not remove account", e);
204:                }
205:            }
206:
207:            /**
208:             * @ejb:interface-method view-type="remote"
209:             **/
210:            public CustomerData createCustomer(String pBankId, String pName,
211:                    float pInitialDeposit) throws BankException {
212:                try {
213:                    return getCustomerSession().createCustomer(pBankId, pName,
214:                            pInitialDeposit);
215:                } catch (Exception e) {
216:                    sessionCtx.setRollbackOnly();
217:                    e.printStackTrace();
218:                    throw new BankException("Could not create account", e);
219:                }
220:            }
221:
222:            /**
223:             * @ejb:interface-method view-type="remote"
224:             **/
225:            public void removeCustomer(String pCustomerId) throws BankException {
226:                try {
227:                    getCustomerSession().removeCustomer(pCustomerId);
228:                } catch (Exception e) {
229:                    sessionCtx.setRollbackOnly();
230:                    e.printStackTrace();
231:                    throw new BankException("Could not remove account", e);
232:                }
233:            }
234:
235:            /**
236:             * @ejb:interface-method view-type="remote"
237:             **/
238:            public CustomerData getCustomer(String pCustomerId)
239:                    throws BankException {
240:                try {
241:                    CustomerSession lSession = getCustomerSession();
242:                    return lSession.getCustomer(pCustomerId);
243:                } catch (Exception e) {
244:                    e.printStackTrace();
245:                    throw new BankException("Could not get customer for "
246:                            + pCustomerId, e);
247:                }
248:            }
249:
250:            /**
251:             * @ejb:interface-method view-type="remote"
252:             **/
253:            public Collection getCustomers(String pBankId) throws BankException {
254:                try {
255:                    return getCustomerSession().getCustomers(pBankId);
256:                } catch (Exception e) {
257:                    e.printStackTrace();
258:                    throw new BankException("Could not get customers for bank "
259:                            + pBankId, e);
260:                }
261:            }
262:
263:            private AccountSession getAccountSession() throws RemoteException {
264:                try {
265:                    AccountSessionHome lHome = (AccountSessionHome) new InitialContext()
266:                            .lookup(AccountSessionHome.COMP_NAME);
267:                    return lHome.create();
268:                } catch (NamingException ne) {
269:                    throw new EJBException(ne);
270:                } catch (CreateException ce) {
271:                    throw new EJBException(ce);
272:                }
273:            }
274:
275:            private CustomerSession getCustomerSession() throws RemoteException {
276:                try {
277:                    CustomerSessionHome lHome = (CustomerSessionHome) new InitialContext()
278:                            .lookup(CustomerSessionHome.COMP_NAME);
279:                    return lHome.create();
280:                } catch (NamingException ne) {
281:                    throw new EJBException(ne);
282:                } catch (CreateException ce) {
283:                    throw new EJBException(ce);
284:                }
285:            }
286:
287:        }
288:        /*
289:         *   $Id: TellerSessionBean.java 57211 2006-09-26 12:39:46Z dimitris@jboss.org $
290:         *   Currently locked by:$Locker$
291:         *   Revision:
292:         *   $Log$
293:         *   Revision 1.1.16.2  2006/03/01 15:58:56  adrian
294:         *   Remove xdoclet from the jca tests + other tidyup
295:         *
296:         *   Revision 1.1.16.1  2005/10/29 05:04:35  starksm
297:         *   Update the LGPL header
298:         *
299:         *   Revision 1.1  2002/05/04 01:08:25  schaefera
300:         *   Added new Stats classes (JMS related) to JSR-77 implemenation and added the
301:         *   bank-new test application but this does not work right now properly but
302:         *   it is not added to the default tests so I shouldn't bother someone.
303:         *
304:         *   Revision 1.1.2.2  2002/04/29 21:05:17  schaefera
305:         *   Added new marathon test suite using the new bank application
306:         *
307:         *   Revision 1.1.2.1  2002/04/17 05:07:24  schaefera
308:         *   Redesigned the banknew example therefore to a create separation between
309:         *   the Entity Bean (CMP) and the Session Beans (Business Logic).
310:         *   The test cases are redesigned but not finished yet.
311:         *
312:         *   Revision 1.1.2.2  2002/04/15 04:28:15  schaefera
313:         *   Minor fixes regarding to the JNDI names of the beans.
314:         *
315:         *   Revision 1.1.2.1  2002/04/15 02:32:24  schaefera
316:         *   Add a new test version of the bank because the old did no use transactions
317:         *   and the new uses XDoclet 1.1.2 to generate the DDs and other Java classes.
318:         *   Also a marathon test is added. Please specify the jbosstest.duration for
319:         *   how long and the test.timeout (which must be longer than the duration) to
320:         *   run the test with run_tests.xml, tag marathon-test-and-report.
321:         *
322:         *   Revision 1.3  2001/01/07 23:14:34  peter
323:         *   Trying to get JAAS to work within test suite.
324:         *
325:         *   Revision 1.2  2000/09/30 01:00:55  fleury
326:         *   Updated bank tests to work with new jBoss version
327:         *
328:         *   Revision 1.1.1.1  2000/06/21 15:52:37  oberg
329:         *   Initial import of jBoss test. This module contains CTS tests, some simple examples, and small bean suites.
330:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.