public JMSConfiguration createJMSConfigurationFromEndpointInfo(Bus bus,
EndpointInfo endpointInfo,
EndpointReferenceType target,
boolean isConduit)
throws IOException {
JMSEndpoint endpoint = getExtensorsAndConfig(bus, endpointInfo, target, isConduit);
if (address != null) {
mapAddressToEndpoint(address, endpoint);
}
if (jmsConfig == null) {
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 (jmsConfig.isUsingEndpointInfo()) {
JndiTemplate jt = new JndiTemplate();
jt.setEnvironment(JMSOldConfigHolder.getInitialContextEnv(endpoint));
boolean pubSubDomain = endpoint.getJmsVariant().contains(JMSURIConstants.TOPIC);
JNDIConfiguration jndiConfig = new JNDIConfiguration();
jndiConfig.setJndiConnectionFactoryName(endpoint.getJndiConnectionFactoryName());
jmsConfig.setJndiTemplate(jt);
jndiConfig.setConnectionUserName(endpoint.getUsername());
jndiConfig.setConnectionPassword(endpoint.getPassword());
jmsConfig.setJndiConfig(jndiConfig);
if (endpoint.isSetReconnectOnException()) {
jmsConfig.setReconnectOnException(endpoint.isReconnectOnException());
}
jmsConfig.setDurableSubscriptionName(serverBehavior.getDurableSubscriberName());
jmsConfig.setExplicitQosEnabled(true);
if (jmsConfig.getMessageSelector() == null) {
jmsConfig.setMessageSelector(serverBehavior.getMessageSelector());
}
if (isConduit) {
if (runtimePolicy.isSetMessageType()) {
jmsConfig.setMessageType(runtimePolicy.getMessageType().value());
} else if (address == null) {
jmsConfig.setMessageType(JMSConstants.BYTE_MESSAGE_TYPE);
}
}
jmsConfig.setPubSubDomain(pubSubDomain);
jmsConfig.setPubSubNoLocal(true);
if (clientConfig.isSetClientReceiveTimeout()) {
jmsConfig.setReceiveTimeout(clientConfig.getClientReceiveTimeout());
}
if (clientConfig.isSetUseConduitIdSelector()) {
jmsConfig.setUseConduitIdSelector(clientConfig.isUseConduitIdSelector());
}
if (clientConfig.isSetConduitSelectorPrefix()) {
jmsConfig.setConduitSelectorPrefix(clientConfig.getConduitSelectorPrefix());
}
jmsConfig.setEnforceSpec(clientConfig.isEnforceSpec());
jmsConfig.setSubscriptionDurable(serverBehavior.isSetDurableSubscriberName());
jmsConfig.setDurableSubscriptionName(serverBehavior.getDurableSubscriberName());
jmsConfig.setDurableSubscriptionClientId(serverConfig.getDurableSubscriptionClientId());
if (sessionPool.isSetHighWaterMark()) {
jmsConfig.setMaxConcurrentConsumers(sessionPool.getHighWaterMark());
}
if (sessionPool.isSetLowWaterMark()) {
jmsConfig.setConcurrentConsumers(sessionPool.getLowWaterMark());
}
if (endpoint.isSetTimeToLive()) {
long timeToLive = endpoint.getTimeToLive();
jmsConfig.setTimeToLive(timeToLive);
}
if (endpoint.isSetUseJMS11()) {
jmsConfig.setUseJms11(endpoint.isUseJMS11());
}
if (serverBehavior.isSetTransactional()) {
jmsConfig.setSessionTransacted(serverBehavior.isTransactional());
}
boolean useJndi = endpoint.getJmsVariant().contains(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());
if (address != null) {
jmsConfig.setReplyToDestination(address.getJndiReplyToDestinationName());
}
} else {
// Use the default dynamic destination resolver
jmsConfig.setTargetDestination(endpoint.getDestinationName());
jmsConfig.setReplyDestination(endpoint.getReplyToName());
if (address != null) {
jmsConfig.setReplyToDestination(address.getJmsReplyToDestinationName());
}
}
}
String requestURI = endpoint.getRequestURI();
jmsConfig.setRequestURI(requestURI);
String targetService = endpoint.getParameter(JMSSpecConstants.TARGETSERVICE_PARAMETER_NAME);
jmsConfig.setTargetService(targetService);
return jmsConfig;
}