static URI resolve(EndpointAddress address) throws EndpointAddressResolutionException { try { return address.getUri(); } catch (Exception ex) { throw new EndpointAddressResolutionException(address, ex); } } }
static URI resolve(EndpointAddress address) throws EndpointAddressResolutionException { try { return address.getUri(); } catch (Exception ex) { throw new EndpointAddressResolutionException(address, ex); } } }
public URI interpolate(EndpointAddress endpoint, Message message) throws InterpolationException { UriTemplate template = templateCache.getUnchecked(endpoint.getEndpoint()); String[] variables = template.getVariables(); if (variables.length > 0) { Map<String, Object> values = Maps.newHashMap(); String payload = new String(message.getData(), Charsets.UTF_8); for (String variable : variables) { JsonPath path = variableCompiler.getUnchecked(variable); try { values.put(variable, path.read(payload)); } catch (InvalidPathException e) { throw new InterpolationException(String.format("Missing variable on path %s", path.getPath()), e); } } try { return URI.create(template.expand(values)); } catch (VariableExpansionException e) { throw new InterpolationException("Cannot expand template", e); } } return endpoint.getUri(); }
public URI interpolate(EndpointAddress endpoint, Message message) throws InterpolationException { UriTemplate template = templateCache.getUnchecked(endpoint.getEndpoint()); String[] variables = template.getVariables(); if (variables.length > 0) { Map<String, Object> values = Maps.newHashMap(); String payload = new String(message.getData(), Charsets.UTF_8); for (String variable : variables) { JsonPath path = variableCompiler.getUnchecked(variable); try { values.put(variable, path.read(payload)); } catch (InvalidPathException e) { throw new InterpolationException(String.format("Missing variable on path %s", path.getPath()), e); } } try { return URI.create(template.expand(values)); } catch (VariableExpansionException e) { throw new InterpolationException("Cannot expand template", e); } } return endpoint.getUri(); }
@Override public MessageSender create(Subscription subscription) { EndpointAddress endpoint = subscription.getEndpoint(); URI uri = endpoint.getUri(); ConnectionFactory connectionFactory = getConnectionFactory(uri); JMSContext jmsContext = connectionFactory.createContext( endpoint.getUsername(), endpoint.getPassword() ); return new JmsMessageSender(jmsContext, extractTopicName(uri), metadataAppender); }
@Override public MessageSender create(Subscription subscription) { EndpointAddress endpoint = subscription.getEndpoint(); URI uri = endpoint.getUri(); ConnectionFactory connectionFactory = getConnectionFactory(uri); JMSContext jmsContext = connectionFactory.createContext( endpoint.getUsername(), endpoint.getPassword() ); return new JmsMessageSender(jmsContext, extractTopicName(uri), metadataAppender); }
@Test public void willReturnURIAsIsIfNoTemplate() throws InterpolationException { // given EndpointAddress endpoint = EndpointAddress.of("http://some.endpoint.com/"); // when URI interpolated = new MessageBodyInterpolator().interpolate(endpoint, SAMPLE_MSG); // then assertThat(interpolated).isEqualTo(endpoint.getUri()); }