This commit is contained in:
Mark Fisher
2009-06-15 12:09:39 +00:00
parent 1f0913088c
commit 6936e313b1
3 changed files with 22 additions and 4 deletions

View File

@@ -66,8 +66,10 @@ public abstract class AbstractConsumerEndpointParser extends AbstractBeanDefinit
String inputChannelAttributeName = this.getInputChannelAttributeName();
if (!element.hasAttribute(inputChannelAttributeName)) {
if (!parserContext.isNested()) {
String elementDescription = IntegrationNamespaceUtils.createElementDescription(element);
parserContext.getReaderContext().error("The '" + inputChannelAttributeName
+ "' attribute is required for this top-level endpoint element.", element);
+ "' attribute is required for the top-level endpoint element "
+ elementDescription + ".", element);
}
return handlerBeanDefinition;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 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.
@@ -31,6 +31,7 @@ import org.springframework.util.StringUtils;
*
* @author Mark Fisher
* @author Marius Bogoevici
* @author Alex Peters
*/
public abstract class IntegrationNamespaceUtils {
@@ -122,6 +123,20 @@ public abstract class IntegrationNamespaceUtils {
Conventions.attributeNameToPropertyName(attributeName));
}
/**
* Provides a user friendly description of an element based on its node
* name and, if available, its "id" attribute value. This is useful for
* creating error messages from within bean definition parsers.
*/
public static String createElementDescription(Element element) {
String elementId = "'" + element.getNodeName() + "'";
String id = element.getAttribute("id");
if (StringUtils.hasText(id)) {
elementId += " with id='" + id + "'";
}
return elementId;
}
/**
* Parse a "poller" element to provide a reference for the target
* BeanDefinitionBuilder. If the poller element does not contain a "ref"

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 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.
@@ -35,7 +35,8 @@ public class ServiceActivatorParser extends AbstractConsumerEndpointParser {
IntegrationNamespaceUtils.BASE_PACKAGE + ".handler.ServiceActivatingHandler");
String ref = element.getAttribute(REF_ATTRIBUTE);
if (!StringUtils.hasText(ref)) {
parserContext.getReaderContext().error("The '" + REF_ATTRIBUTE + "' attribute is required.", element);
parserContext.getReaderContext().error("The '" + REF_ATTRIBUTE + "' attribute is required for element "
+ IntegrationNamespaceUtils.createElementDescription(element) + ".", element);
}
builder.addConstructorArgReference(ref);
if (StringUtils.hasText(element.getAttribute(METHOD_ATTRIBUTE))) {