if (endpointElement.hasAttribute("request-path")) {
requestPath = endpointElement.getAttribute("request-path");
} else {
requestPath = String.format("/%s.do", channelAdapterId);
}
subscriptionList.add(new Subscription().withEndpoint(
baseURI.concat(requestPath)).withProtocol(
baseURI.startsWith("https") ? "https" : "http"));
// register a HttpEndpoint at this path
BeanDefinitionBuilder httpEndpointBuilder = BeanDefinitionBuilder
.genericBeanDefinition(HttpEndpoint.class);
String beanName = String
.format("%s-httpEndpoint", channelAdapterId);
parserContext.registerBeanComponent(new BeanComponentDefinition(
httpEndpointBuilder.getBeanDefinition(), beanName,
new String[] { requestPath }));
snsExecutorBuilder.addPropertyReference("httpEndpoint", beanName);
}
// subscriptions element
Element subscriptionsElement = DomUtils.getChildElementByTagName(
element, "subscriptions");
if (subscriptionsElement != null) {
NodeList childNodes = subscriptionsElement.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node child = childNodes.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
Element childElement = (Element) child;
String localName = child.getLocalName();
if ("http".equals(localName)) {
String uri = childElement.getAttribute("base-uri");
if (childElement.hasAttribute("request-path")) {
uri = uri.concat(childElement
.getAttribute("request-path"));
}
subscriptionList.add(new Subscription().withEndpoint(
uri).withProtocol(
uri.startsWith("https") ? "https" : "http"));
} else if ("sqs".equals(localName)) {
String queueArn = null;
if (childElement.hasAttribute("queue-arn")) {
queueArn = childElement.getAttribute("queue-arn");
}
String queueId = null;
if (childElement.hasAttribute("queue-id")) {
queueId = childElement.getAttribute("queue-id");
}
Assert.state(queueArn != null || queueId != null,
"One of 'queue-arn' or 'queue-id' needs to be defined");
if (queueId != null) {
String sqsBeanName = SqsParserUtils
.getExecutorBeanName(queueId);
snsExecutorBuilder.addDependsOn(sqsBeanName);
sqsExecutorMap.put(queueId,
new RuntimeBeanReference(sqsBeanName));
subscriptionList.add(new Subscription()
.withEndpoint(queueId).withProtocol("sqs"));
} else {
subscriptionList
.add(new Subscription().withEndpoint(
queueArn).withProtocol("sqs"));
}
}
}
}