Source Code Cross Referenced for JmsTransactionManager102.java in  » J2EE » spring-framework-2.0.6 » org » springframework » jms » connection » 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.0.6 » org.springframework.jms.connection 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2002-2005 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.jms.connection;
018:
019:        import javax.jms.Connection;
020:        import javax.jms.ConnectionFactory;
021:        import javax.jms.JMSException;
022:        import javax.jms.QueueConnection;
023:        import javax.jms.QueueConnectionFactory;
024:        import javax.jms.Session;
025:        import javax.jms.TopicConnection;
026:        import javax.jms.TopicConnectionFactory;
027:
028:        /**
029:         * A subclass of JmsTransactionManager that uses the JMS 1.0.2 specification,
030:         * rather than the JMS 1.1 methods used by JmsTransactionManager itself.
031:         * This class can be used for JMS 1.0.2 providers, offering the same API as
032:         * JmsTransactionManager does for JMS 1.1 providers.
033:         *
034:         * <p>You need to set the pubSubDomain property accordingly, as this
035:         * class will always create either QueueConnections/QueueSessions or
036:         * TopicConnections/TopicSessions.
037:         *
038:         * @author Juergen Hoeller
039:         * @since 1.1
040:         * @see #setConnectionFactory
041:         * @see #setPubSubDomain
042:         */
043:        public class JmsTransactionManager102 extends JmsTransactionManager {
044:
045:            private boolean pubSubDomain = false;
046:
047:            /**
048:             * Create a new JmsTransactionManager102 for bean-style usage.
049:             * <p>Note: The ConnectionFactory has to be set before using the instance.
050:             * This constructor can be used to prepare a JmsTemplate via a BeanFactory,
051:             * typically setting the ConnectionFactory via setConnectionFactory.
052:             * @see #setConnectionFactory
053:             */
054:            public JmsTransactionManager102() {
055:                super ();
056:            }
057:
058:            /**
059:             * Create a new JmsTransactionManager102, given a ConnectionFactory.
060:             * @param connectionFactory the ConnectionFactory to manage transactions for
061:             * @param pubSubDomain whether the Publish/Subscribe domain (Topics) or
062:             * Point-to-Point domain (Queues) should be used
063:             * @see #setPubSubDomain
064:             */
065:            public JmsTransactionManager102(
066:                    ConnectionFactory connectionFactory, boolean pubSubDomain) {
067:                setConnectionFactory(connectionFactory);
068:                this .pubSubDomain = pubSubDomain;
069:                afterPropertiesSet();
070:            }
071:
072:            /**
073:             * Configure the JmsTransactionManager102 with knowledge of the JMS domain used.
074:             * This tells the JMS 1.0.2 provider which class hierarchy to use for creating
075:             * Connections and Sessions. Default is Point-to-Point (Queues).
076:             * @param pubSubDomain true for Publish/Subscribe domain (Topics),
077:             * false for Point-to-Point domain (Queues)
078:             */
079:            public void setPubSubDomain(boolean pubSubDomain) {
080:                this .pubSubDomain = pubSubDomain;
081:            }
082:
083:            /**
084:             * Return whether the Publish/Subscribe domain (Topics) is used.
085:             * Otherwise, the Point-to-Point domain (Queues) is used.
086:             */
087:            public boolean isPubSubDomain() {
088:                return pubSubDomain;
089:            }
090:
091:            /**
092:             * In addition to checking if the connection factory is set, make sure
093:             * that the supplied connection factory is of the appropriate type for
094:             * the specified destination type: QueueConnectionFactory for queues,
095:             * and TopicConnectionFactory for topics.
096:             */
097:            public void afterPropertiesSet() {
098:                super .afterPropertiesSet();
099:
100:                // Make sure that the ConnectionFactory passed is consistent.
101:                // Some provider implementations of the ConnectionFactory interface
102:                // implement both domain interfaces under the cover, so just check if
103:                // the selected domain is consistent with the type of connection factory.
104:                if (isPubSubDomain()) {
105:                    if (!(getConnectionFactory() instanceof  TopicConnectionFactory)) {
106:                        throw new IllegalArgumentException(
107:                                "Specified a Spring JMS 1.0.2 transaction manager for topics "
108:                                        + "but did not supply an instance of TopicConnectionFactory");
109:                    }
110:                } else {
111:                    if (!(getConnectionFactory() instanceof  QueueConnectionFactory)) {
112:                        throw new IllegalArgumentException(
113:                                "Specified a Spring JMS 1.0.2 transaction manager for queues "
114:                                        + "but did not supply an instance of QueueConnectionFactory");
115:                    }
116:                }
117:            }
118:
119:            /**
120:             * This implementation overrides the superclass method to use JMS 1.0.2 API.
121:             */
122:            protected Connection createConnection() throws JMSException {
123:                if (isPubSubDomain()) {
124:                    return ((TopicConnectionFactory) getConnectionFactory())
125:                            .createTopicConnection();
126:                } else {
127:                    return ((QueueConnectionFactory) getConnectionFactory())
128:                            .createQueueConnection();
129:                }
130:            }
131:
132:            /**
133:             * This implementation overrides the superclass method to use JMS 1.0.2 API.
134:             */
135:            protected Session createSession(Connection con) throws JMSException {
136:                if (isPubSubDomain()) {
137:                    return ((TopicConnection) con).createTopicSession(true,
138:                            Session.AUTO_ACKNOWLEDGE);
139:                } else {
140:                    return ((QueueConnection) con).createQueueSession(true,
141:                            Session.AUTO_ACKNOWLEDGE);
142:                }
143:            }
144:
145:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.