Source Code Cross Referenced for JotmFactoryBean.java in  » J2EE » spring-framework-2.5 » org » springframework » transaction » jta » 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 » spring framework 2.5 » org.springframework.transaction.jta 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2002-2006 the original author or authors.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package org.springframework.transaction.jta;
018:
019:        import javax.naming.NamingException;
020:
021:        import org.objectweb.jotm.Current;
022:        import org.objectweb.jotm.Jotm;
023:
024:        import org.springframework.beans.factory.DisposableBean;
025:        import org.springframework.beans.factory.FactoryBean;
026:
027:        /**
028:         * FactoryBean that retrieves the JTA UserTransaction/TransactionManager for
029:         * ObjectWeb's <a href="http://jotm.objectweb.org">JOTM</a>. Will retrieve
030:         * an already active JOTM instance if found (e.g. if running in JOnAS),
031:         * else create a new local JOTM instance.
032:         *
033:         * <p>With JOTM, the same object implements both the
034:         * {@link javax.transaction.UserTransaction} and the
035:         * {@link javax.transaction.TransactionManager} interface,
036:         * as returned by this FactoryBean.
037:         *
038:         * <p>A local JOTM instance is well-suited for working in conjunction with
039:         * ObjectWeb's <a href="http://xapool.experlog.com">XAPool</a>, e.g. with bean
040:         * definitions like the following:
041:         *
042:         * <pre class="code">
043:         * &lt;bean id="jotm" class="org.springframework.transaction.jta.JotmFactoryBean"/&gt;
044:         *
045:         * &lt;bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"&gt;
046:         *   &lt;property name="userTransaction" ref="jotm"/&gt;
047:         * &lt;/bean&gt;
048:         *
049:         * &lt;bean id="innerDataSource" class="org.enhydra.jdbc.standard.StandardXADataSource" destroy-method="shutdown"&gt;
050:         *   &lt;property name="transactionManager" ref="jotm"/&gt;
051:         *   &lt;property name="driverName" value="..."/&gt;
052:         *   &lt;property name="url" value="..."/&gt;
053:         *   &lt;property name="user" value="..."/&gt;
054:         *   &lt;property name="password" value="..."/&gt;
055:         * &lt;/bean&gt;
056:         *
057:         * &lt;bean id="dataSource" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource" destroy-method="shutdown"&gt;
058:         *   &lt;property name="dataSource" ref="innerDataSource"/&gt;
059:         *   &lt;property name="user" value="..."/&gt;
060:         *   &lt;property name="password" value="..."/&gt;
061:         *   &lt;property name="maxSize" value="..."/&gt;
062:         * &lt;/bean&gt;</pre>
063:         *
064:         * Note that Spring's {@link JtaTransactionManager} will automatically detect
065:         * that the passed-in UserTransaction reference also implements the
066:         * TransactionManager interface. Hence, it is not necessary to specify a
067:         * separate reference for JtaTransactionManager's "transactionManager" property.
068:         *
069:         * <p>Implementation note: This FactoryBean uses JOTM's static access method
070:         * to obtain the JOTM {@link org.objectweb.jotm.Current} object, which
071:         * implements both the UserTransaction and the TransactionManager interface,
072:         * as mentioned above.
073:         *
074:         * @author Juergen Hoeller
075:         * @since 21.01.2004
076:         * @see JtaTransactionManager#setUserTransaction
077:         * @see JtaTransactionManager#setTransactionManager
078:         * @see org.objectweb.jotm.Current
079:         */
080:        public class JotmFactoryBean implements  FactoryBean, DisposableBean {
081:
082:            private Current jotmCurrent;
083:
084:            private Jotm jotm;
085:
086:            public JotmFactoryBean() throws NamingException {
087:                // Check for already active JOTM instance.
088:                this .jotmCurrent = Current.getCurrent();
089:
090:                // If none found, create new local JOTM instance.
091:                if (this .jotmCurrent == null) {
092:                    // Only for use within the current Spring context:
093:                    // local, not bound to registry.
094:                    this .jotm = new Jotm(true, false);
095:                    this .jotmCurrent = Current.getCurrent();
096:                }
097:            }
098:
099:            /**
100:             * Set the default transaction timeout for the JOTM instance.
101:             * <p>Should only be called for a local JOTM instance,
102:             * not when accessing an existing (shared) JOTM instance.
103:             */
104:            public void setDefaultTimeout(int defaultTimeout) {
105:                this .jotmCurrent.setDefaultTimeout(defaultTimeout);
106:            }
107:
108:            /**
109:             * Return the JOTM instance created by this factory bean, if any.
110:             * Will be <code>null</code> if an already active JOTM instance is used.
111:             * <p>Application code should never need to access this.
112:             */
113:            public Jotm getJotm() {
114:                return this .jotm;
115:            }
116:
117:            public Object getObject() {
118:                return this .jotmCurrent;
119:            }
120:
121:            public Class getObjectType() {
122:                return this .jotmCurrent.getClass();
123:            }
124:
125:            public boolean isSingleton() {
126:                return true;
127:            }
128:
129:            /**
130:             * Stop the local JOTM instance, if created by this FactoryBean.
131:             */
132:            public void destroy() {
133:                if (this.jotm != null) {
134:                    this.jotm.stop();
135:                }
136:            }
137:
138:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.