static void checkAndFinalizeConfig(RemoteConfiguration config, RemoteRuntimeEngineBuilder builder ) {
if( builder instanceof RemoteJmsRuntimeEngineBuilderImpl ) {
RemoteJmsRuntimeEngineBuilderImpl jmsBuilder = (RemoteJmsRuntimeEngineBuilderImpl) builder;
// check
if( config.getUserName() == null ) {
throw new InsufficientInfoToBuildException("A user name is required to access the JMS queues!");
}
if( config.getPassword() == null ) {
throw new InsufficientInfoToBuildException("A password is required to access the JMS queues!");
}
// Connection Factory
if( jmsBuilder.createOwnFactory ) {
ConnectionFactory createdConnectionFactory = null;
if( jmsBuilder.hostName == null ) {
throw new InsufficientInfoToBuildException("A host name or IP address is required to create a JMS ConnectionFactory!");
}
if( jmsBuilder.jmsConnectorPort == null ) {
throw new InsufficientInfoToBuildException("A connector port is required to create a JMS ConnectionFactory!");
}
Map<String, Object> connParams;
if( config.getUseUssl() ) {
connParams = new HashMap<String, Object>(7);
connParams.put(TransportConstants.PORT_PROP_NAME, jmsBuilder.jmsConnectorPort);
connParams.put(TransportConstants.HOST_PROP_NAME, jmsBuilder.hostName);
jmsBuilder.checkKeyAndTruststoreInfo();
// SSL
connParams.put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
connParams.put(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME, jmsBuilder.keystorePassword);
connParams.put(TransportConstants.KEYSTORE_PATH_PROP_NAME, jmsBuilder.keystoreLocation);
connParams.put(TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME, jmsBuilder.truststorePassword);
connParams.put(TransportConstants.TRUSTSTORE_PATH_PROP_NAME, jmsBuilder.truststoreLocation);
} else {
// setup
connParams = new HashMap<String, Object>(3);
connParams.put(TransportConstants.PORT_PROP_NAME, jmsBuilder.jmsConnectorPort);
connParams.put(TransportConstants.HOST_PROP_NAME, jmsBuilder.hostName);
connParams.put(TransportConstants.SSL_ENABLED_PROP_NAME, false);
}
// create connection factory
createdConnectionFactory = new HornetQJMSConnectionFactory(false,
new TransportConfiguration(NettyConnectorFactory.class.getName(), connParams));
config.setConnectionFactory(createdConnectionFactory);
}
if( jmsBuilder.jbossServerHostName != null && jmsBuilder.remoteInitialContext == null ) {
jmsBuilder.remoteInitialContext = getRemoteJbossInitialContext(jmsBuilder.jbossServerHostName, config.getUserName(), config.getPassword());
}
if( jmsBuilder.remoteInitialContext != null ) {
// sets connection factory, if null
config.setRemoteInitialContext(jmsBuilder.remoteInitialContext);
} else {
config.checkValidJmsValues();
}
} else if( builder instanceof RemoteRestRuntimeEngineBuilderImpl ) {
if( config.getServerBaseRestUrl() == null ) {
throw new InsufficientInfoToBuildException("A URL is required to build the factory.");
}
if( config.getUserName() == null ) {
throw new InsufficientInfoToBuildException("A user name is required to build the factory.");
}
if( config.getPassword() == null ) {
throw new InsufficientInfoToBuildException("A password is required to build the factory.");
}
}
if( config.getExtraJaxbClasses() != null && ! config.getExtraJaxbClasses().isEmpty() ) {
if( config.getDeploymentId() == null ) {
throw new InsufficientInfoToBuildException("A deployment id is required if user-defined class instances are being sent.");
}
}
}