if (destinationType.equals(QUEUE_TYPE)
|| destinationType.equals(TOPIC_TYPE))
{
String uri = null;
String name = null;
PortReference addr = new PortReference();
if (environment!=null) {
for (Object key : environment.keySet()) {
if (key.toString().equals(JNDI_URL_TAG))
uri = environment.getProperty(key.toString());
else
{
if (key.toString().equals(DESTINATION_NAME_TAG))
{
name = environment.getProperty(key.toString());
if ((destinationName != null) && !name.equals(destinationName))
throw new IllegalArgumentException("Destination name inconsistency: < "+name+", "+destinationName+" >");
}
else
addr.addExtension(key.toString(), environment.getProperty(key.toString()));
}
}
}
if (uri == null) {
uri = addr.getExtensionValue(Context.PROVIDER_URL) ;
}
if (uri == null) {
uri = Configuration.getJndiServerURL() ;
}
if (name == null)
name = destinationName;
addr.setAddress(getJmsAddress(uri, name));
addr.addExtension(DESTINATION_TYPE_TAG, destinationType);
addr.addExtension(DESTINATION_NAME_TAG, destinationName);
addr.addExtension(SPECIFICATION_VERSION_TAG, protocol);
if (connection != null)
addr.addExtension(CONNECTION_FACTORY_TAG, connection);
if (messageSelector != null)
addr.addExtension(MESSAGE_SELECTOR_TAG, messageSelector);
addr.addExtension(PERSISTENT_TAG, String.valueOf(peristent));
addr.addExtension(ACKNOWLEDGE_MODE_TAG, String.valueOf(AcknowledgeMode.getAckMode(acknowledgeModeStr)));
setAddr(addr);
if(username != null)
addr.addExtension(JMS_SECURITY_PRINCIPAL_TAG, username);
if(password != null)
addr.addExtension(JMS_SECURITY_CREDENTIAL_TAG, password);
addr.addExtension(TRANSACTED_TAG, String.valueOf(transacted));
}
else
throw new IllegalArgumentException("Invalid destination type! "+destinationType);
}
else