From 98633cec5d9b851bf3986c1b6c1236754c140e2e Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Fri, 1 Aug 2008 23:13:20 +0000 Subject: [PATCH] updated EndpointInterceptorParser.java --- .../config/EndpointInterceptorParser.java | 71 ++----------------- 1 file changed, 7 insertions(+), 64 deletions(-) diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/EndpointInterceptorParser.java b/org.springframework.integration/src/main/java/org/springframework/integration/config/EndpointInterceptorParser.java index 681fa33b36..89ee1c1e61 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/config/EndpointInterceptorParser.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/EndpointInterceptorParser.java @@ -19,74 +19,17 @@ package org.springframework.integration.config; import java.util.HashMap; import java.util.Map; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import org.springframework.beans.factory.config.RuntimeBeanReference; -import org.springframework.beans.factory.support.AbstractBeanDefinition; -import org.springframework.beans.factory.support.ManagedList; -import org.springframework.beans.factory.xml.NamespaceHandler; -import org.springframework.beans.factory.xml.ParserContext; -import org.springframework.util.Assert; - /** - * A helper class for parsing the sub-elements of an endpoint's - * interceptors element. - * * @author Mark Fisher */ -public class EndpointInterceptorParser { +public class EndpointInterceptorParser extends AbstractInterceptorParser { - private final Map parsers = new HashMap(); - - public EndpointInterceptorParser() { - this.parsers.put("transaction-interceptor", new TransactionInterceptorParser()); - this.parsers.put("concurrency-interceptor", new ConcurrencyInterceptorParser()); - } - - @SuppressWarnings("unchecked") - public ManagedList parseEndpointInterceptors(Element element, ParserContext parserContext) { - ManagedList interceptors = new ManagedList(); - NodeList childNodes = element.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 ("bean".equals(localName)) { - interceptors.add(new RuntimeBeanReference( - IntegrationNamespaceUtils.parseBeanDefinitionElement(childElement, parserContext))); - } - else if ("ref".equals(localName)) { - String ref = childElement.getAttribute("bean"); - interceptors.add(new RuntimeBeanReference(ref)); - } - else { - BeanDefinitionRegisteringParser parser = this.parsers.get(localName); - String interceptorBeanName = null; - if (parser == null) { - interceptorBeanName = handleNonstandardInterceptor(childElement, parserContext); - } - else { - interceptorBeanName = parser.parse(childElement, parserContext); - } - interceptors.add(new RuntimeBeanReference(interceptorBeanName)); - } - } - } - return interceptors; - } - - protected String handleNonstandardInterceptor(Element childElement, ParserContext parserContext) { - NamespaceHandler handler = parserContext.getReaderContext().getNamespaceHandlerResolver() - .resolve(childElement.getNamespaceURI()); - AbstractBeanDefinition interceptorDefinition = - ((AbstractBeanDefinition) handler.parse(childElement, parserContext)); - String beanName = (String) interceptorDefinition.getMetadataAttribute("interceptorName").getValue(); - Assert.hasText("No value for interceptorName provided by namespace handler for element '" - + childElement.getNodeName() + "'"); - return beanName; + @Override + protected Map getParserMap() { + Map parsers = new HashMap(); + parsers.put("transaction-interceptor", new TransactionInterceptorParser()); + parsers.put("concurrency-interceptor", new ConcurrencyInterceptorParser()); + return parsers; } }