}
private void recoverJdbcXAResources( Vector xaresList, Vector connList) {
ResourcesUtil resourceUtil = ResourcesUtil.createInstance();
com.sun.enterprise.config.ConfigBean[] jdbcres = null;
try {
jdbcres = (com.sun.enterprise.config.serverbeans.JdbcResource[])
(resourceUtil.getJdbcResourcesAsMap().get(ResourcesUtil.RESOURCES));
} catch( ConfigException ce ) {
_logger.log(Level.WARNING, ce.getMessage() );
return;
}
if ( jdbcres == null || jdbcres.length == 0 ) {
return;
}
Set jdbcPools = new HashSet();
for (int i = 0; i < jdbcres.length; i++ ) {
try {
if ( resourceUtil.isEnabled( jdbcres[i]) ) {
com.sun.enterprise.config.serverbeans.JdbcConnectionPool
pool = resourceUtil.getJdbcConnectionPoolByName(
((com.sun.enterprise.config.serverbeans.JdbcResource)
jdbcres[i]).getPoolName() );
if ( pool != null &&
"javax.sql.XADataSource".equals(pool.getResType() ) ) {
jdbcPools.add( pool );
}
if (_logger.isLoggable(Level.FINE)){
_logger.fine( "ResourceInstaller:: recoverJdbcXAResources :: "
+ "adding : " + ((com.sun.enterprise.config.serverbeans.JdbcResource)
jdbcres[i]).getPoolName() );
}
}
} catch( ConfigException ce ) {
_logger.log(Level.WARNING, ce.getMessage() );
}
}
loadAllJdbcResources();
// Read from the transaction-service , if the replacement of
// Vendor XAResource class with our version required.
// If yes, put the mapping in the xaresourcewrappers properties.
Properties xaresourcewrappers = new Properties();
try {
ConfigContext ctx =
ApplicationServer.getServerContext().getConfigContext();
TransactionService txs =
ServerBeansFactory.getTransactionServiceBean(ctx);
xaresourcewrappers.put(
"oracle.jdbc.xa.client.OracleXADataSource",
"com.sun.enterprise.transaction.OracleXAResource");
ElementProperty[] eprops = txs.getElementProperty();
for(int i=0;i<eprops.length;i++){
String name = eprops[i].getName();
String value = eprops[i].getValue();
if(name.equals("oracle-xa-recovery-workaround")) {
if("false".equals(value)){
xaresourcewrappers.remove(
"oracle.jdbc.xa.client.OracleXADataSource");
}
} else if(name.equals("sybase-xa-recovery-workaround")) {
if(value.equals("true")) {
xaresourcewrappers.put(
"com.sybase.jdbc2.jdbc.SybXADataSource",
"com.sun.enterprise.transaction.SybaseXAResource");
}
}
}
}catch(ConfigException cex){
_logger.log(Level.INFO,"jdbc.config_error",cex);
}
ConnectorRuntime crt = ConnectorRuntime.getRuntime();
//for(int i=0; i<jdbcConnectionPools.length; ++i) {
Iterator iter = jdbcPools.iterator();
while( iter.hasNext() ) {
com.sun.enterprise.config.serverbeans.JdbcConnectionPool
jdbcConnectionPool = (com.sun.enterprise.config.serverbeans.JdbcConnectionPool)
iter.next();
if(jdbcConnectionPool.getResType()==null
|| jdbcConnectionPool.getName()==null
|| !jdbcConnectionPool.getResType().equals(
"javax.sql.XADataSource")) {
continue;
}
String poolName = jdbcConnectionPool.getName();
try {
String[] dbUserPassword =
resourceUtil.getdbUserPasswordOfJdbcConnectionPool(
jdbcConnectionPool);
String dbUser = dbUserPassword[0];
String dbPassword = dbUserPassword[1];
ManagedConnectionFactory fac =
crt.obtainManagedConnectionFactory(poolName);