}
public static JMSConfiguration getInitJMSConfiguration(String address) throws Exception {
JMSEndpoint endpoint = JMSEndpointParser.createEndpoint(address);
JMSConfiguration jmsConfig = new JMSConfiguration();
if (endpoint.isSetDeliveryMode()) {
int deliveryMode = endpoint.getDeliveryMode()
.equals(JMSURIConstants.DELIVERYMODE_PERSISTENT)
? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
jmsConfig.setDeliveryMode(deliveryMode);
}
if (endpoint.isSetPriority()) {
int priority = endpoint.getPriority();
jmsConfig.setPriority(priority);
}
if (endpoint.isSetTimeToLive()) {
long timeToLive = endpoint.getTimeToLive();
jmsConfig.setTimeToLive(timeToLive);
}
if (jmsConfig.isUsingEndpointInfo()) {
JndiTemplate jt = new JndiTemplate();
jt.setEnvironment(JMSOldConfigHolder.getInitialContextEnv(endpoint));
boolean pubSubDomain = false;
pubSubDomain = endpoint.getJmsVariant().equals(JMSURIConstants.TOPIC);
JNDIConfiguration jndiConfig = new JNDIConfiguration();
jndiConfig.setJndiConnectionFactoryName(endpoint.getJndiConnectionFactoryName());
jmsConfig.setJndiTemplate(jt);
jmsConfig.setJndiConfig(jndiConfig);
jmsConfig.setExplicitQosEnabled(true);
jmsConfig.setPubSubDomain(pubSubDomain);
jmsConfig.setPubSubNoLocal(true);
boolean useJndi = endpoint.getJmsVariant().equals(JMSURIConstants.JNDI);
if (useJndi) {
// Setup Destination jndi destination resolver
final JndiDestinationResolver jndiDestinationResolver = new JndiDestinationResolver();
jndiDestinationResolver.setJndiTemplate(jt);
jmsConfig.setDestinationResolver(jndiDestinationResolver);
jmsConfig.setTargetDestination(endpoint.getDestinationName());
jmsConfig.setReplyDestination(endpoint.getReplyToName());
} else {
// Use the default dynamic destination resolver
jmsConfig.setTargetDestination(endpoint.getDestinationName());
jmsConfig.setReplyDestination(endpoint.getReplyToName());
}
}
return jmsConfig;
}