in qpid-jms-discovery/src/main/java/org/apache/qpid/jms/provider/discovery/DiscoveryProviderFactory.java [57:120]
public Provider createProvider(URI remoteURI, ProviderFutureFactory futureFactory) throws Exception {
CompositeData composite = URISupport.parseComposite(remoteURI);
Map<String, String> options = composite.getParameters();
// Gather failover and discovery options.
Map<String, String> failoverOptions = PropertyUtil.filterProperties(options, FailoverProviderFactory.FAILOVER_OPTION_PREFIX);
Map<String, String> failoverNestedOptions = PropertyUtil.filterProperties(failoverOptions, FailoverProviderFactory.FAILOVER_NESTED_OPTION_PREFIX_ADDON);
Map<String, String> discoveryOptions = PropertyUtil.filterProperties(options, DISCOVERY_OPTION_PREFIX);
Map<String, String> discoveredOptions = PropertyUtil.filterProperties(discoveryOptions, DISCOVERY_DISCOVERED_OPTION_PREFIX_ADON);
// Combine the provider options, and the nested/discovered options.
Map<String, String> mainOptions = new HashMap<String, String>();
mainOptions.putAll(failoverOptions);
mainOptions.putAll(discoveryOptions);
Map<String, String> nestedOptions = new HashMap<String, String>();
nestedOptions.putAll(failoverNestedOptions);
nestedOptions.putAll(discoveredOptions);
Map<String, String> providerOptions = PropertyUtil.filterProperties(options, "provider.");
// If we have been given a futures factory to use then we ignore any URI options indicating
// what to create and just go with what we are given.
if (futureFactory == null) {
// Create a configured ProviderFutureFactory for use by the resulting AmqpProvider
futureFactory = ProviderFutureFactory.create(providerOptions);
if (!providerOptions.isEmpty()) {
String msg = ""
+ " Not all Provider options could be applied during Failover Provider creation."
+ " Check the options are spelled correctly."
+ " Unused parameters=[" + providerOptions + "]."
+ " This provider instance cannot be started.";
throw new IllegalArgumentException(msg);
}
}
// Failover will apply the nested options to each URI while attempting to connect.
FailoverProvider failover = new FailoverProvider(Collections.emptyList(), nestedOptions, futureFactory);
Map<String, String> leftOverDiscoveryOptions = PropertyUtil.setProperties(failover, mainOptions);
DiscoveryProvider discovery = new DiscoveryProvider(remoteURI, failover);
Map<String, String> unusedOptions = PropertyUtil.setProperties(discovery, leftOverDiscoveryOptions);
if (!unusedOptions.isEmpty()) {
String msg = ""
+ " Not all options could be set on the Discovery provider."
+ " Check the options are spelled correctly."
+ " Unused parameters=[" + unusedOptions + "]."
+ " This Provider cannot be started.";
throw new IllegalArgumentException(msg);
}
List<URI> agentURIs = composite.getComponents();
List<DiscoveryAgent> discoveryAgents = new ArrayList<DiscoveryAgent>(agentURIs.size());
for (URI agentURI : agentURIs) {
discoveryAgents.add(DiscoveryAgentFactory.createAgent(agentURI));
}
discovery.setDiscoveryAgents(discoveryAgents);
return discovery;
}