Source Code Cross Referenced for connectorCASLR.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » jtests » beans » j2eeca » 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 » org.objectweb.jonas.jtests.beans.j2eeca 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // connectorCASLR.java
002:        // Stateless Session bean
003:
004:        package org.objectweb.jonas.jtests.beans.j2eeca;
005:
006:        import javax.ejb.CreateException;
007:        import javax.ejb.SessionBean;
008:        import javax.ejb.SessionContext;
009:        import javax.naming.InitialContext;
010:        import javax.resource.cci.ConnectionMetaData;
011:        import javax.resource.spi.ConnectionEvent;
012:
013:        import org.objectweb.jonas.common.Log;
014:        import org.objectweb.util.monolog.api.BasicLevel;
015:        import org.objectweb.util.monolog.api.Logger;
016:
017:        import fictional.resourceadapter.CommonClient;
018:        import fictional.resourceadapter.ConnectionImpl;
019:        import fictional.resourceadapter.JtestInteraction;
020:        import fictional.resourceadapter.JtestResourceAdapter;
021:
022:        /**
023:         *  -
024:         */
025:        public class connectorCASLR implements  SessionBean {
026:
027:            static private Logger logger = null;
028:            SessionContext ejbContext;
029:            private CommonClient cccf = null; //Common Client Connection Factory
030:            private JtestResourceAdapter mcf = null; //Managed Connection Factory
031:            private CommonClient csp = null; //ConnectionSpec
032:            private ConnectionImpl conn = null;
033:            InitialContext ic = null;
034:            JtestInteraction i = null;
035:            ConnectionMetaData cMetaData = null;
036:            String cName = "connectorCASLR";
037:
038:            // ------------------------------------------------------------------
039:            // SessionBean implementation
040:            // ------------------------------------------------------------------
041:
042:            public void setSessionContext(SessionContext ctx) {
043:                if (logger == null) {
044:                    logger = Log.getLogger("org.objectweb.jonas.jtests.j2eeca");
045:                }
046:                logger.log(BasicLevel.DEBUG, cName + ".setSessionContext");
047:                ejbContext = ctx;
048:            }
049:
050:            public void ejbRemove() {
051:                logger.log(BasicLevel.DEBUG, cName + ".ejbRemove");
052:            }
053:
054:            public void ejbCreate() throws CreateException {
055:                logger.log(BasicLevel.DEBUG, cName + ".ejbCreate");
056:            }
057:
058:            public void ejbPassivate() {
059:                logger.log(BasicLevel.DEBUG, cName + ".ejbPassivate");
060:            }
061:
062:            public void ejbActivate() {
063:                logger.log(BasicLevel.DEBUG, cName + ".ejbActivate");
064:            }
065:
066:            // ------------------------------------------------------------------
067:            // connectorCA implementation
068:            // ------------------------------------------------------------------
069:            /**
070:             * method1
071:             */
072:            public void method1(String rar_jndi_name, String testName)
073:                    throws Exception {
074:                logger.log(BasicLevel.DEBUG, "============================ "
075:                        + testName);
076:                try {
077:                    ic = new InitialContext();
078:                } catch (Exception e1) {
079:                    logger.log(BasicLevel.DEBUG, cName
080:                            + ".method1 error: InitialContext failed");
081:                    throw e1;
082:                }
083:                try {
084:                    cccf = (CommonClient) ic.lookup(rar_jndi_name);
085:                    logger.log(BasicLevel.DEBUG, cName + ".method1 : found "
086:                            + rar_jndi_name);
087:                } catch (Exception e2) {
088:                    logger.log(BasicLevel.DEBUG, cName
089:                            + ".method1 error: lookup failed for "
090:                            + rar_jndi_name);
091:                    throw e2;
092:                }
093:
094:                try {
095:                    csp = new CommonClient(); // get a new ConnectionSpec
096:                    logger.log(BasicLevel.DEBUG, cName
097:                            + ".method1 : ConnectionSpec o.k.");
098:
099:                } catch (Exception e3) {
100:                    logger.log(BasicLevel.DEBUG, cName
101:                            + ".method1 : new connection spec failed");
102:                    throw e3;
103:                }
104:                try {
105:                    conn = (ConnectionImpl) cccf.getConnection();
106:                    logger.log(BasicLevel.DEBUG, cName
107:                            + ".method1 : getConnection conn=" + conn);
108:                    if (conn == null) {
109:                        logger
110:                                .log(
111:                                        BasicLevel.DEBUG,
112:                                        cName
113:                                                + ".method1 error: getConnection returned null connection.");
114:                        throw new Exception("");
115:                    }
116:                } catch (Exception e4) {
117:                    logger.log(BasicLevel.DEBUG, cName
118:                            + ".method1 error: getConnection failed "
119:                            + e4.toString());
120:                    throw e4;
121:                }
122:                try {
123:                    i = (JtestInteraction) conn.createInteraction();
124:                } catch (Exception e5) {
125:                    logger.log(BasicLevel.DEBUG, cName
126:                            + ".method1 error: create interaction failed");
127:                    throw e5;
128:                }
129:                try {
130:                    cMetaData = (ConnectionMetaData) conn.getMetaData();
131:                } catch (Exception e6) {
132:                    logger.log(BasicLevel.DEBUG, cName
133:                            + ".method1 : get ConnectionMetaData failed");
134:                    throw e6;
135:                }
136:
137:            }
138:
139:            /**
140:             * closeUp
141:             */
142:            public void closeUp(int w) {
143:                try {
144:                    if (w > 0) {
145:                        // The CONNECTION_ERROR_OCCURRED indicates that the associated 
146:                        // ManagedConnection instance is now invalid and unusable.
147:                        conn.close(ConnectionEvent.CONNECTION_ERROR_OCCURRED);
148:                        logger.log(BasicLevel.DEBUG, cName
149:                                + ".closeUp : closed physical connection");
150:                    } else {
151:                        // The CONNECTION_CLOSED indicates that connection handle
152:                        // is closed, but physical connection still exists
153:                        conn.close();
154:                        logger.log(BasicLevel.DEBUG, cName
155:                                + ".closeUp : closed connection");
156:                    }
157:                } catch (Exception e) {
158:                    logger
159:                            .log(
160:                                    BasicLevel.DEBUG,
161:                                    cName
162:                                            + ".closeUp error: close handle/physical connection failed");
163:                }
164:            }
165:
166:            /**
167:             * JUnit tests
168:             */
169:            public boolean isConnectionSpec() {
170:                if (csp == null)
171:                    return false;
172:                else
173:                    return true;
174:            }
175:
176:            public boolean isConnection() {
177:                if (conn == null)
178:                    return false;
179:                else
180:                    return true;
181:            }
182:
183:            public boolean isInteraction() {
184:                if (i == null)
185:                    return false;
186:                else
187:                    return true;
188:            }
189:
190:            public String getConnectionProduct() throws Exception {
191:                String s;
192:                try {
193:                    s = cMetaData.getEISProductName();
194:                    logger
195:                            .log(
196:                                    BasicLevel.DEBUG,
197:                                    cName
198:                                            + ".getConnectionProduct : ConnectionMetaData.product="
199:                                            + s);
200:                } catch (Exception e) {
201:                    logger
202:                            .log(
203:                                    BasicLevel.DEBUG,
204:                                    cName
205:                                            + ".getConnectionProduct error: ConnectionMetaData.getEISProductName() failed");
206:                    throw e;
207:                }
208:                return s;
209:            }
210:
211:            /**
212:             * The application server calls setter methods on the ManagedConnectionFactory instance
213:             * to set various configuration properties on this instance. These properties provide
214:             * information required by the ManagedConnectionFactory instance to create physical
215:             * connections to the underlying EIS. The application server uses an existing property set
216:             * (configured during the deployment of a resource adapter) to set the required properties on
217:             * the ManagedConnectionFactory instance.
218:             * 
219:             */
220:            public String getServerName() throws Exception {
221:                logger.log(BasicLevel.DEBUG, cName + ".getServerName");
222:                mcf = (JtestResourceAdapter) cccf.getMcf(); // ManagedConnectionFactory    
223:                String cp1 = "null";
224:                if (mcf == null)
225:                    return cp1;
226:                try {
227:                    cp1 = mcf.getServerName();
228:                } catch (Exception e) {
229:                    logger.log(BasicLevel.DEBUG, cName
230:                            + ".getConfigurationProperty error: failed");
231:                    throw e;
232:                }
233:                return cp1;
234:            }
235:
236:            public String getProtocolProperty() throws Exception {
237:                logger.log(BasicLevel.DEBUG, cName + ".getProtocolProperty");
238:                mcf = (JtestResourceAdapter) cccf.getMcf(); // ManagedConnectionFactory    
239:                String p = "null";
240:                if (mcf == null)
241:                    return p;
242:                try {
243:                    p = mcf.getProtocol();
244:                } catch (Exception e) {
245:                    logger.log(BasicLevel.DEBUG, cName
246:                            + ".getProtocolProperty error: failed");
247:                    throw e;
248:                }
249:                return p;
250:            }
251:
252:            /**
253:             * After the newly created ManagedConnectionFactory instance has been configured with
254:             * its property set, the application server creates a new ConnectionManager instance.
255:             * true returned if ConnectionManager is valid
256:             */
257:            public boolean getCMInstance() {
258:                mcf = (JtestResourceAdapter) cccf.getMcf(); // ManagedConnectionFactory    
259:                if (mcf.getCM() == null) { // ConnectionManager not null
260:                    logger
261:                            .log(
262:                                    BasicLevel.DEBUG,
263:                                    cName
264:                                            + ".getCMInstance error: ConnectionManager is null");
265:                    return false;
266:                } else {
267:                    logger.log(BasicLevel.DEBUG, cName
268:                            + ".getCMInstance ConnectionManager is o.k.");
269:                    return true;
270:                }
271:            }
272:
273:            public int getMCF_Pwriter() {
274:                int here = 2;
275:                mcf = (JtestResourceAdapter) cccf.getMcf(); // ManagedConnectionFactory    
276:                try {
277:                    if (mcf.getLogWriter() == null) { // PrintWriter not null
278:                        logger.log(BasicLevel.DEBUG, cName
279:                                + ".getMCF_Pwriter No PrintWriter registered");
280:                        here = 0;
281:                    } else {
282:                        logger.log(BasicLevel.DEBUG, cName
283:                                + ".getMCF_Pwriter PrintWriter is o.k.");
284:                        here = 1;
285:                    }
286:                } catch (Exception e) {
287:                    logger.log(BasicLevel.DEBUG, cName
288:                            + ".getMCF_Pwriter error: " + e.toString());
289:                }
290:                return here;
291:            }
292:
293:            public int getMC_Pwriter() {
294:                int here = 2;
295:                ConnectionImpl conni = (ConnectionImpl) conn;
296:                try {
297:                    JtestResourceAdapter mc = (JtestResourceAdapter) conni
298:                            .getMC(); //get ManagedConnection        
299:                    if (mc.getLogWriter() == null) { // PrintWriter not null
300:                        logger
301:                                .log(
302:                                        BasicLevel.DEBUG,
303:                                        cName
304:                                                + ".getMC_Pwriter No PrintWriter registered in ManagedConnection");
305:                        here = 0;
306:                    } else {
307:                        logger
308:                                .log(
309:                                        BasicLevel.DEBUG,
310:                                        cName
311:                                                + ".getMC_Pwriter PrintWriter in ManagedConnection is o.k.");
312:                        here = 1;
313:                    }
314:                } catch (Exception e) {
315:                    logger.log(BasicLevel.DEBUG, cName
316:                            + ".getMC_Pwriter error: " + e.toString());
317:                }
318:                return here;
319:            }
320:
321:            public void setMatchNull(boolean b) {
322:                mcf = (JtestResourceAdapter) cccf.getMcf(); // ManagedConnectionFactory    
323:                mcf.setMatchNull(b);
324:            }
325:
326:            public int cntListeners() {
327:                int i = 0;
328:                ConnectionImpl conni = (ConnectionImpl) conn;
329:                try {
330:                    JtestResourceAdapter mc = (JtestResourceAdapter) conni
331:                            .getMC(); //get ManagedConnection        
332:                    i = mc.cntListeners();
333:                    logger.log(BasicLevel.DEBUG, cName + ".cntListeners cnt="
334:                            + i);
335:                } catch (Exception e) {
336:                    logger.log(BasicLevel.DEBUG, cName
337:                            + ".cntListeners error: failed to count Listeners");
338:                }
339:                return i;
340:            }
341:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.