Source Code Cross Referenced for ConnectionFactoryImpl.java in  » J2EE » JOnAS-4.8.6 » ersatz » resourceadapter » 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 » JOnAS 4.8.6 » ersatz.resourceadapter 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on December 12, 2003
003:         *
004:         * ConnectionFactoryImpl.java is used to test the J2EE Connector
005:         * as implemented by JOnAS. 
006:         * 
007:         */
008:        package ersatz.resourceadapter;
009:
010:        import javax.naming.Reference;
011:        import javax.naming.NamingException;
012:        import javax.resource.ResourceException;
013:        import javax.resource.NotSupportedException;
014:        import javax.resource.spi.ConnectionManager; //  interfaces implemented in this class
015:        import javax.resource.cci.ConnectionFactory;
016:        import javax.resource.cci.Connection;
017:        import javax.resource.cci.ConnectionSpec; // j2ee 1.5
018:        import javax.resource.cci.RecordFactory;
019:        import javax.resource.cci.ResourceAdapterMetaData;
020:        import java.io.Serializable;
021:        import javax.resource.Referenceable;
022:
023:        /**
024:         * @author Bob Kruse
025:         *
026:         * used to test the J2EE Connector as implemented by JOnAS.
027:         *
028:         */
029:        public class ConnectionFactoryImpl implements  ConnectionFactory,
030:                Referenceable, Serializable
031:
032:        {
033:            Reference reference;
034:            private ConnectionManager cm;
035:            private ManagedConnectionFactoryImpl mcf; // used in cm.allocateConnection
036:            private ConnectionSpecImpl cs; // ConnectionSpec
037:            protected boolean managed = true;
038:            private String userName = "";
039:            private String passWord = "";
040:            String cName = "ConnectionFactoryImpl";
041:
042:            //
043:            //  ConnectionFactory instance created during lookup() by Application Server
044:            // 
045:            public ConnectionFactoryImpl() {
046:            }
047:
048:            public ConnectionFactoryImpl(ManagedConnectionFactoryImpl mcf,
049:                    ConnectionManager cm) {
050:                this .mcf = mcf;
051:                this .cm = cm;
052:
053:            }
054:
055:            //
056:            // Container Managed Sign-on calls getConnection() from the Application Component
057:            //
058:            // Container-managed sign-on when deployment file contains line below
059:            //
060:            //  <res-auth>Container</res-auth>
061:            //
062:            public Connection getConnection() throws ResourceException {
063:                Utility.log(cName + ".getConnection"
064:                        + " (Container Managed Sign-on)");
065:                ConnectionImpl conn = null;
066:                try {
067:                    conn = (ConnectionImpl) getConnection(null);
068:                    return conn;
069:                } catch (ResourceException ex) {
070:                    throw ex;
071:                }
072:            }
073:
074:            //
075:            // Component Managed Sign-on calls getConnection(cs) directly from the Application Component
076:            //
077:            // Component-managed sign-on when file "connector.xml / secured.jar" contains line below
078:            //
079:            //  <res-auth>Application</res-auth>
080:            //
081:            public Connection getConnection(ConnectionSpec connectionspec)
082:                    throws ResourceException {
083:                ConnectionImpl conn = null;
084:                ConnectionSpecImpl cs = null;
085:                ConnectionRequestInfoImpl jcri = null; // 
086:
087:                if (connectionspec == null) {
088:                    mcf.setRes_Auth("Container");
089:                    Utility.log(cName + ".getConnection detected res-auth='"
090:                            + mcf.getRes_Auth() + "'");
091:                    // TODO what now? anything?
092:                    // now pass null to cm.allocateConnection(mcf, null);
093:                } else {
094:                    mcf.setRes_Auth("Application");
095:                    Utility.log(cName + ".getConnection detected res-auth='"
096:                            + mcf.getRes_Auth() + "'");
097:                    cs = (ConnectionSpecImpl) connectionspec;
098:                    // load user and password into ConnectionRequestInfo instance
099:                    jcri = new ConnectionRequestInfoImpl();
100:                    jcri.setUserName(cs.getUserName());
101:                    jcri.setPassword(cs.getPassword());
102:
103:                }
104:                Utility.log(cName
105:                        + ".getConnection calling cm.allocateConnection");
106:                try {
107:                    conn = (ConnectionImpl) cm.allocateConnection(mcf, jcri);
108:                    if (conn == null) {
109:                        Utility.log(cName
110:                                + ". getConnection, cm.allocateConnection"
111:                                + " error: Null connection object returned");
112:                        throw new ResourceException(
113:                                "Null connection object returned by allocateConnection");
114:                    }
115:                    conn.crii = jcri;
116:                    return conn;
117:                } catch (IllegalStateException is) {
118:                    Utility.log(cName + ".getConnection IllegalStateException"
119:                            + is);
120:                    throw is;
121:                } catch (ResourceException re) {
122:                    Utility.log(cName + ".getConnection ResourceException="
123:                            + re);
124:                    throw re;
125:                }
126:            }
127:
128:            public RecordFactory getRecordFactory() throws ResourceException {
129:                NotSupportedException nse = new NotSupportedException(
130:                        "RecordFactory is not currently supported");
131:                Utility.log(cName + ".getRecordFactory " + nse);
132:                throw nse;
133:            }
134:
135:            public ResourceAdapterMetaData getMetaData()
136:                    throws ResourceException {
137:                Utility.log(cName + ".getMetaData");
138:                ResourceAdapterMetaData rd = null; // TODO  do something
139:                return rd;
140:            }
141:
142:            public ConnectionManager getCM() {
143:                return cm;
144:            }
145:
146:            public ManagedConnectionFactoryImpl getMcf() {
147:                return mcf;
148:            }
149:
150:            //
151:            // *****************
152:            //    Reference
153:            // *****************
154:            //
155:            /** Required by the referencable attribute
156:             *  @param  ref Reference object
157:             **/
158:            public void setReference(javax.naming.Reference ref) {
159:                this .reference = ref;
160:            }
161:
162:            /** Required by the referencable attribute
163:             *  @return  Reference object
164:             **/
165:            public Reference getReference() throws NamingException {
166:                return reference;
167:            }
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.