From acf9d2bc13c8982331493c84f296f5e1c84c3d6d Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Thu, 4 Nov 2010 13:40:45 -0400 Subject: [PATCH] INT-1554 polishing, finished restructuring of XmppNamespaceHandler --- .../XmppMessageInboundEndpointParser.java | 51 ++++++++++++++++++ .../xmpp/config/XmppNamespaceHandler.java | 54 +------------------ .../XmppRosterEventInboundEndpointParser.java | 51 ++++++++++++++++++ .../XmppRosterEventMessageDrivenEndpoint.java | 1 - 4 files changed, 103 insertions(+), 54 deletions(-) create mode 100644 spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/config/XmppMessageInboundEndpointParser.java create mode 100644 spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/config/XmppRosterEventInboundEndpointParser.java diff --git a/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/config/XmppMessageInboundEndpointParser.java b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/config/XmppMessageInboundEndpointParser.java new file mode 100644 index 0000000000..49fbee0e9e --- /dev/null +++ b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/config/XmppMessageInboundEndpointParser.java @@ -0,0 +1,51 @@ +/* + * Copyright 2002-2010 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.integration.xmpp.config; + +import org.springframework.beans.factory.support.BeanDefinitionBuilder; +import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser; +import org.springframework.beans.factory.xml.ParserContext; +import org.springframework.integration.config.xml.IntegrationNamespaceUtils; +import org.springframework.util.Assert; +import org.w3c.dom.Element; + +/** + * @author Josh Long + * @author Oleg Zhurakousky + * @since 2.0 + */ +public class XmppMessageInboundEndpointParser extends AbstractSingleBeanDefinitionParser { + + @Override + protected String getBeanClassName(Element element) { + return "org.springframework.integration.xmpp.messages.XmppMessageDrivenEndpoint"; + } + + @Override + protected boolean shouldGenerateIdAsFallback() { + return true; + } + + @Override + protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { + String connectionName = element.getAttribute("xmpp-connection"); + Assert.hasText(connectionName, "'xmpp-connection' must be defined"); + builder.addPropertyReference("xmppConnection", connectionName); + IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "channel", "requestChannel"); + IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "extract-payload"); + IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "auto-startup"); + } +} diff --git a/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/config/XmppNamespaceHandler.java b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/config/XmppNamespaceHandler.java index 7492f2ae3c..d85114054f 100644 --- a/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/config/XmppNamespaceHandler.java +++ b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/config/XmppNamespaceHandler.java @@ -16,25 +16,18 @@ package org.springframework.integration.xmpp.config; -import org.springframework.beans.factory.support.BeanDefinitionBuilder; -import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser; import org.springframework.beans.factory.xml.NamespaceHandlerSupport; -import org.springframework.beans.factory.xml.ParserContext; -import org.springframework.integration.config.xml.IntegrationNamespaceUtils; -import org.springframework.util.Assert; -import org.w3c.dom.Element; /** * This class parses the schema for XMPP support. * * @author Josh Long * @author Mark Fisher + * @author Oleg Zhurakousky * @since 2.0 */ public class XmppNamespaceHandler extends NamespaceHandlerSupport { - private static final String PACKAGE_NAME = "org.springframework.integration.xmpp"; - public void init() { // connection registerBeanDefinitionParser("xmpp-connection", new XmppConnectionParser()); @@ -49,49 +42,4 @@ public class XmppNamespaceHandler extends NamespaceHandlerSupport { registerBeanDefinitionParser("header-enricher", new XmppHeaderEnricherParser()); } - - private static class XmppMessageInboundEndpointParser extends AbstractSingleBeanDefinitionParser { - - @Override - protected String getBeanClassName(Element element) { - return PACKAGE_NAME + ".messages.XmppMessageDrivenEndpoint"; - } - - @Override - protected boolean shouldGenerateIdAsFallback() { - return true; - } - - @Override - protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { - String connectionName = element.getAttribute("xmpp-connection"); - Assert.hasText(connectionName, "'xmpp-connection' must be defined"); - builder.addPropertyReference("xmppConnection", connectionName); - IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "channel", "requestChannel"); - IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "extract-payload"); - IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "auto-startup"); - } - } - - private static class XmppRosterEventInboundEndpointParser extends AbstractSingleBeanDefinitionParser { - - @Override - protected String getBeanClassName(Element element) { - return PACKAGE_NAME + ".presence.XmppRosterEventMessageDrivenEndpoint"; - } - - @Override - protected boolean shouldGenerateIdAsFallback() { - return true; - } - - @Override - protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { - String connectionName = element.getAttribute("xmpp-connection"); - Assert.hasText(connectionName, "'xmpp-connection' must be defined"); - builder.addPropertyReference("xmppConnection", connectionName); - IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "channel", "requestChannel"); - IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "auto-startup"); - } - } } diff --git a/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/config/XmppRosterEventInboundEndpointParser.java b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/config/XmppRosterEventInboundEndpointParser.java new file mode 100644 index 0000000000..72c2478692 --- /dev/null +++ b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/config/XmppRosterEventInboundEndpointParser.java @@ -0,0 +1,51 @@ +/* + * Copyright 2002-2010 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.integration.xmpp.config; + +import org.springframework.beans.factory.support.BeanDefinitionBuilder; +import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser; +import org.springframework.beans.factory.xml.ParserContext; +import org.springframework.integration.config.xml.IntegrationNamespaceUtils; +import org.springframework.util.Assert; +import org.w3c.dom.Element; + +/** + * @author Josh Long + * @author Oleg Zhurakousky + * @since 2.0 + * + */ +public class XmppRosterEventInboundEndpointParser extends AbstractSingleBeanDefinitionParser { + + @Override + protected String getBeanClassName(Element element) { + return "org.springframework.integration.xmpp.presenceXmppRosterEventMessageDrivenEndpoint"; + } + + @Override + protected boolean shouldGenerateIdAsFallback() { + return true; + } + + @Override + protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { + String connectionName = element.getAttribute("xmpp-connection"); + Assert.hasText(connectionName, "'xmpp-connection' must be defined"); + builder.addPropertyReference("xmppConnection", connectionName); + IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "channel", "requestChannel"); + IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "auto-startup"); + } +} \ No newline at end of file diff --git a/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/presence/XmppRosterEventMessageDrivenEndpoint.java b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/presence/XmppRosterEventMessageDrivenEndpoint.java index a18310c673..0e376bbb45 100644 --- a/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/presence/XmppRosterEventMessageDrivenEndpoint.java +++ b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/presence/XmppRosterEventMessageDrivenEndpoint.java @@ -143,5 +143,4 @@ public class XmppRosterEventMessageDrivenEndpoint extends AbstractEndpoint { forwardRosterEventMessage(presence); } } - }