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


001:        /*
002:         * Copyright 2002-2007 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.jca.support;
018:
019:        import javax.resource.ResourceException;
020:        import javax.resource.spi.ConnectionManager;
021:        import javax.resource.spi.ManagedConnectionFactory;
022:
023:        import org.springframework.beans.factory.FactoryBean;
024:        import org.springframework.beans.factory.InitializingBean;
025:
026:        /**
027:         * {@link org.springframework.beans.factory.FactoryBean} that creates
028:         * a local JCA connection factory in "non-managed" mode (as defined by the
029:         * Java Connector Architecture specification). This is a direct alternative
030:         * to a {@link org.springframework.jndi.JndiObjectFactoryBean} definition that
031:         * obtains a connection factory handle from a J2EE server's naming environment.
032:         *
033:         * <p>The type of the connection factory is dependent on the actual connector:
034:         * the connector can either expose its native API (such as a JDBC
035:         * {@link javax.sql.DataSource} or a JMS {@link javax.jms.ConnectionFactory})
036:         * or follow the standard Common Client Interface (CCI), as defined by the JCA spec.
037:         * The exposed interface in the CCI case is {@link javax.resource.cci.ConnectionFactory}.
038:         *
039:         * <p>In order to use this FactoryBean, you must specify the connector's
040:         * {@link #setManagedConnectionFactory "managedConnectionFactory"} (usually
041:         * configured as separate JavaBean), which will be used to create the actual
042:         * connection factory reference as exposed to the application. Optionally,
043:         * you can also specify a {@link #setConnectionManager "connectionManager"},
044:         * in order to use a custom ConnectionManager instead of the connector's default.
045:         *
046:         * <p><b>NOTE:</b> In non-managed mode, a connector is not deployed on an
047:         * application server, or more specificially not interacting with an application
048:         * server. Consequently, it cannot use a J2EE server's system contracts:
049:         * connection management, transaction management, and security management.
050:         * A custom ConnectionManager implementation has to be used for applying those
051:         * services in conjunction with a standalone transaction coordinator etc.
052:         *
053:         * <p>The connector will use a local ConnectionManager (included in the connector)
054:         * by default, which cannot participate in global transactions due to the lack
055:         * of XA enlistment. You need to specify an XA-capable ConnectionManager in
056:         * order to make the connector interact with an XA transaction coordinator.
057:         * Alternatively, simply use the native local transaction facilities of the
058:         * exposed API (e.g. CCI local transactions), or use a corresponding
059:         * implementation of Spring's PlatformTransactionManager SPI
060:         * (e.g. {@link org.springframework.jca.cci.connection.CciLocalTransactionManager})
061:         * to drive local transactions.
062:         *
063:         * @author Juergen Hoeller
064:         * @since 1.2
065:         * @see #setManagedConnectionFactory
066:         * @see #setConnectionManager
067:         * @see javax.resource.cci.ConnectionFactory
068:         * @see javax.resource.cci.Connection#getLocalTransaction
069:         * @see org.springframework.jca.cci.connection.CciLocalTransactionManager
070:         */
071:        public class LocalConnectionFactoryBean implements  FactoryBean,
072:                InitializingBean {
073:
074:            private ManagedConnectionFactory managedConnectionFactory;
075:
076:            private ConnectionManager connectionManager;
077:
078:            private Object connectionFactory;
079:
080:            /**
081:             * Set the JCA ManagerConnectionFactory that should be used to create
082:             * the desired connection factory.
083:             * <p>The ManagerConnectionFactory will usually be set up as separate bean
084:             * (potentially as inner bean), populated with JavaBean properties:
085:             * a ManagerConnectionFactory is encouraged to follow the JavaBean pattern
086:             * by the JCA specification, analogous to a JDBC DataSource and a JDO
087:             * PersistenceManagerFactory.
088:             * <p>Note that the ManagerConnectionFactory implementation might expect
089:             * a reference to its JCA 1.5 ResourceAdapter, expressed through the
090:             * {@link javax.resource.spi.ResourceAdapterAssociation} interface.
091:             * Simply inject the corresponding ResourceAdapter instance into its
092:             * "resourceAdapter" bean property in this case, before passing the
093:             * ManagerConnectionFactory into this LocalConnectionFactoryBean.
094:             * @see javax.resource.spi.ManagedConnectionFactory#createConnectionFactory()
095:             */
096:            public void setManagedConnectionFactory(
097:                    ManagedConnectionFactory managedConnectionFactory) {
098:                this .managedConnectionFactory = managedConnectionFactory;
099:            }
100:
101:            /**
102:             * Set the JCA ConnectionManager that should be used to create the
103:             * desired connection factory.
104:             * <p>A ConnectionManager implementation for local usage is often
105:             * included with a JCA connector. Such an included ConnectionManager
106:             * might be set as default, with no need to explicitly specify one.
107:             * @see javax.resource.spi.ManagedConnectionFactory#createConnectionFactory(javax.resource.spi.ConnectionManager)
108:             */
109:            public void setConnectionManager(ConnectionManager connectionManager) {
110:                this .connectionManager = connectionManager;
111:            }
112:
113:            public void afterPropertiesSet() throws ResourceException {
114:                if (this .managedConnectionFactory == null) {
115:                    throw new IllegalArgumentException(
116:                            "Property 'managedConnectionFactory' is required");
117:                }
118:                if (this .connectionManager != null) {
119:                    this .connectionFactory = this .managedConnectionFactory
120:                            .createConnectionFactory(this .connectionManager);
121:                } else {
122:                    this .connectionFactory = this .managedConnectionFactory
123:                            .createConnectionFactory();
124:                }
125:            }
126:
127:            public Object getObject() {
128:                return this .connectionFactory;
129:            }
130:
131:            public Class getObjectType() {
132:                return (this .connectionFactory != null ? this .connectionFactory
133:                        .getClass() : null);
134:            }
135:
136:            public boolean isSingleton() {
137:                return true;
138:            }
139:
140:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.