if (stopped)
throw new IllegalStateException("Stopped resource adapter.");
ActivationSpecImpl specImpl;
String userName;
ConnectionFactory cf = null;
XAConnection connection;
Vector resources = new Vector();
if (connections == null)
connections = new Hashtable();
try {
for (int i = 0; i < specs.length; i++) {
if (! (specs[i] instanceof ActivationSpecImpl))
throw new ResourceException("Provided ActivationSpec instance is not a JORAM activation spec.");
specImpl = (ActivationSpecImpl) specs[i];
if (! specImpl.getResourceAdapter().equals(this))
throw new ResourceException("Supplied ActivationSpec instance associated to an other ResourceAdapter.");
userName = specImpl.getUserName();
// The connection does not already exist: creating it.
if (! connections.containsKey(userName)) {
String password = specImpl.getPassword();
String identityClass = specImpl.getIdentityClass();
if (isHa) {
if (collocated) {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "haURL = " + haURL);
if (haURL != null) {
cf = HATcpConnectionFactory.create(haURL);
} else {
cf = HALocalConnectionFactory.create();
}
} else {
String urlHa = "hajoram://" + hostName + ":" + serverPort;
cf = HATcpConnectionFactory.create(urlHa);
}
} else {
if (collocated)
cf = LocalConnectionFactory.create();
else
cf = TcpConnectionFactory.create(hostName, serverPort);
}
cf.getParameters().connectingTimer = connectingTimer;
cf.getParameters().cnxPendingTimer = cnxPendingTimer;
cf.getParameters().txPendingTimer = txPendingTimer;
// set identity class for this connectionFactory.
cf.setIdentityClassName(identityClass);
connection = cf.createXAConnection(userName, password);
connections.put(userName, connection);
resources.add(connection.createXASession().getXAResource());
}