Using Asserts with IllegalArgumentException/IllegalStateException instead of ConfigurationException.
This commit is contained in:
@@ -21,10 +21,10 @@ import java.rmi.registry.Registry;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.integration.ConfigurationException;
|
||||
import org.springframework.integration.adapter.config.AbstractRemotingOutboundGatewayParser;
|
||||
import org.springframework.integration.rmi.RmiInboundGateway;
|
||||
import org.springframework.integration.rmi.RmiOutboundGateway;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -51,9 +51,8 @@ public class RmiOutboundGatewayParser extends AbstractRemotingOutboundGatewayPar
|
||||
protected void doPostProcess(BeanDefinitionBuilder builder, Element element) {
|
||||
String host = element.getAttribute("host");
|
||||
String remoteChannel = element.getAttribute("remote-channel");
|
||||
if (!(StringUtils.hasText(host) && StringUtils.hasText(remoteChannel))) {
|
||||
throw new ConfigurationException("The 'host' and 'remote-channel' attributes are both required");
|
||||
}
|
||||
Assert.isTrue(StringUtils.hasText(host) && StringUtils.hasText(remoteChannel),
|
||||
"The 'host' and 'remote-channel' attributes are both required");
|
||||
String portAttribute = element.getAttribute("port");
|
||||
String port = StringUtils.hasText(portAttribute) ? portAttribute : "" + Registry.REGISTRY_PORT;
|
||||
String url = "rmi://" + host + ":" + port + "/" + RmiInboundGateway.SERVICE_NAME_PREFIX + remoteChannel;
|
||||
|
||||
@@ -25,12 +25,12 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
|
||||
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.ConfigurationException;
|
||||
import org.springframework.integration.channel.MessageChannel;
|
||||
import org.springframework.integration.config.IntegrationNamespaceUtils;
|
||||
import org.springframework.integration.security.channel.ChannelAccessPolicy;
|
||||
import org.springframework.integration.security.channel.ChannelInvocationDefinitionSource;
|
||||
import org.springframework.integration.security.channel.ChannelSecurityInterceptor;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
|
||||
@@ -75,9 +75,8 @@ public class SecuredChannelsParser extends AbstractSingleBeanDefinitionParser {
|
||||
Pattern pattern = Pattern.compile(accessPolicyElement.getAttribute("pattern"));
|
||||
String sendAccess = accessPolicyElement.getAttribute("send-access");
|
||||
String receiveAccess = accessPolicyElement.getAttribute("receive-access");
|
||||
if (!StringUtils.hasText(sendAccess) && !StringUtils.hasText(receiveAccess)) {
|
||||
throw new ConfigurationException("At least one of 'send-access' or 'receive-access' must be provided.");
|
||||
}
|
||||
Assert.isTrue(StringUtils.hasText(sendAccess) || StringUtils.hasText(receiveAccess),
|
||||
"At least one of 'send-access' or 'receive-access' must be provided.");
|
||||
objectDefinitionSource.addPatternMapping(pattern, new ChannelAccessPolicy(sendAccess, receiveAccess));
|
||||
}
|
||||
return objectDefinitionSource;
|
||||
|
||||
@@ -21,8 +21,6 @@ import java.util.Date;
|
||||
|
||||
import org.quartz.CronExpression;
|
||||
|
||||
import org.springframework.integration.ConfigurationException;
|
||||
|
||||
/**
|
||||
* A trigger that uses a cron expression.
|
||||
*
|
||||
@@ -39,8 +37,9 @@ public class CronTrigger implements Trigger {
|
||||
public CronTrigger(String expression) {
|
||||
try {
|
||||
this.expression = new CronExpression(expression);
|
||||
} catch (ParseException e) {
|
||||
throw new ConfigurationException(
|
||||
}
|
||||
catch (ParseException e) {
|
||||
throw new IllegalArgumentException(
|
||||
"failed to parse cron expression: " + expression);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user