1 23 24 package com.sun.gjc.spi; 25 26 import javax.resource.ResourceException ; 27 import javax.resource.spi.ConnectionRequestInfo ; 28 import com.sun.gjc.common.DataSourceSpec; 29 import com.sun.gjc.common.DataSourceObjectBuilder; 30 import com.sun.gjc.util.SecurityUtils; 31 import javax.resource.spi.security.PasswordCredential ; 32 import javax.resource.spi.ResourceAllocationException ; 33 import com.sun.logging.*; 34 import java.util.logging.Logger ; 35 import java.util.logging.Level ; 36 import com.sun.enterprise.util.i18n.StringManager; 37 38 39 45 46 public class CPManagedConnectionFactory extends ManagedConnectionFactory { 47 48 private transient javax.sql.ConnectionPoolDataSource cpDataSourceObj; 49 50 private static Logger _logger; 51 static { 52 _logger = LogDomains.getLogger(LogDomains.RSR_LOGGER); 53 } 54 55 72 public javax.resource.spi.ManagedConnection createManagedConnection(javax.security.auth.Subject subject, 73 ConnectionRequestInfo cxRequestInfo) throws ResourceException { 74 if(logWriter != null) { 75 logWriter.println("In createManagedConnection"); 76 } 77 PasswordCredential pc = SecurityUtils.getPasswordCredential(this, subject, cxRequestInfo); 78 79 if(cpDataSourceObj == null) { 80 if(dsObjBuilder == null) { 81 dsObjBuilder = new DataSourceObjectBuilder(spec); 82 } 83 84 try { 85 cpDataSourceObj = (javax.sql.ConnectionPoolDataSource ) dsObjBuilder.constructDataSourceObject(); 86 } catch(ClassCastException cce) { 87 _logger.log(Level.SEVERE, "jdbc.exc_create_ds",cce); 88 throw new javax.resource.ResourceException (cce.getMessage(), cce); 89 } 90 } 91 92 javax.sql.PooledConnection cpConn = null; 93 94 try { 95 100 if ( isEqual( pc, getUser(), getPassword() ) ) { 101 cpConn = cpDataSourceObj.getPooledConnection(); 102 } else { 103 cpConn = cpDataSourceObj.getPooledConnection(pc.getUserName(), 104 new String (pc.getPassword())); 105 } 106 107 } catch(java.sql.SQLException sqle) { 108 _logger.log(Level.FINE, "jdbc.exc_create_ds_conn",sqle); 110 StringManager sm = 111 StringManager.getManager( DataSourceObjectBuilder.class); 112 String msg = sm.getString( "jdbc.cannot_allocate_connection", sqle.getMessage() ); 113 ResourceAllocationException rae = new ResourceAllocationException ( 114 msg, sqle ); 115 throw rae; 116 } 117 118 119 com.sun.gjc.spi.ManagedConnection mc = constructManagedConnection( 120 cpConn, null, pc, this ); 121 122 mc.initializeConnectionType( ManagedConnection.ISPOOLEDCONNECTION ); 123 124 validateAndSetIsolation( mc ); 126 return mc; 127 } 128 129 138 public boolean equals(Object other) { 139 if(logWriter != null) { 140 logWriter.println("In equals"); 141 } 142 146 if(other instanceof com.sun.gjc.spi.CPManagedConnectionFactory) { 147 com.sun.gjc.spi.CPManagedConnectionFactory otherMCF = 148 (com.sun.gjc.spi.CPManagedConnectionFactory) other; 149 return this.spec.equals(otherMCF.spec); 150 } 151 return false; 152 } 153 154 160 public void setserverName(String serverName) { 161 spec.setDetail(DataSourceSpec.SERVERNAME, serverName); 162 } 163 164 170 public String getserverName() { 171 return spec.getDetail(DataSourceSpec.SERVERNAME); 172 } 173 174 180 public void setServerName(String serverName) { 181 spec.setDetail(DataSourceSpec.SERVERNAME, serverName); 182 } 183 184 190 public String getServerName() { 191 return spec.getDetail(DataSourceSpec.SERVERNAME); 192 } 193 194 200 public void setportNumber(String portNumber) { 201 spec.setDetail(DataSourceSpec.PORTNUMBER, portNumber); 202 } 203 204 210 public String getportNumber() { 211 return spec.getDetail(DataSourceSpec.PORTNUMBER); 212 } 213 214 220 public void setPortNumber(String portNumber) { 221 spec.setDetail(DataSourceSpec.PORTNUMBER, portNumber); 222 } 223 224 230 public String getPortNumber() { 231 return spec.getDetail(DataSourceSpec.PORTNUMBER); 232 } 233 234 240 public void setdatabaseName(String databaseName) { 241 spec.setDetail(DataSourceSpec.DATABASENAME, databaseName); 242 } 243 244 250 public String getdatabaseName() { 251 return spec.getDetail(DataSourceSpec.DATABASENAME); 252 } 253 254 260 public void setDatabaseName(String databaseName) { 261 spec.setDetail(DataSourceSpec.DATABASENAME, databaseName); 262 } 263 264 270 public String getDatabaseName() { 271 return spec.getDetail(DataSourceSpec.DATABASENAME); 272 } 273 274 280 public void setdataSourceName(String dsn) { 281 spec.setDetail(DataSourceSpec.DATASOURCENAME, dsn); 282 } 283 284 290 public String getdataSourceName() { 291 return spec.getDetail(DataSourceSpec.DATASOURCENAME); 292 } 293 294 300 public void setDataSourceName(String dsn) { 301 spec.setDetail(DataSourceSpec.DATASOURCENAME, dsn); 302 } 303 304 310 public String getDataSourceName() { 311 return spec.getDetail(DataSourceSpec.DATASOURCENAME); 312 } 313 314 320 public void setdescription(String desc) { 321 spec.setDetail(DataSourceSpec.DESCRIPTION, desc); 322 } 323 324 330 public String getdescription() { 331 return spec.getDetail(DataSourceSpec.DESCRIPTION); 332 } 333 334 340 public void setDescription(String desc) { 341 spec.setDetail(DataSourceSpec.DESCRIPTION, desc); 342 } 343 344 350 public String getDescription() { 351 return spec.getDetail(DataSourceSpec.DESCRIPTION); 352 } 353 354 360 public void setnetworkProtocol(String nwProtocol) { 361 spec.setDetail(DataSourceSpec.NETWORKPROTOCOL, nwProtocol); 362 } 363 364 370 public String getnetworkProtocol() { 371 return spec.getDetail(DataSourceSpec.NETWORKPROTOCOL); 372 } 373 374 380 public void setNetworkProtocol(String nwProtocol) { 381 spec.setDetail(DataSourceSpec.NETWORKPROTOCOL, nwProtocol); 382 } 383 384 390 public String getNetworkProtocol() { 391 return spec.getDetail(DataSourceSpec.NETWORKPROTOCOL); 392 } 393 394 400 public void setroleName(String roleName) { 401 spec.setDetail(DataSourceSpec.ROLENAME, roleName); 402 } 403 404 410 public String getroleName() { 411 return spec.getDetail(DataSourceSpec.ROLENAME); 412 } 413 414 420 public void setRoleName(String roleName) { 421 spec.setDetail(DataSourceSpec.ROLENAME, roleName); 422 } 423 424 430 public String getRoleName() { 431 return spec.getDetail(DataSourceSpec.ROLENAME); 432 } 433 434 440 public void setmaxStatements(String maxStmts) { 441 spec.setDetail(DataSourceSpec.MAXSTATEMENTS, maxStmts); 442 } 443 444 450 public String getmaxStatements() { 451 return spec.getDetail(DataSourceSpec.MAXSTATEMENTS); 452 } 453 454 460 public void setMaxStatements(String maxStmts) { 461 spec.setDetail(DataSourceSpec.MAXSTATEMENTS, maxStmts); 462 } 463 464 470 public String getMaxStatements() { 471 return spec.getDetail(DataSourceSpec.MAXSTATEMENTS); 472 } 473 474 480 public void setinitialPoolSize(String initPoolSz) { 481 spec.setDetail(DataSourceSpec.INITIALPOOLSIZE, initPoolSz); 482 } 483 484 490 public String getinitialPoolSize() { 491 return spec.getDetail(DataSourceSpec.INITIALPOOLSIZE); 492 } 493 494 500 public void setInitialPoolSize(String initPoolSz) { 501 spec.setDetail(DataSourceSpec.INITIALPOOLSIZE, initPoolSz); 502 } 503 504 510 public String getInitialPoolSize() { 511 return spec.getDetail(DataSourceSpec.INITIALPOOLSIZE); 512 } 513 514 520 public void setminPoolSize(String minPoolSz) { 521 spec.setDetail(DataSourceSpec.MINPOOLSIZE, minPoolSz); 522 } 523 524 530 public String getminPoolSize() { 531 return spec.getDetail(DataSourceSpec.MINPOOLSIZE); 532 } 533 534 540 public void setMinPoolSize(String minPoolSz) { 541 spec.setDetail(DataSourceSpec.MINPOOLSIZE, minPoolSz); 542 } 543 544 550 public String getMinPoolSize() { 551 return spec.getDetail(DataSourceSpec.MINPOOLSIZE); 552 } 553 554 560 public void setmaxPoolSize(String maxPoolSz) { 561 spec.setDetail(DataSourceSpec.MAXPOOLSIZE, maxPoolSz); 562 } 563 564 570 public String getmaxPoolSize() { 571 return spec.getDetail(DataSourceSpec.MAXPOOLSIZE); 572 } 573 574 580 public void setMaxPoolSize(String maxPoolSz) { 581 spec.setDetail(DataSourceSpec.MAXPOOLSIZE, maxPoolSz); 582 } 583 584 590 public String getMaxPoolSize() { 591 return spec.getDetail(DataSourceSpec.MAXPOOLSIZE); 592 } 593 594 600 public void setmaxIdleTime(String maxIdleTime) { 601 spec.setDetail(DataSourceSpec.MAXIDLETIME, maxIdleTime); 602 } 603 604 610 public String getmaxIdleTime() { 611 return spec.getDetail(DataSourceSpec.MAXIDLETIME); 612 } 613 614 620 public void setMaxIdleTime(String maxIdleTime) { 621 spec.setDetail(DataSourceSpec.MAXIDLETIME, maxIdleTime); 622 } 623 624 630 public String getMaxIdleTime() { 631 return spec.getDetail(DataSourceSpec.MAXIDLETIME); 632 } 633 634 640 public void setpropertyCycle(String propCycle) { 641 spec.setDetail(DataSourceSpec.PROPERTYCYCLE, propCycle); 642 } 643 644 650 public String getpropertyCycle() { 651 return spec.getDetail(DataSourceSpec.PROPERTYCYCLE); 652 } 653 654 660 public void setPropertyCycle(String propCycle) { 661 spec.setDetail(DataSourceSpec.PROPERTYCYCLE, propCycle); 662 } 663 664 670 public String getPropertyCycle() { 671 return spec.getDetail(DataSourceSpec.PROPERTYCYCLE); 672 } 673 } 674 | Popular Tags |