Config conf = provider.getConfig();
String pfx = "port." + name + ".";
/* Queue manager name */
queueMgr = conf.getString(pfx + "queuemgr");
if (queueMgr == null || queueMgr.equals(""))
throw new PortConfigurationException(this, "queue manager property (queuemgr) not set");
/* Connection mode */
connProps = new Hashtable();
String connMode = conf.getString(pfx + "connmode", "bindings");
if (connMode.equals("bindings"))
connProps.put(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_BINDINGS);
else if (connMode.equals("client"))
connProps.put(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_CLIENT);
else
throw new PortConfigurationException(this, "connection mode property (connmode) must be either 'bindings' or 'client'");
/* Connection properties */
String hostStr = conf.getString(pfx + "host");
String portStr = conf.getString(pfx + "port");
String chanStr = conf.getString(pfx + "channel");
String userStr = conf.getString(pfx + "user");
String passStr = conf.getString(pfx + "password");
if (connMode.equals("bindings")) {
if (hostStr != null && ! hostStr.equals("") ||
portStr != null & ! portStr.equals("") ||
chanStr != null & ! chanStr.equals("") ||
userStr != null & ! userStr.equals("") ||
passStr != null & ! passStr.equals(""))
throw new PortConfigurationException(this, "properties host, port, channel, user and password must not be defined when connection mode (connmode) is set to 'bindings'");
}
else {
if (hostStr == null || hostStr.equals(""))
throw new PortConfigurationException(this, "queue manager host property (host) not set");
connProps.put(MQC.HOST_NAME_PROPERTY, hostStr);
if (portStr != null && ! portStr.equals("")) {
try {
int portNum = Integer.parseInt(portStr);
connProps.put(MQC.PORT_PROPERTY, new Integer(portNum));
} catch (NumberFormatException ex) {
throw new PortConfigurationException(this, "queue manager port property (port) must be a valid integer");
}
}
if (chanStr == null || chanStr.equals(""))
throw new PortConfigurationException(this, "queue manager channel property (channel) not set");
connProps.put(MQC.CHANNEL_PROPERTY, chanStr);
if (userStr != null && ! userStr.equals(""))
connProps.put(MQC.USER_ID_PROPERTY, userStr);
if (passStr != null && ! passStr.equals(""))
connProps.put(MQC.PASSWORD_PROPERTY, passStr);