int serverPort =
((ManagedConnectionFactoryImpl) mcf).getServerPort().intValue();
try {
if (cxRequest instanceof QueueConnectionRequest) {
QueueConnectionFactory factory = QueueTcpConnectionFactory.create(hostName, serverPort);
setFactoryParameters((AbstractConnectionFactory) factory, (ManagedConnectionFactoryImpl) mcf);
((AbstractConnectionFactory) factory).setIdentityClassName(identityClass);
return factory.createQueueConnection(userName, password);
} else if (cxRequest instanceof TopicConnectionRequest) {
TopicConnectionFactory factory = TopicTcpConnectionFactory.create(hostName, serverPort);
setFactoryParameters((AbstractConnectionFactory) factory, (ManagedConnectionFactoryImpl) mcf);
((AbstractConnectionFactory) factory).setIdentityClassName(identityClass);
return factory.createTopicConnection(userName, password);
} else {
ConnectionFactory factory = TcpConnectionFactory.create(hostName, serverPort);
setFactoryParameters((AbstractConnectionFactory) factory, (ManagedConnectionFactoryImpl) mcf);
((AbstractConnectionFactory) factory).setIdentityClassName(identityClass);
return factory.createConnection(userName, password);
}
} catch (IllegalStateException exc) {
throw new CommException("Could not access the JORAM server: " + exc);
} catch (JMSSecurityException exc) {
throw new SecurityException("Invalid user identification: " + exc);