* {@inheritDoc}
*/
public void loadXAResourcesAndItsConnections(List xaresList, List connList) {
//Done so as to initialize connectors-runtime before loading connector-resources. need a better way ?
ConnectorRuntime crt = connectorRuntimeProvider.get();
//Done so as to load all connector-modules. need to load only connector-modules instead of all apps
startupProvider.get();
Collection<ConnectorResource> connectorResources = getAllConnectorResources();
if (connectorResources == null || connectorResources.size() == 0) {
return;
}
List<ConnectorConnectionPool> connPools = new ArrayList<ConnectorConnectionPool>();
for (Resource resource : connectorResources) {
ConnectorResource connResource = (ConnectorResource) resource;
if(getResourcesUtil().isEnabled(connResource)) {
ResourceInfo resourceInfo = ConnectorsUtil.getResourceInfo(connResource);
ConnectorConnectionPool pool = ResourcesUtil.createInstance().getConnectorConnectionPoolOfResource(resourceInfo);
if (pool != null &&
ConnectorConstants.XA_TRANSACTION_TX_SUPPORT_STRING.equals(
getTransactionSupport(pool))) {
connPools.add(pool);
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("ConnectorsRecoveryResourceHandler loadXAResourcesAndItsConnections :: "
+ "adding : " + connResource.getPoolName());
}
}
}
}
loadAllConnectorResources();
if(_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Recovering pools : " + connPools.size());
}
for(ConnectorConnectionPool connPool : connPools){
PoolInfo poolInfo = ConnectorsUtil.getPoolInfo(connPool);
try {
String[] dbUserPassword = getdbUserPasswordOfConnectorConnectionPool(connPool);
if (dbUserPassword == null) {
continue;
}
String dbUser = dbUserPassword[0];
String dbPassword = dbUserPassword[1];
Subject subject = new Subject();
//If username or password of the connector connection pool
//is null a warning is logged and recovery continues with
//empty String username or password as the case may be,
//because some databases allow null[as in empty string]
//username [pointbase interprets this as "root"]/password.
if (dbPassword == null) {
dbPassword = "";
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST,
"datasource.xadatasource_nullpassword_error", poolInfo);
}
}
if (dbUser == null) {
dbUser = "";
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST,
"datasource.xadatasource_nulluser_error", poolInfo);
}
}
String rarName = connPool.getResourceAdapterName();
//TODO V3 JMS-RA ??
if (ConnectorAdminServiceUtils.isJMSRA(rarName)) {
if(_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Performing recovery for JMS RA, poolName " + poolInfo);
}
ManagedConnectionFactory[] mcfs =
crt.obtainManagedConnectionFactories(poolInfo);
_logger.log(Level.INFO, "JMS resource recovery has created CFs = " + mcfs.length);
for (int i = 0; i < mcfs.length; i++) {
PasswordCredential pc = new PasswordCredential(
dbUser, dbPassword.toCharArray());
pc.setManagedConnectionFactory(mcfs[i]);
Principal prin =
new ResourcePrincipal(dbUser, dbPassword);
subject.getPrincipals().add(prin);
subject.getPrivateCredentials().add(pc);
ManagedConnection mc = mcfs[i].
createManagedConnection(subject, null);
connList.add(mc);
try {
XAResource xares = mc.getXAResource();
if (xares != null) {
xaresList.add(xares);
}
} catch (ResourceException ex) {
// ignored. Not at XA_TRANSACTION level
}
}
} else {
ManagedConnectionFactory mcf =
crt.obtainManagedConnectionFactory(poolInfo);
PasswordCredential pc = new PasswordCredential(
dbUser, dbPassword.toCharArray());
pc.setManagedConnectionFactory(mcf);
Principal prin = new ResourcePrincipal(dbUser, dbPassword);
subject.getPrincipals().add(prin);