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);