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.gjc.spi.ManagedConnectionFactory; 34 35 import com.sun.logging.*; 36 import java.util.logging.Logger ; 37 import java.util.logging.Level ; 38 import com.sun.enterprise.util.i18n.StringManager; 39 40 46 47 public class XAManagedConnectionFactory extends ManagedConnectionFactory { 48 49 private transient javax.sql.XADataSource xaDataSourceObj; 50 51 private static Logger _logger; 52 static { 53 _logger = LogDomains.getLogger( LogDomains.RSR_LOGGER ); 54 } 55 56 73 public javax.resource.spi.ManagedConnection createManagedConnection(javax.security.auth.Subject subject, 74 ConnectionRequestInfo cxRequestInfo) throws ResourceException { 75 if(logWriter != null) { 76 logWriter.println("In createManagedConnection"); 77 } 78 PasswordCredential pc = SecurityUtils.getPasswordCredential(this, subject, cxRequestInfo); 79 80 if(xaDataSourceObj == null) { 81 if(dsObjBuilder == null) { 82 dsObjBuilder = new DataSourceObjectBuilder(spec); 83 } 84 85 try { 86 xaDataSourceObj = (javax.sql.XADataSource ) dsObjBuilder.constructDataSourceObject(); 87 } catch(ClassCastException cce) { 88 _logger.log(Level.SEVERE, "jdbc.exc_cce_XA", cce); 89 throw new javax.resource.ResourceException (cce.getMessage()); 90 } 91 } 92 93 javax.sql.XAConnection xaConn = null; 94 95 try { 96 101 if ( isEqual( pc, getUser(), getPassword() ) ) { 102 xaConn = xaDataSourceObj.getXAConnection(); 103 } else { 104 xaConn = xaDataSourceObj.getXAConnection(pc.getUserName(), 105 new String (pc.getPassword())); 106 } 107 108 109 } catch(java.sql.SQLException sqle) { 110 _logger.log(Level.FINE, "jdbc.exc_create_xa_conn",sqle); 112 StringManager sm = StringManager.getManager( 113 DataSourceObjectBuilder.class ); 114 String msg = sm.getString( "jdbc.cannot_allocate_connection", sqle.getMessage() ); 115 ResourceAllocationException rae = new ResourceAllocationException ( 116 msg, sqle ); 117 throw rae; 118 } 119 120 com.sun.gjc.spi.ManagedConnection mc = constructManagedConnection( 121 xaConn, null, pc, this ); 122 123 mc.initializeConnectionType( ManagedConnection.ISXACONNECTION); 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.XAManagedConnectionFactory) { 147 com.sun.gjc.spi.XAManagedConnectionFactory otherMCF = 148 (com.sun.gjc.spi.XAManagedConnectionFactory) other; 149 return this.spec.equals(otherMCF.spec); 150 } 151 return false; 152 } 153 154 155 161 public void setserverName(String serverName) { 162 spec.setDetail(DataSourceSpec.SERVERNAME, serverName); 163 } 164 165 171 public String getserverName() { 172 return spec.getDetail(DataSourceSpec.SERVERNAME); 173 } 174 175 181 public void setServerName(String serverName) { 182 spec.setDetail(DataSourceSpec.SERVERNAME, serverName); 183 } 184 185 191 public String getServerName() { 192 return spec.getDetail(DataSourceSpec.SERVERNAME); 193 } 194 195 201 public void setportNumber(String portNumber) { 202 spec.setDetail(DataSourceSpec.PORTNUMBER, portNumber); 203 } 204 205 211 public String getportNumber() { 212 return spec.getDetail(DataSourceSpec.PORTNUMBER); 213 } 214 215 221 public void setPortNumber(String portNumber) { 222 spec.setDetail(DataSourceSpec.PORTNUMBER, portNumber); 223 } 224 225 231 public String getPortNumber() { 232 return spec.getDetail(DataSourceSpec.PORTNUMBER); 233 } 234 235 241 public void setdatabaseName(String databaseName) { 242 spec.setDetail(DataSourceSpec.DATABASENAME, databaseName); 243 } 244 245 251 public String getdatabaseName() { 252 return spec.getDetail(DataSourceSpec.DATABASENAME); 253 } 254 255 261 public void setDatabaseName(String databaseName) { 262 spec.setDetail(DataSourceSpec.DATABASENAME, databaseName); 263 } 264 265 271 public String getDatabaseName() { 272 return spec.getDetail(DataSourceSpec.DATABASENAME); 273 } 274 275 281 public void setdataSourceName(String dsn) { 282 spec.setDetail(DataSourceSpec.DATASOURCENAME, dsn); 283 } 284 285 291 public String getdataSourceName() { 292 return spec.getDetail(DataSourceSpec.DATASOURCENAME); 293 } 294 295 301 public void setDataSourceName(String dsn) { 302 spec.setDetail(DataSourceSpec.DATASOURCENAME, dsn); 303 } 304 305 311 public String getDataSourceName() { 312 return spec.getDetail(DataSourceSpec.DATASOURCENAME); 313 } 314 315 321 public void setdescription(String desc) { 322 spec.setDetail(DataSourceSpec.DESCRIPTION, desc); 323 } 324 325 331 public String getdescription() { 332 return spec.getDetail(DataSourceSpec.DESCRIPTION); 333 } 334 335 341 public void setDescription(String desc) { 342 spec.setDetail(DataSourceSpec.DESCRIPTION, desc); 343 } 344 345 351 public String getDescription() { 352 return spec.getDetail(DataSourceSpec.DESCRIPTION); 353 } 354 355 361 public void setnetworkProtocol(String nwProtocol) { 362 spec.setDetail(DataSourceSpec.NETWORKPROTOCOL, nwProtocol); 363 } 364 365 371 public String getnetworkProtocol() { 372 return spec.getDetail(DataSourceSpec.NETWORKPROTOCOL); 373 } 374 375 381 public void setNetworkProtocol(String nwProtocol) { 382 spec.setDetail(DataSourceSpec.NETWORKPROTOCOL, nwProtocol); 383 } 384 385 391 public String getNetworkProtocol() { 392 return spec.getDetail(DataSourceSpec.NETWORKPROTOCOL); 393 } 394 395 401 public void setroleName(String roleName) { 402 spec.setDetail(DataSourceSpec.ROLENAME, roleName); 403 } 404 405 411 public String getroleName() { 412 return spec.getDetail(DataSourceSpec.ROLENAME); 413 } 414 415 421 public void setRoleName(String roleName) { 422 spec.setDetail(DataSourceSpec.ROLENAME, roleName); 423 } 424 425 431 public String getRoleName() { 432 return spec.getDetail(DataSourceSpec.ROLENAME); 433 } 434 435 441 public void setmaxStatements(String maxStmts) { 442 spec.setDetail(DataSourceSpec.MAXSTATEMENTS, maxStmts); 443 } 444 445 451 public String getmaxStatements() { 452 return spec.getDetail(DataSourceSpec.MAXSTATEMENTS); 453 } 454 455 461 public void setMaxStatements(String maxStmts) { 462 spec.setDetail(DataSourceSpec.MAXSTATEMENTS, maxStmts); 463 } 464 465 471 public String getMaxStatements() { 472 return spec.getDetail(DataSourceSpec.MAXSTATEMENTS); 473 } 474 475 481 public void setinitialPoolSize(String initPoolSz) { 482 spec.setDetail(DataSourceSpec.INITIALPOOLSIZE, initPoolSz); 483 } 484 485 491 public String getinitialPoolSize() { 492 return spec.getDetail(DataSourceSpec.INITIALPOOLSIZE); 493 } 494 495 501 public void setInitialPoolSize(String initPoolSz) { 502 spec.setDetail(DataSourceSpec.INITIALPOOLSIZE, initPoolSz); 503 } 504 505 511 public String getInitialPoolSize() { 512 return spec.getDetail(DataSourceSpec.INITIALPOOLSIZE); 513 } 514 515 521 public void setminPoolSize(String minPoolSz) { 522 spec.setDetail(DataSourceSpec.MINPOOLSIZE, minPoolSz); 523 } 524 525 531 public String getminPoolSize() { 532 return spec.getDetail(DataSourceSpec.MINPOOLSIZE); 533 } 534 535 541 public void setMinPoolSize(String minPoolSz) { 542 spec.setDetail(DataSourceSpec.MINPOOLSIZE, minPoolSz); 543 } 544 545 551 public String getMinPoolSize() { 552 return spec.getDetail(DataSourceSpec.MINPOOLSIZE); 553 } 554 555 561 public void setmaxPoolSize(String maxPoolSz) { 562 spec.setDetail(DataSourceSpec.MAXPOOLSIZE, maxPoolSz); 563 } 564 565 571 public String getmaxPoolSize() { 572 return spec.getDetail(DataSourceSpec.MAXPOOLSIZE); 573 } 574 575 581 public void setMaxPoolSize(String maxPoolSz) { 582 spec.setDetail(DataSourceSpec.MAXPOOLSIZE, maxPoolSz); 583 } 584 585 591 public String getMaxPoolSize() { 592 return spec.getDetail(DataSourceSpec.MAXPOOLSIZE); 593 } 594 595 601 public void setmaxIdleTime(String maxIdleTime) { 602 spec.setDetail(DataSourceSpec.MAXIDLETIME, maxIdleTime); 603 } 604 605 611 public String getmaxIdleTime() { 612 return spec.getDetail(DataSourceSpec.MAXIDLETIME); 613 } 614 615 621 public void setMaxIdleTime(String maxIdleTime) { 622 spec.setDetail(DataSourceSpec.MAXIDLETIME, maxIdleTime); 623 } 624 625 631 public String getMaxIdleTime() { 632 return spec.getDetail(DataSourceSpec.MAXIDLETIME); 633 } 634 635 641 public void setpropertyCycle(String propCycle) { 642 spec.setDetail(DataSourceSpec.PROPERTYCYCLE, propCycle); 643 } 644 645 651 public String getpropertyCycle() { 652 return spec.getDetail(DataSourceSpec.PROPERTYCYCLE); 653 } 654 655 661 public void setPropertyCycle(String propCycle) { 662 spec.setDetail(DataSourceSpec.PROPERTYCYCLE, propCycle); 663 } 664 665 671 public String getPropertyCycle() { 672 return spec.getDetail(DataSourceSpec.PROPERTYCYCLE); 673 } 674 } 675 | Popular Tags |