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


001:        /*
002:         * Created on Jul 10, 2003
003:         *
004:         * ConnectionImpl.java is used to test the J2EE Connector
005:         * as implemented by JOnAS. This class implements the Connection Interface
006:         * and ConnectionMetaData Interface (cci) classes.
007:         *  
008:         */
009:        package fictional.resourceadapter;
010:
011:        import javax.resource.ResourceException;
012:        import javax.resource.NotSupportedException;
013:        import javax.resource.cci.*;
014:        import javax.resource.spi.ManagedConnection;
015:        import javax.resource.spi.ConnectionEvent;
016:        import org.objectweb.jonas.common.Log;
017:        import org.objectweb.util.monolog.api.Logger;
018:        import org.objectweb.util.monolog.api.BasicLevel;
019:
020:        /**
021:         * @author Bob Kruse
022:         *
023:         * Jtest Resource Adapter
024:         *
025:         * used to test the J2EE Connector as implemented by JOnAS.
026:         * 
027:         */
028:        public class ConnectionImpl implements  Connection, ConnectionMetaData,
029:                java.io.Serializable {
030:            public String product = "Fictional EIS"; // see J2eeConnectorTestBeanClient
031:            String version = "1.1";
032:            String UserName = "Fictional_User_Name"; //
033:            private ManagedConnection mc;
034:            public LocalTransactionImpl lt;
035:            boolean closed = false; // connection is closed
036:            private Logger logger = null;
037:            String cName = "";
038:            private boolean autoCommitMode = false;
039:
040:            //
041:            // *****************
042:            //    Connection    methods
043:            // *****************
044:            //
045:            public ConnectionImpl(Object mc) { // constructor for Connection
046:                if (logger == null) {
047:                    logger = Log.getLogger("fictional.resourceadapter");
048:                }
049:                logger.log(BasicLevel.DEBUG, impl(this ) + ".constructor");
050:                this .mc = (ManagedConnection) mc;
051:            }
052:
053:            private String impl(Object obj) {
054:                if (obj instanceof  Connection) {
055:                    return "ConnectionImpl";
056:                } else if (obj instanceof  ConnectionImpl) {
057:                    return "Connection";
058:                } else if (obj instanceof  ConnectionMetaData) {
059:                    return "ConnectionMetaData";
060:                } else
061:                    return "ConnectionImpl. Is this an error";
062:            }
063:
064:            //
065:            // close connection handle
066:            //
067:            public void close() throws ResourceException {
068:                logger.log(BasicLevel.DEBUG, impl(this )
069:                        + ".close with ConnectionEvent.CONNECTION_CLOSED="
070:                        + ConnectionEvent.CONNECTION_CLOSED);
071:                closed = true;
072:
073:                if (mc != null) {
074:                    try {
075:                        JtestResourceAdapter omc = (JtestResourceAdapter) mc;
076:                        omc.sendEvent(ConnectionEvent.CONNECTION_CLOSED, null,
077:                                this );
078:                        mc = null;
079:                        logger.log(BasicLevel.DEBUG, impl(this )
080:                                + ".close sendevent 'CONNECTION_CLOSED'");
081:                    } catch (ResourceException e) {
082:                        logger.log(BasicLevel.DEBUG, impl(this )
083:                                + ".close error: unable to close");
084:                        throw e;
085:                    }
086:                } else {
087:                    logger.log(BasicLevel.DEBUG, impl(this )
088:                            + ".close error: mc=null");
089:                }
090:                return;
091:            }
092:
093:            //
094:            // close physical connection
095:            //
096:            // The connectionErrorOccurred method indicates that the associated 
097:            // ManagedConnection instance is now invalid and unusable.
098:            // mc.sendEvent method makes the call to connectionErrorOccurred
099:            //
100:            public void close(int eType) throws ResourceException {
101:                logger.log(BasicLevel.DEBUG, impl(this ) + ".close(" + eType
102:                        + ")");
103:                closed = true;
104:
105:                if (mc != null) {
106:                    try {
107:                        JtestResourceAdapter omc = (JtestResourceAdapter) mc;
108:                        omc.sendEvent(eType, null, this );
109:                        mc = null;
110:                        logger.log(BasicLevel.DEBUG, impl(this )
111:                                + ".close(CONNECTION_ERROR_OCCURRED="
112:                                + ConnectionEvent.CONNECTION_ERROR_OCCURRED
113:                                + ") to " + "close physical connection");
114:                    } catch (ResourceException e) {
115:                        logger
116:                                .log(
117:                                        BasicLevel.DEBUG,
118:                                        impl(this )
119:                                                + ".close error: unable to close physical connection"
120:                                                + " with 'CONNECTION_ERROR_OCCURRED'");
121:                        throw e;
122:                    }
123:                } else {
124:                    logger.log(BasicLevel.DEBUG, impl(this )
125:                            + ".close error: mc=null already");
126:                }
127:                return;
128:            }
129:
130:            public Interaction createInteraction() throws ResourceException {
131:                logger.log(BasicLevel.DEBUG, impl(this ) + ".createInteraction");
132:                Interaction gi = new JtestInteraction(this , mc);
133:                // TODO Interaction gi = new Interaction(this, this.mc, lw);
134:                return gi;
135:            }
136:
137:            public ConnectionMetaData getMetaData() throws ResourceException {
138:                logger.log(BasicLevel.DEBUG, impl(this ) + ".getMetaData");
139:                ConnectionMetaData eisInfo = (ConnectionMetaData) new ConnectionImpl(
140:                        mc);
141:                return eisInfo;
142:            }
143:
144:            public LocalTransaction getLocalTransaction()
145:                    throws ResourceException {
146:                try {
147:                    JtestResourceAdapter jmc = (JtestResourceAdapter) mc;
148:                    lt = (LocalTransactionImpl) jmc.getLocalTransaction(true);
149:                    logger.log(BasicLevel.DEBUG, impl(this )
150:                            + ".getLocalTransaction lt=" + lt);
151:                } catch (Exception e) {
152:                    logger.log(BasicLevel.DEBUG, impl(this )
153:                            + ".getLocalTransaction error: " + e.getMessage()
154:                            + " <<<<<<<<<<<<");
155:                }
156:                return (lt);
157:            }
158:
159:            public ResultSetInfo getResultSetInfo() throws ResourceException {
160:                logger.log(BasicLevel.DEBUG, impl(this ) + ".getResultSetInfo");
161:                NotSupportedException nse = new NotSupportedException(
162:                        "getResultSetInfo is not supported");
163:                throw nse;
164:            }
165:
166:            public void associateConnection(ManagedConnection mc)
167:                    throws IllegalStateException {
168:                logger.log(BasicLevel.DEBUG, impl(this )
169:                        + ".associateConnection");
170:                this .mc = mc;
171:            }
172:
173:            public ManagedConnection getMC() throws ResourceException {
174:                logger.log(BasicLevel.DEBUG, impl(this ) + ".getMC mc="
175:                        + this .mc);
176:                return this .mc;
177:            }
178:
179:            public void setAutoCommit(boolean a) {
180:                autoCommitMode = a;
181:            }
182:
183:            public boolean getAutoCommit() {
184:                return autoCommitMode;
185:            }
186:
187:            //
188:            // **********************
189:            //    ConnectionMetaData    methods
190:            // **********************
191:            //
192:            //  The method getUserName returns the user name for an active connection as 
193:            //  known to the underlying EIS instance. The name corresponds the resource 
194:            //  principal under whose security context a connection to the EIS
195:            //  instance has been established.  (page 109 CA 1.0)
196:            //
197:            public String getEISProductName() throws ResourceException {
198:                return (product);
199:            }
200:
201:            public String getEISProductVersion() throws ResourceException {
202:                return (version);
203:            }
204:
205:            public String getUserName() throws ResourceException {
206:                return (UserName);
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.