Source Code Cross Referenced for GeronimoConnectionManagerFactory.java in  » J2EE » openejb3 » org » apache » openejb » resource » 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 » openejb3 » org.apache.openejb.resource 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         *
003:         * Licensed to the Apache Software Foundation (ASF) under one or more
004:         * contributor license agreements.  See the NOTICE file distributed with
005:         * this work for additional information regarding copyright ownership.
006:         * The ASF licenses this file to You under the Apache License, Version 2.0
007:         * (the "License"); you may not use this file except in compliance with
008:         * the License.  You may obtain a copy of the License at
009:         *
010:         *     http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         *  Unless required by applicable law or agreed to in writing, software
013:         *  distributed under the License is distributed on an "AS IS" BASIS,
014:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015:         *  See the License for the specific language governing permissions and
016:         *  limitations under the License.
017:         */package org.apache.openejb.resource;
018:
019:        import org.apache.geronimo.connector.outbound.GenericConnectionManager;
020:        import org.apache.geronimo.connector.outbound.connectionmanagerconfig.LocalTransactions;
021:        import org.apache.geronimo.connector.outbound.connectionmanagerconfig.NoPool;
022:        import org.apache.geronimo.connector.outbound.connectionmanagerconfig.NoTransactions;
023:        import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PartitionedPool;
024:        import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PoolingSupport;
025:        import org.apache.geronimo.connector.outbound.connectionmanagerconfig.SinglePool;
026:        import org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionSupport;
027:        import org.apache.geronimo.connector.outbound.connectionmanagerconfig.XATransactions;
028:        import org.apache.geronimo.transaction.manager.RecoverableTransactionManager;
029:
030:        import javax.transaction.TransactionManager;
031:
032:        public class GeronimoConnectionManagerFactory {
033:            private String name;
034:            private ClassLoader classLoader;
035:
036:            private TransactionManager transactionManager;
037:
038:            // Type of transaction used by the ConnectionManager
039:            // local, none, or xa
040:            private String transactionSupport;
041:
042:            // pooling properties
043:            private boolean pooling = true;
044:            private String partitionStrategy; //: none, by-subject, by-connector-properties
045:            private int poolMaxSize = 10;
046:            private int poolMinSize = 0;
047:            private boolean allConnectionsEqual = true;
048:            private int connectionMaxWaitMilliseconds = 5000;
049:            private int connectionMaxIdleMinutes = 15;
050:
051:            public String getName() {
052:                return name;
053:            }
054:
055:            public void setName(String name) {
056:                this .name = name;
057:            }
058:
059:            public ClassLoader getClassLoader() {
060:                return classLoader;
061:            }
062:
063:            public void setClassLoader(ClassLoader classLoader) {
064:                this .classLoader = classLoader;
065:            }
066:
067:            public TransactionManager getTransactionManager() {
068:                return transactionManager;
069:            }
070:
071:            public void setTransactionManager(
072:                    TransactionManager transactionManager) {
073:                this .transactionManager = transactionManager;
074:            }
075:
076:            public String getTransactionSupport() {
077:                return transactionSupport;
078:            }
079:
080:            public void setTransactionSupport(String transactionSupport) {
081:                this .transactionSupport = transactionSupport;
082:            }
083:
084:            public boolean isPooling() {
085:                return pooling;
086:            }
087:
088:            public void setPooling(boolean pooling) {
089:                this .pooling = pooling;
090:            }
091:
092:            public String getPartitionStrategy() {
093:                return partitionStrategy;
094:            }
095:
096:            public void setPartitionStrategy(String partitionStrategy) {
097:                this .partitionStrategy = partitionStrategy;
098:            }
099:
100:            public int getPoolMaxSize() {
101:                return poolMaxSize;
102:            }
103:
104:            public void setPoolMaxSize(int poolMaxSize) {
105:                this .poolMaxSize = poolMaxSize;
106:            }
107:
108:            public int getPoolMinSize() {
109:                return poolMinSize;
110:            }
111:
112:            public void setPoolMinSize(int poolMinSize) {
113:                this .poolMinSize = poolMinSize;
114:            }
115:
116:            public boolean isAllConnectionsEqual() {
117:                return allConnectionsEqual;
118:            }
119:
120:            public void setAllConnectionsEqual(boolean allConnectionsEqual) {
121:                this .allConnectionsEqual = allConnectionsEqual;
122:            }
123:
124:            public int getConnectionMaxWaitMilliseconds() {
125:                return connectionMaxWaitMilliseconds;
126:            }
127:
128:            public void setConnectionMaxWaitMilliseconds(
129:                    int connectionMaxWaitMilliseconds) {
130:                this .connectionMaxWaitMilliseconds = connectionMaxWaitMilliseconds;
131:            }
132:
133:            public int getConnectionMaxIdleMinutes() {
134:                return connectionMaxIdleMinutes;
135:            }
136:
137:            public void setConnectionMaxIdleMinutes(int connectionMaxIdleMinutes) {
138:                this .connectionMaxIdleMinutes = connectionMaxIdleMinutes;
139:            }
140:
141:            public GenericConnectionManager create() {
142:                PoolingSupport poolingSupport = createPoolingSupport();
143:
144:                ClassLoader classLoader = this .classLoader;
145:                if (classLoader == null)
146:                    Thread.currentThread().getContextClassLoader();
147:                if (classLoader == null)
148:                    classLoader = getClass().getClassLoader();
149:                if (classLoader == null)
150:                    classLoader = ClassLoader.getSystemClassLoader();
151:                GenericConnectionManager connectionManager = new GenericConnectionManager(
152:                        createTransactionSupport(), poolingSupport, null,
153:                        new AutoConnectionTracker(),
154:                        (RecoverableTransactionManager) transactionManager,
155:                        name, classLoader);
156:                return connectionManager;
157:            }
158:
159:            private TransactionSupport createTransactionSupport() {
160:                if (transactionSupport == null
161:                        || "local".equalsIgnoreCase(transactionSupport)) {
162:                    return LocalTransactions.INSTANCE;
163:                } else if ("none".equalsIgnoreCase(transactionSupport)) {
164:                    return NoTransactions.INSTANCE;
165:                } else if ("xa".equalsIgnoreCase(transactionSupport)) {
166:                    return new XATransactions(true, false);
167:                } else {
168:                    throw new IllegalArgumentException(
169:                            "Unknown transaction type " + transactionSupport);
170:                }
171:            }
172:
173:            private PoolingSupport createPoolingSupport() {
174:                // pooling off?
175:                if (!pooling) {
176:                    return new NoPool();
177:                }
178:
179:                if (partitionStrategy == null
180:                        || "none".equalsIgnoreCase(partitionStrategy)) {
181:
182:                    // unpartitioned pool
183:                    return new SinglePool(poolMaxSize, poolMinSize,
184:                            connectionMaxWaitMilliseconds,
185:                            connectionMaxIdleMinutes, allConnectionsEqual,
186:                            !allConnectionsEqual, false);
187:
188:                } else if ("by-connector-properties"
189:                        .equalsIgnoreCase(partitionStrategy)) {
190:
191:                    // partition by contector properties such as username and password on a jdbc connection
192:                    return new PartitionedPool(poolMaxSize, poolMinSize,
193:                            connectionMaxWaitMilliseconds,
194:                            connectionMaxIdleMinutes, allConnectionsEqual,
195:                            !allConnectionsEqual, false, true, false);
196:                } else if ("by-subject".equalsIgnoreCase(partitionStrategy)) {
197:
198:                    // partition by caller subject
199:                    return new PartitionedPool(poolMaxSize, poolMinSize,
200:                            connectionMaxWaitMilliseconds,
201:                            connectionMaxIdleMinutes, allConnectionsEqual,
202:                            !allConnectionsEqual, false, false, true);
203:                } else {
204:                    throw new IllegalArgumentException(
205:                            "Unknown partition strategy " + partitionStrategy);
206:                }
207:            }
208:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.