Java Code Examples for org.apache.activemq.util.URISupport#parseComposite()

The following examples show how to use org.apache.activemq.util.URISupport#parseComposite() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JmsFactory.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
private static boolean isSSL(URI uri) {
    try {
        CompositeData compositeData = URISupport.parseComposite(uri);
        if ("ssl".equals(compositeData.getScheme())) {
            return true;
        }
        for(URI component : compositeData.getComponents()){
            if ("ssl".equals(component.getScheme())) {
                return true;
            }
        }
    } catch (URISyntaxException e) {
        throw new IllegalArgumentException("Attempting to initiate JMS with invalid composite URI [" + uri + "]", e);
    }
    return false;
}
 
Example 2
Source File: DiscoveryTransportNoBrokerTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
public void testSetDiscoveredBrokerProperties() throws Exception {
   final String extraParameterName = "connectionTimeout";
   final String extraParameterValue = "3000";
   final URI uri = new URI("discovery:(multicast://default)?initialReconnectDelay=100&" + DiscoveryListener.DISCOVERED_OPTION_PREFIX + extraParameterName + "=" + extraParameterValue);
   CompositeData compositeData = URISupport.parseComposite(uri);

   StubCompositeTransport compositeTransport = new StubCompositeTransport();
   DiscoveryTransport discoveryTransport = DiscoveryTransportFactory.createTransport(compositeTransport, compositeData, compositeData.getParameters());

   discoveryTransport.onServiceAdd(new DiscoveryEvent("tcp://localhost:61616"));
   assertEquals("expected added URI after discovery event", compositeTransport.getTransportURIs().length, 1);

   URI discoveredServiceURI = compositeTransport.getTransportURIs()[0];
   Map<String, String> parameters = URISupport.parseParameters(discoveredServiceURI);
   assertTrue("unable to add parameter to discovered service", parameters.containsKey(extraParameterName));
   assertEquals("incorrect value for parameter added to discovered service", parameters.get(extraParameterName), extraParameterValue);
}
 
Example 3
Source File: DiscoveryTransportNoBrokerTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
public void testSetDiscoveredStaticBrokerProperties() throws Exception {
   final String extraParameterName = "connectionTimeout";
   final String extraParameterValue = "3000";
   final URI uri = new URI("discovery:(static:tcp://localhost:61616)?initialReconnectDelay=100&" + DiscoveryListener.DISCOVERED_OPTION_PREFIX + extraParameterName + "=" + extraParameterValue);
   CompositeData compositeData = URISupport.parseComposite(uri);

   StubCompositeTransport compositeTransport = new StubCompositeTransport();
   DiscoveryTransport discoveryTransport = DiscoveryTransportFactory.createTransport(compositeTransport, compositeData, compositeData.getParameters());

   discoveryTransport.start();
   assertEquals("expected added URI after discovery event", 1, compositeTransport.getTransportURIs().length);

   URI discoveredServiceURI = compositeTransport.getTransportURIs()[0];
   Map<String, String> parameters = URISupport.parseParameters(discoveredServiceURI);
   assertTrue("unable to add parameter to discovered service", parameters.containsKey(extraParameterName));
   assertEquals("incorrect value for parameter added to discovered service", parameters.get(extraParameterName), extraParameterValue);
}
 
Example 4
Source File: JmsFactory.java    From nifi with Apache License 2.0 6 votes vote down vote up
private static boolean isSSL(URI uri) {
    try {
        CompositeData compositeData = URISupport.parseComposite(uri);
        if ("ssl".equals(compositeData.getScheme())) {
            return true;
        }
        for(URI component : compositeData.getComponents()){
            if ("ssl".equals(component.getScheme())) {
                return true;
            }
        }
    } catch (URISyntaxException e) {
        throw new IllegalArgumentException("Attempting to initiate JMS with invalid composite URI [" + uri + "]", e);
    }
    return false;
}
 
Example 5
Source File: DiscoveryTransportNoBrokerTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
public void testAddRemoveDiscoveredBroker() throws Exception {
   final URI uri = new URI("discovery:(multicast://default)?initialReconnectDelay=100&connectionTimeout=3000");
   CompositeData compositeData = URISupport.parseComposite(uri);

   StubCompositeTransport compositeTransport = new StubCompositeTransport();
   DiscoveryTransport discoveryTransport = DiscoveryTransportFactory.createTransport(compositeTransport, compositeData, compositeData.getParameters());

   final String serviceName = "tcp://localhost:61616";
   discoveryTransport.onServiceAdd(new DiscoveryEvent(serviceName));
   assertEquals("expected added URI after discovery event", 1, compositeTransport.getTransportURIs().length);

   discoveryTransport.onServiceRemove(new DiscoveryEvent(serviceName));
   assertEquals("expected URI removed after discovery event", 0, compositeTransport.getTransportURIs().length);
}
 
Example 6
Source File: ActiveMQ5Factory.java    From tomee with Apache License 2.0 5 votes vote down vote up
private BrokerService newDefaultBroker(final URI uri) throws Exception {
    final URISupport.CompositeData compositeData = URISupport.parseComposite(uri);
    final Map<String, String> params = new HashMap<>(compositeData.getParameters());

    final BrokerService brokerService = newPatchedBrokerService();

    IntrospectionSupport.setProperties(brokerService, params);
    if (!params.isEmpty()) {
        String msg = "There are " + params.size()
                + " Broker options that couldn't be set on the BrokerService."
                + " Check the options are spelled correctly."
                + " Unknown parameters=[" + params + "]."
                + " This BrokerService cannot be started.";
        throw new IllegalArgumentException(msg);
    }

    if (compositeData.getPath() != null) {
        brokerService.setBrokerName(compositeData.getPath());
    }

    for (final URI component : compositeData.getComponents()) {
        if ("network".equals(component.getScheme())) {
            brokerService.addNetworkConnector(component.getSchemeSpecificPart());
        } else if ("proxy".equals(component.getScheme())) {
            brokerService.addProxyConnector(component.getSchemeSpecificPart());
        } else {
            brokerService.addConnector(component);
        }
    }
    return brokerService;
}