INT-1603 added namespace support for SearchInboundMessageSource
This commit is contained in:
@@ -34,6 +34,7 @@ public class TwitterNamespaceHandler extends AbstractIntegrationNamespaceHandler
|
||||
registerBeanDefinitionParser("inbound-channel-adapter", new TwitterReceivingMessageSourceParser());
|
||||
registerBeanDefinitionParser("dm-inbound-channel-adapter", new TwitterReceivingMessageSourceParser());
|
||||
registerBeanDefinitionParser("mentions-inbound-channel-adapter", new TwitterReceivingMessageSourceParser());
|
||||
registerBeanDefinitionParser("search-inbound-channel-adapter", new TwitterReceivingMessageSourceParser());
|
||||
|
||||
// outbound
|
||||
registerBeanDefinitionParser("outbound-channel-adapter", new TwitterSendingMessageHandlerParser());
|
||||
|
||||
@@ -27,6 +27,8 @@ import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.config.xml.AbstractPollingInboundChannelAdapterParser;
|
||||
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
|
||||
import org.springframework.integration.twitter.core.Twitter4jTemplate;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Parser for inbound Twitter Channel Adapters.
|
||||
@@ -49,12 +51,25 @@ public class TwitterReceivingMessageSourceParser extends AbstractPollingInboundC
|
||||
else if ("mentions-inbound-channel-adapter".equals(elementName)) {
|
||||
className = BASE_PACKAGE + ".inbound.MentionsReceivingMessageSource";
|
||||
}
|
||||
else if ("search-inbound-channel-adapter".equals(elementName)){
|
||||
className = BASE_PACKAGE + ".inbound.SearchReceivingMessageSource";
|
||||
}
|
||||
else {
|
||||
parserContext.getReaderContext().error("element '" + elementName + "' is not supported by this parser.", element);
|
||||
}
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(className);
|
||||
builder.addConstructorArgReference(element.getAttribute("twitter-template"));
|
||||
String templateBeanName = element.getAttribute("twitter-template");
|
||||
|
||||
if (!StringUtils.hasText(templateBeanName)){
|
||||
BeanDefinitionBuilder templateBuilder =
|
||||
BeanDefinitionBuilder.genericBeanDefinition("org.springframework.integration.twitter.core.Twitter4jTemplate");
|
||||
builder.addConstructorArgValue(templateBuilder.getBeanDefinition());
|
||||
} else {
|
||||
builder.addConstructorArgReference(templateBeanName);
|
||||
}
|
||||
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "auto-startup");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "query");
|
||||
String name = BeanDefinitionReaderUtils.registerWithGeneratedName(builder.getBeanDefinition(), parserContext.getRegistry());
|
||||
return new RuntimeBeanReference(name);
|
||||
}
|
||||
|
||||
@@ -43,6 +43,30 @@
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
|
||||
<xsd:element name="search-inbound-channel-adapter">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Configures an inbound channel adapter that consumes message (representing mentions of your handle)
|
||||
from twitter and sends Messages whose payloads are Status objects.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="inbound-twitter-type">
|
||||
<xsd:attribute name="query" type="xsd:string" use="required">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Twitter search query (e.g, #springintegration .
|
||||
For more info on Twitter queries please refer to this site: http://search.twitter.com/operators)
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="dm-inbound-channel-adapter">
|
||||
<xsd:annotation>
|
||||
@@ -95,7 +119,7 @@
|
||||
<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="id" type="xsd:string"/>
|
||||
<xsd:attribute name="twitter-template" use="required" type="xsd:string">
|
||||
<xsd:attribute name="twitter-template" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
|
||||
Reference in New Issue
Block a user