Using Asserts with IllegalArgumentException/IllegalStateException instead of ConfigurationException.

This commit is contained in:
Mark Fisher
2008-09-29 13:26:27 +00:00
parent e6f22df1bb
commit c76daa497d
2 changed files with 4 additions and 9 deletions

View File

@@ -23,7 +23,7 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.ConfigurationException;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
@@ -58,9 +58,7 @@ public abstract class AbstractRemotingGatewayParser extends AbstractSimpleBeanDe
@Override
protected final void postProcess(BeanDefinitionBuilder builder, Element element) {
String requestChannelRef = element.getAttribute("request-channel");
if (!StringUtils.hasText(requestChannelRef)) {
throw new ConfigurationException("a 'request-channel' reference is required");
}
Assert.hasText(requestChannelRef, "a 'request-channel' reference is required");
builder.addPropertyReference("requestChannel", requestChannelRef);
String replyChannel = element.getAttribute("reply-channel");
if (StringUtils.hasText(replyChannel)) {

View File

@@ -19,8 +19,7 @@ package org.springframework.integration.adapter.config;
import org.w3c.dom.Element;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.integration.ConfigurationException;
import org.springframework.util.StringUtils;
import org.springframework.util.Assert;
/**
* Base class for url-based remoting outbound gateway parsers.
@@ -37,9 +36,7 @@ public abstract class AbstractRemotingOutboundGatewayParser extends AbstractRemo
@Override
protected void doPostProcess(BeanDefinitionBuilder builder, Element element) {
String url = element.getAttribute("url");
if (!StringUtils.hasText(url)) {
throw new ConfigurationException("The 'url' attribute is required.");
}
Assert.hasText(url, "The 'url' attribute is required.");
builder.addConstructorArgValue(url);
}