Source Code Cross Referenced for TxSessionBean.java in  » EJB-Server-JBoss-4.2.1 » testsuite » org » jboss » test » perf » 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.perf.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.perf.ejb;
023:
024:        import java.rmi.RemoteException;
025:        import javax.ejb.CreateException;
026:        import javax.ejb.EJBException;
027:        import javax.ejb.SessionBean;
028:        import javax.ejb.SessionContext;
029:        import javax.naming.Context;
030:        import javax.naming.InitialContext;
031:        import javax.naming.NamingException;
032:        import javax.transaction.Transaction;
033:        import javax.transaction.TransactionManager;
034:
035:        import org.jboss.test.perf.interfaces.TxSession;
036:
037:        public class TxSessionBean implements  SessionBean {
038:            private SessionContext sessionContext;
039:            private InitialContext iniCtx;
040:
041:            public void ejbCreate() throws CreateException {
042:            }
043:
044:            public void ejbActivate() {
045:            }
046:
047:            public void ejbPassivate() {
048:            }
049:
050:            public void ejbRemove() {
051:            }
052:
053:            public void setSessionContext(SessionContext context) {
054:                sessionContext = context;
055:                try {
056:                    iniCtx = new InitialContext();
057:                } catch (NamingException e) {
058:                    throw new EJBException(e);
059:                }
060:            }
061:
062:            /*
063:             * This method is defined with "Required"
064:             */
065:            public String txRequired() {
066:                Transaction tx = getDaTransaction();
067:                if (tx == null)
068:                    throw new EJBException("Required sees no transaction");
069:                else
070:                    return ("required sees a transaction " + tx.hashCode());
071:            }
072:
073:            /*
074:             * This method is defined with "Requires_new"
075:             */
076:            public String txRequiresNew() {
077:                Object tx = getDaTransaction();
078:                if (tx == null)
079:                    throw new EJBException("RequiresNew sees no transaction");
080:                else
081:                    return ("requiresNew sees a transaction " + tx.hashCode());
082:            }
083:
084:            /*
085:             * testSupports is defined with Supports
086:             */
087:            public String txSupports() {
088:                Object tx = getDaTransaction();
089:                if (tx == null)
090:                    return "supports sees no transaction";
091:                else
092:                    return "supports sees a transaction " + tx.hashCode();
093:            }
094:
095:            /*
096:             * This method is defined with "Mandatory"
097:             */
098:            public String txMandatory() {
099:                Object tx = getDaTransaction();
100:                if (tx == null)
101:                    throw new EJBException("Mandatory sees no transaction");
102:                else
103:                    return ("mandatory sees a transaction " + tx.hashCode());
104:            }
105:
106:            /*
107:             * This method is defined with "Never"
108:             */
109:            public String txNever() {
110:                Object tx = getDaTransaction();
111:                if (tx == null)
112:                    return "never sees no transaction";
113:                else
114:                    throw new EJBException("txNever sees a transaction");
115:            }
116:
117:            /*
118:             * This method is defined with "TxNotSupported"
119:             */
120:            public String txNotSupported() {
121:                Object tx = getDaTransaction();
122:                if (tx == null)
123:                    return "notSupported sees no transaction";
124:                else
125:                    throw new EJBException("txNotSupported sees a transaction");
126:            }
127:
128:            /*
129:             * This method is defined with "Required" and it passes it to a Supports Tx
130:             */
131:            public String requiredToSupports() throws RemoteException {
132:                String message;
133:                Object tx = getDaTransaction();
134:                if (tx == null)
135:                    throw new EJBException("Required doesn't see a transaction");
136:                else
137:                    message = "Required sees a transaction " + tx.hashCode()
138:                            + " Supports should see the same ";
139:
140:                message = message
141:                        + ((TxSession) sessionContext.getEJBObject())
142:                                .txSupports();
143:
144:                // And after invocation we should have the same transaction
145:                tx = getDaTransaction();
146:                if (tx == null)
147:                    throw new EJBException(
148:                            "Required doesn't see a transaction COMING BACK");
149:                else
150:                    return message
151:                            + " on coming back Required sees a transaction "
152:                            + tx.hashCode();
153:
154:            }
155:
156:            /*
157:             * This method is defined with "Required" and it passes it to a Mandatory Tx
158:             */
159:            public String requiredToMandatory() throws RemoteException {
160:                String message;
161:                Object tx = getDaTransaction();
162:                if (tx == null)
163:                    throw new EJBException("Required doesn't see a transaction");
164:                else
165:                    message = "Required sees a transaction " + tx.hashCode()
166:                            + " NotSupported should see the same ";
167:
168:                message = message
169:                        + ((TxSession) sessionContext.getEJBObject())
170:                                .txMandatory();
171:
172:                // And after invocation we should have the same transaction
173:                tx = getDaTransaction();
174:                if (tx == null)
175:                    throw new EJBException(
176:                            "Required doesn't see a transaction COMING BACK");
177:                else
178:                    return message
179:                            + " on coming back Required sees a transaction "
180:                            + tx.hashCode();
181:            }
182:
183:            public String requiredToRequiresNew() throws RemoteException {
184:                String message;
185:                Object tx = getDaTransaction();
186:                if (tx == null)
187:                    throw new EJBException("Required doesn't see a transaction");
188:                else
189:                    message = "Required sees a transaction " + tx.hashCode()
190:                            + " Requires new should see a new transaction ";
191:
192:                message = message
193:                        + ((TxSession) sessionContext.getEJBObject())
194:                                .txRequiresNew();
195:
196:                // And after invocation we should have the same transaction
197:                tx = getDaTransaction();
198:                if (tx == null)
199:                    throw new EJBException(
200:                            "Required doesn't see a transaction COMING BACK");
201:                else
202:                    return message
203:                            + " on coming back Required sees a transaction "
204:                            + tx.hashCode();
205:            }
206:
207:            private Transaction getDaTransaction() {
208:                Transaction t = null;
209:                try {
210:                    TransactionManager tm = (TransactionManager) iniCtx
211:                            .lookup("java:/TransactionManager");
212:                    t = tm.getTransaction();
213:                } catch (Exception e) {
214:                }
215:                return t;
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.