}
}
private ConnectionFactory getOrCreateConnectionFactory() {
if (connectionFactory == null) {
ConnectionFactory factory = new ConnectionFactory();
factory.setUsername(getUsername());
factory.setPassword(getPassword());
factory.setVirtualHost(getVhost());
factory.setHost(getHostname());
factory.setPort(getPortNumber());
if (getClientProperties() != null) {
factory.setClientProperties(getClientProperties());
}
factory.setConnectionTimeout(getConnectionTimeout());
factory.setRequestedChannelMax(getRequestedChannelMax());
factory.setRequestedFrameMax(getRequestedFrameMax());
factory.setRequestedHeartbeat(getRequestedHeartbeat());
if (getSslProtocol() != null) {
try {
if (getSslProtocol().equals("true")) {
factory.useSslProtocol();
} else if (getTrustManager() == null) {
factory.useSslProtocol(getSslProtocol());
} else {
factory.useSslProtocol(getSslProtocol(), getTrustManager());
}
} catch (NoSuchAlgorithmException e) {
throw new IllegalArgumentException("Invalid sslProtocol " + sslProtocol, e);
} catch (KeyManagementException e) {
throw new IllegalArgumentException("Invalid sslProtocol " + sslProtocol, e);
}
}
if (getAutomaticRecoveryEnabled() != null) {
factory.setAutomaticRecoveryEnabled(getAutomaticRecoveryEnabled());
}
if (getNetworkRecoveryInterval() != null) {
factory.setNetworkRecoveryInterval(getNetworkRecoveryInterval());
}
if (getTopologyRecoveryEnabled() != null) {
factory.setTopologyRecoveryEnabled(getTopologyRecoveryEnabled());
}
connectionFactory = factory;
}
return connectionFactory;
}