MessageHandlingException and MessageDeliveryException now require the failed/undelivered Message as a constructor argument.

This commit is contained in:
Mark Fisher
2008-04-09 00:18:56 +00:00
parent f6756da3c8
commit fec6dec258
153 changed files with 458 additions and 476 deletions

View File

@@ -50,7 +50,7 @@ public abstract class AbstractRemotingTargetAdapter implements MessageHandler {
return this.handlerProxy.handle(message);
}
catch (RemoteAccessException e) {
throw new MessageHandlingException("unable to handle message remotely", e);
throw new MessageHandlingException(message, "unable to handle message remotely", e);
}
}

View File

@@ -20,7 +20,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.channel.RequestReplyTemplate;
import org.springframework.integration.handler.MessageHandler;
@@ -100,7 +100,7 @@ public class MessageHandlingSourceAdapter implements SourceAdapter, MessageHandl
public final void afterPropertiesSet() throws Exception {
if (this.channel == null) {
throw new MessagingConfigurationException("The 'channel' property of '" + this.getClass().getName()
throw new ConfigurationException("The 'channel' property of '" + this.getClass().getName()
+ "' must not be null.");
}
synchronized (this.lifecycleMonitor) {
@@ -134,7 +134,7 @@ public class MessageHandlingSourceAdapter implements SourceAdapter, MessageHandl
this.afterPropertiesSet();
}
catch (Exception e) {
throw new MessagingConfigurationException("unable to initialize " + this.getClass().getName(), e);
throw new ConfigurationException("unable to initialize " + this.getClass().getName(), e);
}
}
if (!this.expectReply) {

View File

@@ -31,8 +31,8 @@ public class MessageMappingException extends MessageHandlingException {
super(failedMessage, description);
}
public MessageMappingException(String description, Throwable cause) {
super(description, cause);
public MessageMappingException(Message<?> failedMessage, String description, Throwable cause) {
super(failedMessage, description, cause);
}
}

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.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.util.StringUtils;
/**
@@ -57,7 +57,7 @@ public abstract class AbstractRequestReplySourceAdapterParser extends AbstractSi
protected void postProcess(BeanDefinitionBuilder builder, Element element) {
String channelRef = element.getAttribute("channel");
if (!StringUtils.hasText(channelRef)) {
throw new MessagingConfigurationException("a 'channel' reference is required");
throw new ConfigurationException("a 'channel' reference is required");
}
builder.addPropertyReference("channel", channelRef);
builder.addPropertyValue("expectReply", element.getAttribute("expect-reply").equals("true"));

View File

@@ -27,6 +27,7 @@ import org.springframework.integration.message.AbstractMessageMapper;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageHandlingException;
import org.springframework.integration.message.MessagingException;
import org.springframework.util.Assert;
import org.springframework.util.FileCopyUtils;
@@ -66,7 +67,7 @@ public abstract class AbstractFileMapper<T> extends AbstractMessageMapper<T, Fil
return file;
}
catch (Exception e) {
throw new MessageHandlingException("failure occurred mapping file to message", e);
throw new MessageHandlingException(message, "failure occurred mapping file to message", e);
}
}
@@ -86,11 +87,11 @@ public abstract class AbstractFileMapper<T> extends AbstractMessageMapper<T, Fil
return message;
}
catch (Exception e) {
String errorMessage = "failure occurred mapping file to message";
String description = "failure occurred mapping file to message";
if (logger.isWarnEnabled()) {
logger.warn(errorMessage, e);
logger.warn(description, e);
}
throw new MessageHandlingException(errorMessage, e);
throw new MessagingException(description, e);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -24,7 +24,7 @@ import java.util.Collection;
import java.util.List;
import org.springframework.integration.adapter.PollableSource;
import org.springframework.integration.message.MessageHandlingException;
import org.springframework.integration.message.MessagingException;
import org.springframework.util.Assert;
/**
@@ -66,7 +66,7 @@ public class FileSource implements PollableSource<File> {
files = this.directory.listFiles();
}
if (files == null) {
throw new MessageHandlingException("Problem occurred while polling for files. " +
throw new MessagingException("Problem occurred while polling for files. " +
"Is '" + directory.getAbsolutePath() + "' a directory?");
}
List<File> results = new ArrayList<File>();

View File

@@ -33,7 +33,7 @@ import org.springframework.integration.adapter.PollableSource;
import org.springframework.integration.adapter.PollingSourceAdapter;
import org.springframework.integration.adapter.file.ByteArrayFileMapper;
import org.springframework.integration.adapter.file.TextFileMapper;
import org.springframework.integration.message.MessageHandlingException;
import org.springframework.integration.message.MessagingException;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -129,10 +129,10 @@ public class FtpSourceAdapter extends PollingSourceAdapter<File> implements Poll
LinkedList<File> localFileList = new LinkedList<File>();
this.client.connect(this.host, this.port);
if (!StringUtils.hasText(this.username)) {
throw new MessageHandlingException("username is required");
throw new MessagingException("username is required");
}
if (!this.client.login(this.username, this.password)) {
throw new MessageHandlingException("Login failed. Please check the username and password.");
throw new MessagingException("Login failed. Please check the username and password.");
}
if (logger.isDebugEnabled()) {
logger.debug("login successful");
@@ -140,7 +140,7 @@ public class FtpSourceAdapter extends PollingSourceAdapter<File> implements Poll
this.client.setFileType(FTP.IMAGE_FILE_TYPE);
if (!this.remoteWorkingDirectory.equals(this.client.printWorkingDirectory())
&& !this.client.changeWorkingDirectory(this.remoteWorkingDirectory)) {
throw new MessageHandlingException("Could not change directory to '" +
throw new MessagingException("Could not change directory to '" +
remoteWorkingDirectory + "'. Please check the path.");
}
if (logger.isDebugEnabled()) {
@@ -176,9 +176,9 @@ public class FtpSourceAdapter extends PollingSourceAdapter<File> implements Poll
}
}
catch (IOException ioe) {
throw new MessageHandlingException("Error when disconnecting from ftp.", ioe);
throw new MessagingException("Error when disconnecting from ftp.", ioe);
}
throw new MessageHandlingException("Error while polling for messages.", e);
throw new MessagingException("Error while polling for messages.", e);
}
}

View File

@@ -25,7 +25,7 @@ import javax.servlet.http.HttpServletResponse;
import org.springframework.integration.adapter.MessageHandlingSourceAdapter;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.handler.MessageHandler;
import org.springframework.integration.message.MessageHandlingException;
import org.springframework.integration.message.MessagingException;
import org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter;
import org.springframework.web.HttpRequestHandler;
@@ -85,7 +85,7 @@ public class HttpInvokerSourceAdapter extends MessageHandlingSourceAdapter imple
public void handleRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
if (this.exporter == null) {
throw new MessageHandlingException("adapter has not been initialized");
throw new MessagingException("adapter has not been initialized");
}
this.exporter.handleRequest(request, response);
}

View File

@@ -23,7 +23,7 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.adapter.httpinvoker.HttpInvokerTargetAdapter;
import org.springframework.integration.endpoint.DefaultMessageEndpoint;
import org.springframework.integration.scheduling.Subscription;
@@ -53,10 +53,10 @@ public class HttpInvokerTargetAdapterParser extends AbstractSingleBeanDefinition
String channel = element.getAttribute("channel");
String url = element.getAttribute("url");
if (!StringUtils.hasText(channel)) {
throw new MessagingConfigurationException("The 'channel' attribute is required.");
throw new ConfigurationException("The 'channel' attribute is required.");
}
if (!StringUtils.hasText(url)) {
throw new MessagingConfigurationException("The 'url' attribute is required.");
throw new ConfigurationException("The 'url' attribute is required.");
}
adapterDef.getConstructorArgumentValues().addGenericArgumentValue(url);
String adapterBeanName = parserContext.getReaderContext().generateBeanName(adapterDef);

View File

@@ -20,7 +20,7 @@ import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.adapter.MessageHeaderMapper;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.support.converter.MessageConverter;
@@ -105,7 +105,7 @@ public abstract class AbstractJmsTemplateBasedAdapter implements InitializingBea
}
if (this.jmsTemplate == null) {
if (this.connectionFactory == null || (this.destination == null && this.destinationName == null)) {
throw new MessagingConfigurationException("Either a 'jmsTemplate' or " +
throw new ConfigurationException("Either a 'jmsTemplate' or " +
"*both* 'connectionFactory' and 'destination' (or 'destination-name') are required.");
}
this.jmsTemplate = this.createDefaultJmsTemplate();

View File

@@ -18,10 +18,10 @@ package org.springframework.integration.adapter.jms;
import javax.jms.MessageListener;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageDeliveryException;
import org.springframework.integration.message.MessagingException;
import org.springframework.jms.support.converter.MessageConverter;
import org.springframework.util.Assert;
@@ -54,7 +54,7 @@ public class ChannelPublishingJmsListener implements MessageListener {
public void onMessage(javax.jms.Message jmsMessage) {
if (this.channel == null) {
throw new MessagingConfigurationException("'channel' must not be null");
throw new ConfigurationException("'channel' must not be null");
}
try {
Message<?> messageToSend = (Message<?>) this.converter.fromMessage(jmsMessage);
@@ -66,7 +66,7 @@ public class ChannelPublishingJmsListener implements MessageListener {
}
}
catch (Exception e) {
throw new MessageDeliveryException("failed to convert JMS Message", e);
throw new MessagingException("failed to convert and send JMS Message", e);
}
}

View File

@@ -25,8 +25,8 @@ import javax.jms.Destination;
import javax.jms.JMSException;
import org.springframework.integration.adapter.MessageHeaderMapper;
import org.springframework.integration.adapter.MessageMappingException;
import org.springframework.integration.message.MessageHeader;
import org.springframework.integration.message.MessagingException;
import org.springframework.util.StringUtils;
/**
@@ -69,7 +69,7 @@ public class DefaultJmsHeaderMapper implements MessageHeaderMapper<javax.jms.Mes
}
}
catch (JMSException e) {
throw new MessageMappingException("failed to map from MessageHeader", e);
throw new MessagingException("failed to map from MessageHeader", e);
}
}
@@ -97,7 +97,7 @@ public class DefaultJmsHeaderMapper implements MessageHeaderMapper<javax.jms.Mes
}
}
catch (JMSException e) {
throw new MessageMappingException("failed to map to MessageHeader", e);
throw new MessagingException("failed to map to MessageHeader", e);
}
}

View File

@@ -22,7 +22,7 @@ import javax.jms.Session;
import org.springframework.integration.adapter.MessageHeaderMapper;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageHandlingException;
import org.springframework.integration.message.MessagingException;
import org.springframework.jms.support.converter.MessageConversionException;
import org.springframework.jms.support.converter.MessageConverter;
import org.springframework.jms.support.converter.SimpleMessageConverter;
@@ -59,7 +59,7 @@ public class HeaderMappingMessageConverter implements MessageConverter {
public javax.jms.Message toMessage(Object object, Session session) throws JMSException, MessageConversionException {
if (!(object instanceof Message<?>)) {
throw new MessageHandlingException("expected a '" + Message.class.getName() +
throw new MessagingException("expected a '" + Message.class.getName() +
"', but received '" + object.getClass() + "'");
}
Message<?> message = (Message<?>) object;

View File

@@ -23,7 +23,7 @@ import javax.jms.Session;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.context.Lifecycle;
import org.springframework.core.task.TaskExecutor;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.adapter.AbstractSourceAdapter;
import org.springframework.jms.listener.AbstractJmsListeningContainer;
import org.springframework.jms.listener.DefaultMessageListenerContainer;
@@ -113,7 +113,7 @@ public class JmsMessageDrivenSourceAdapter extends AbstractSourceAdapter<Object>
private void initDefaultContainer() {
if (this.connectionFactory == null || (this.destination == null && this.destinationName == null)) {
throw new MessagingConfigurationException("If a 'container' reference is not provided, then "
throw new ConfigurationException("If a 'container' reference is not provided, then "
+ "'connectionFactory' and 'destination' (or 'destinationName') are required.");
}
DefaultMessageListenerContainer dmlc = new DefaultMessageListenerContainer();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -20,9 +20,9 @@ import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.integration.adapter.MessageMappingException;
import org.springframework.integration.message.AbstractMessageMapper;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageHandlingException;
import org.springframework.mail.MailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMailMessage;
@@ -71,7 +71,7 @@ public class ByteArrayMailMessageMapper extends AbstractMessageMapper<byte[], Ma
return new MimeMailMessage(helper);
}
catch (MessagingException e) {
throw new MessageHandlingException("failed to create MimeMessage", e);
throw new MessageMappingException(message, "failed to create MimeMessage", e);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -24,7 +24,7 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.adapter.mail.MailTargetAdapter;
import org.springframework.integration.endpoint.DefaultMessageEndpoint;
import org.springframework.integration.scheduling.Subscription;
@@ -59,7 +59,7 @@ public class MailTargetAdapterParser extends AbstractSingleBeanDefinitionParser
String headerGeneratorRef = element.getAttribute("header-generator");
if (StringUtils.hasText(mailSenderRef)) {
if (StringUtils.hasText(host) || StringUtils.hasText(username) || StringUtils.hasText(password)) {
throw new MessagingConfigurationException("The 'host', 'username', and 'password' properties " +
throw new ConfigurationException("The 'host', 'username', and 'password' properties " +
"should not be provided when using a 'mail-sender' reference.");
}
adapterDef.getConstructorArgumentValues().addGenericArgumentValue(new RuntimeBeanReference(mailSenderRef));
@@ -76,7 +76,7 @@ public class MailTargetAdapterParser extends AbstractSingleBeanDefinitionParser
adapterDef.getConstructorArgumentValues().addGenericArgumentValue(mailSender);
}
else {
throw new MessagingConfigurationException("Either a 'mail-sender' reference or 'host' property is required.");
throw new ConfigurationException("Either a 'mail-sender' reference or 'host' property is required.");
}
if (StringUtils.hasText(headerGeneratorRef)) {
adapterDef.getPropertyValues().addPropertyValue(

View File

@@ -19,7 +19,7 @@ package org.springframework.integration.adapter.rmi;
import java.rmi.RemoteException;
import java.rmi.registry.Registry;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.adapter.MessageHandlingSourceAdapter;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.handler.MessageHandler;
@@ -68,7 +68,7 @@ public class RmiSourceAdapter extends MessageHandlingSourceAdapter {
public void initialize() throws RemoteException {
String channelName = this.getChannel().getName();
if (channelName == null) {
throw new MessagingConfigurationException("RmiSourceAdapter's MessageChannel must have a 'name'");
throw new ConfigurationException("RmiSourceAdapter's MessageChannel must have a 'name'");
}
RmiServiceExporter exporter = new RmiServiceExporter();
if (this.registryHost != null) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -23,7 +23,7 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.adapter.rmi.RmiSourceAdapter;
import org.springframework.integration.adapter.rmi.RmiTargetAdapter;
import org.springframework.integration.endpoint.DefaultMessageEndpoint;
@@ -55,7 +55,7 @@ public class RmiTargetAdapterParser extends AbstractSingleBeanDefinitionParser {
String localChannel = element.getAttribute("local-channel");
String remoteChannel = element.getAttribute("remote-channel");
if (!(StringUtils.hasText(host) && StringUtils.hasText(localChannel) && StringUtils.hasText(remoteChannel))) {
throw new MessagingConfigurationException(
throw new ConfigurationException(
"The 'host', 'local-channel', and 'remote-channel' attributes are all required");
}
String portAttribute = element.getAttribute("port");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -24,7 +24,7 @@ import java.util.Collection;
import java.util.List;
import org.springframework.integration.adapter.PollableSource;
import org.springframework.integration.message.MessageDeliveryException;
import org.springframework.integration.message.MessagingException;
/**
* A pollable source for receiving bytes from an {@link InputStream}.
@@ -94,7 +94,7 @@ public class ByteStreamSource implements PollableSource<byte[]> {
}
}
catch (IOException e) {
throw new MessageDeliveryException("IO failure occurred in adapter", e);
throw new MessagingException("IO failure occurred in adapter", e);
}
}
return results;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -21,7 +21,7 @@ import java.io.IOException;
import java.io.OutputStream;
import org.springframework.integration.adapter.AbstractTargetAdapter;
import org.springframework.integration.message.MessageHandlingException;
import org.springframework.integration.message.MessagingException;
/**
* A target adapter that writes a byte array to an {@link OutputStream}.
@@ -63,14 +63,14 @@ public class ByteStreamTargetAdapter extends AbstractTargetAdapter {
this.stream.write((byte[]) object);
}
else {
throw new MessageHandlingException(this.getClass().getSimpleName() +
throw new MessagingException(this.getClass().getSimpleName() +
" only supports byte array and String-based messages");
}
this.stream.flush();
return true;
}
catch (IOException e) {
throw new MessageHandlingException("IO failure occurred in adapter", e);
throw new MessagingException("IO failure occurred in adapter", e);
}
}

View File

@@ -24,7 +24,7 @@ import java.util.Collection;
import java.util.List;
import org.springframework.integration.adapter.PollableSource;
import org.springframework.integration.message.MessageDeliveryException;
import org.springframework.integration.message.MessagingException;
import org.springframework.util.Assert;
/**
@@ -76,7 +76,7 @@ public class CharacterStreamSource implements PollableSource<String> {
results.add(line);
}
catch (IOException e) {
throw new MessageDeliveryException("IO failure occurred in adapter", e);
throw new MessagingException("IO failure occurred in adapter", e);
}
}
return results;

View File

@@ -23,9 +23,9 @@ import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.adapter.AbstractTargetAdapter;
import org.springframework.integration.message.MessageHandlingException;
import org.springframework.integration.message.MessagingException;
import org.springframework.util.Assert;
/**
@@ -103,7 +103,7 @@ public class CharacterStreamTargetAdapter extends AbstractTargetAdapter {
return new CharacterStreamTargetAdapter(new OutputStreamWriter(stream, charsetName));
}
catch (UnsupportedEncodingException e) {
throw new MessagingConfigurationException("unsupported encoding: " + charsetName, e);
throw new ConfigurationException("unsupported encoding: " + charsetName, e);
}
}
@@ -140,7 +140,7 @@ public class CharacterStreamTargetAdapter extends AbstractTargetAdapter {
return true;
}
catch (IOException e) {
throw new MessageHandlingException("IO failure occurred in adapter", e);
throw new MessagingException("IO failure occurred in adapter", e);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -17,22 +17,18 @@
package org.springframework.integration;
/**
* The base exception for any failures within the messaging system.
* Exception that indicates an incorrectly configured integration component.
*
* @author Mark Fisher
*/
@SuppressWarnings("serial")
public class MessagingException extends RuntimeException {
public class ConfigurationException extends RuntimeException {
public MessagingException() {
super();
}
public MessagingException(String description) {
public ConfigurationException(String description) {
super(description);
}
public MessagingException(String description, Throwable cause) {
public ConfigurationException(String description, Throwable cause) {
super(description, cause);
}

View File

@@ -1,35 +0,0 @@
/*
* Copyright 2002-2007 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;
/**
* Exception that indicates an incorrectly configured messaging component.
*
* @author Mark Fisher
*/
@SuppressWarnings("serial")
public class MessagingConfigurationException extends MessagingException {
public MessagingConfigurationException(String description) {
super(description);
}
public MessagingConfigurationException(String description, Throwable cause) {
super(description, cause);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -20,7 +20,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageMapper;
@@ -69,7 +69,7 @@ public abstract class AbstractSourceAdapter<T> implements SourceAdapter, Initial
public final void afterPropertiesSet() {
if (this.channel == null) {
throw new MessagingConfigurationException("'channel' is required");
throw new ConfigurationException("'channel' is required");
}
this.initialize();
this.initialized = true;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -21,9 +21,9 @@ import java.util.Arrays;
import java.util.Collection;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.handler.HandlerMethodInvoker;
import org.springframework.integration.util.MethodValidator;
import org.springframework.integration.util.SimpleMethodInvoker;
import org.springframework.util.Assert;
/**
@@ -38,7 +38,7 @@ public class MethodInvokingSource<T> implements PollableSource<Object>, Initiali
private String method;
private SimpleMethodInvoker<T> invoker;
private HandlerMethodInvoker<T> invoker;
public void setObject(T object) {
@@ -52,7 +52,7 @@ public class MethodInvokingSource<T> implements PollableSource<Object>, Initiali
}
public void afterPropertiesSet() {
this.invoker = new SimpleMethodInvoker<T>(this.object, this.method);
this.invoker = new HandlerMethodInvoker<T>(this.object, this.method);
this.invoker.setMethodValidator(new MessageReceivingMethodValidator());
}
@@ -68,7 +68,7 @@ public class MethodInvokingSource<T> implements PollableSource<Object>, Initiali
public void validate(Method method) {
if (method.getReturnType().equals(void.class)) {
throw new MessagingConfigurationException("MethodInvokingSource requires a non-void returning method.");
throw new ConfigurationException("MethodInvokingSource requires a non-void returning method.");
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -20,7 +20,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.integration.util.SimpleMethodInvoker;
import org.springframework.integration.handler.HandlerMethodInvoker;
import org.springframework.util.Assert;
/**
@@ -36,7 +36,7 @@ public class MethodInvokingTarget<T> implements Target<Object>, InitializingBean
private String method;
private SimpleMethodInvoker<T> invoker;
private HandlerMethodInvoker<T> invoker;
private ArgumentListPreparer argumentListPreparer;
@@ -56,7 +56,7 @@ public class MethodInvokingTarget<T> implements Target<Object>, InitializingBean
}
public void afterPropertiesSet() {
this.invoker = new SimpleMethodInvoker<T>(this.object, this.method);
this.invoker = new HandlerMethodInvoker<T>(this.object, this.method);
}
public boolean send(Object object) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -20,10 +20,10 @@ import java.util.Collection;
import java.util.concurrent.Executors;
import org.springframework.context.Lifecycle;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.message.MessageHandlingException;
import org.springframework.integration.message.MessageMapper;
import org.springframework.integration.message.MessagingException;
import org.springframework.integration.scheduling.MessagingTask;
import org.springframework.integration.scheduling.MessagingTaskScheduler;
import org.springframework.integration.scheduling.MessagingTaskSchedulerAware;
@@ -103,7 +103,7 @@ public class PollingSourceAdapter<T> extends AbstractSourceAdapter<T> implements
@Override
protected void initialize() {
if (this.source == null) {
throw new MessagingConfigurationException("source must not be null");
throw new ConfigurationException("source must not be null");
}
}
@@ -145,7 +145,7 @@ public class PollingSourceAdapter<T> extends AbstractSourceAdapter<T> implements
Collection<T> results = this.source.poll(limit);
if (results != null) {
if (results.size() > limit) {
throw new MessageHandlingException("source returned too many results, the limit is " + limit);
throw new MessagingException("source returned too many results, the limit is " + limit);
}
for (T next : results) {
if (this.sendToChannel(next)) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -32,7 +32,7 @@ import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.Lifecycle;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.adapter.SourceAdapter;
import org.springframework.integration.channel.ChannelRegistry;
import org.springframework.integration.channel.ChannelRegistryAware;
@@ -103,7 +103,7 @@ public class MessageBus implements ChannelRegistry, EndpointRegistry, Applicatio
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
Assert.notNull(applicationContext, "'applicationContext' must not be null");
if (applicationContext.getBeanNamesForType(this.getClass()).length > 1) {
throw new MessagingConfigurationException("Only one instance of '" + this.getClass().getSimpleName()
throw new ConfigurationException("Only one instance of '" + this.getClass().getSimpleName()
+ "' is allowed per ApplicationContext.");
}
this.registerChannels(applicationContext);
@@ -304,20 +304,20 @@ public class MessageBus implements ChannelRegistry, EndpointRegistry, Applicatio
private void activateEndpoint(MessageEndpoint endpoint) {
Subscription subscription = endpoint.getSubscription();
if (subscription == null) {
throw new MessagingConfigurationException("Unable to register endpoint '" +
throw new ConfigurationException("Unable to register endpoint '" +
endpoint + "'. No subscription information is available.");
}
MessageChannel channel = subscription.getChannel();
if (channel == null) {
String channelName = subscription.getChannelName();
if (channelName == null) {
throw new MessagingConfigurationException("endpoint '" + endpoint +
throw new ConfigurationException("endpoint '" + endpoint +
"' must provide either 'channel' or 'channelName' in its subscription metadata");
}
channel = this.lookupChannel(channelName);
if (channel == null) {
if (this.autoCreateChannels == false) {
throw new MessagingConfigurationException("Cannot activate subscription, unknown channel '" + channelName +
throw new ConfigurationException("Cannot activate subscription, unknown channel '" + channelName +
"'. Consider enabling the 'autoCreateChannels' option for the message bus.");
}
if (this.logger.isInfoEnabled()) {
@@ -332,7 +332,7 @@ public class MessageBus implements ChannelRegistry, EndpointRegistry, Applicatio
String outputChannelName = dme.getDefaultOutputChannelName();
if (outputChannelName != null && this.lookupChannel(outputChannelName) == null) {
if (!this.autoCreateChannels) {
throw new MessagingConfigurationException("Unknown channel '" + outputChannelName +
throw new ConfigurationException("Unknown channel '" + outputChannelName +
"' configured as 'default-output' for endpoint '" + endpoint +
"'. Consider enabling the 'autoCreateChannels' option for the message bus.");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -24,7 +24,6 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.integration.message.Message;
import org.springframework.util.StringUtils;
/**
* Base class for {@link MessageChannel} implementations providing common
@@ -109,7 +108,7 @@ public abstract class AbstractMessageChannel implements MessageChannel, BeanName
* @return <code>true</code> if the message is sent successfully or
* <code>false</code> if the sending thread is interrupted.
*/
public final boolean send(Message message) {
public final boolean send(Message<?> message) {
return this.send(message, -1);
}
@@ -127,7 +126,7 @@ public abstract class AbstractMessageChannel implements MessageChannel, BeanName
* <code>false</code> if the message cannot be sent within the allotted
* time or the sending thread is interrupted.
*/
public final boolean send(Message message, long timeout) {
public final boolean send(Message<?> message, long timeout) {
if (!this.interceptors.preSend(message, this)) {
return false;
}
@@ -143,7 +142,7 @@ public abstract class AbstractMessageChannel implements MessageChannel, BeanName
* @return the first available message or <code>null</code> if the
* receiving thread is interrupted.
*/
public final Message receive() {
public final Message<?> receive() {
return this.receive(-1);
}
@@ -160,11 +159,11 @@ public abstract class AbstractMessageChannel implements MessageChannel, BeanName
* is available within the allotted time or the receiving thread is
* interrupted.
*/
public final Message receive(long timeout) {
public final Message<?> receive(long timeout) {
if (!this.interceptors.preReceive(this)) {
return null;
}
Message message = this.doReceive(timeout);
Message<?> message = this.doReceive(timeout);
this.interceptors.postReceive(message, this);
return message;
}
@@ -212,7 +211,7 @@ public abstract class AbstractMessageChannel implements MessageChannel, BeanName
return this.interceptors.add(interceptor);
}
public boolean preSend(Message message, MessageChannel channel) {
public boolean preSend(Message<?> message, MessageChannel channel) {
if (logger.isDebugEnabled()) {
logger.debug("preSend on channel '" + channel + "', message: " + message);
}
@@ -224,7 +223,7 @@ public abstract class AbstractMessageChannel implements MessageChannel, BeanName
return true;
}
public void postSend(Message message, MessageChannel channel, boolean sent) {
public void postSend(Message<?> message, MessageChannel channel, boolean sent) {
if (logger.isDebugEnabled()) {
logger.debug("postSend (sent=" + sent + ") on channel '" + channel + "', message: " + message);
}
@@ -245,7 +244,7 @@ public abstract class AbstractMessageChannel implements MessageChannel, BeanName
return true;
}
public void postReceive(Message message, MessageChannel channel) {
public void postReceive(Message<?> message, MessageChannel channel) {
if (logger.isDebugEnabled()) {
logger.debug("postReceive on channel '" + channel + "', message: " + message);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -54,7 +54,7 @@ public interface MessageChannel {
* @return <code>true</code> if the message is sent successfully,
* <code>false</false> if interrupted
*/
boolean send(Message message);
boolean send(Message<?> message);
/**
* Send a message, blocking until either the message is accepted or the
@@ -67,7 +67,7 @@ public interface MessageChannel {
* <code>false</false> if the specified timeout period elapses or
* the send is interrupted
*/
boolean send(Message message, long timeout);
boolean send(Message<?> message, long timeout);
/**
* Receive a message, blocking indefinitely if necessary.
@@ -75,7 +75,7 @@ public interface MessageChannel {
* @return the next available {@link Message} or <code>null</code> if
* interrupted
*/
Message receive();
Message<?> receive();
/**
* Receive a message, blocking until either a message is available or the
@@ -86,7 +86,7 @@ public interface MessageChannel {
* @return the next available {@link Message} or <code>null</code> if the
* specified timeout period elapses or the message reception is interrupted
*/
Message receive(long timeout);
Message<?> receive(long timeout);
/**
* Remove all {@link Message Messages} from this channel.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -100,7 +100,7 @@ public class WireTap extends ChannelInterceptorAdapter implements Lifecycle {
@Override
public boolean preSend(Message<?> message, MessageChannel channel) {
if (this.running && this.selectorsAccept(message)) {
Message<?> duplicate = new GenericMessage(message.getPayload(), message.getHeader());
Message<?> duplicate = new GenericMessage<Object>(message.getPayload(), message.getHeader());
duplicate.getHeader().setAttribute(ORIGINAL_MESSAGE_ID_KEY, message.getId());
if (!this.secondaryChannel.send(duplicate, 0)) {
if (logger.isWarnEnabled()) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -24,7 +24,7 @@ import org.springframework.beans.factory.parsing.BeanComponentDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.router.AggregatingMessageHandler;
import org.springframework.integration.router.AggregatorAdapter;
import org.springframework.util.StringUtils;
@@ -87,7 +87,7 @@ public class AggregatorParser implements BeanDefinitionParser {
final String ref = element.getAttribute(REF_ATTRIBUTE);
final String method = element.getAttribute(METHOD_ATTRIBUTE);
if (!StringUtils.hasText(ref)) {
throw new MessagingConfigurationException("The 'ref' attribute must be present");
throw new ConfigurationException("The 'ref' attribute must be present");
}
if (!topLevel && StringUtils.hasText(id)) {
parserContext.getReaderContext().error(

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -24,7 +24,7 @@ import org.springframework.beans.factory.parsing.BeanComponentDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.adapter.DefaultTargetAdapter;
import org.springframework.integration.adapter.MethodInvokingSource;
import org.springframework.integration.adapter.MethodInvokingTarget;
@@ -64,13 +64,13 @@ public class ChannelAdapterParser implements BeanDefinitionParser {
String method = element.getAttribute(METHOD_ATTRIBUTE);
String channel = element.getAttribute(CHANNEL_ATTRIBUTE);
if (!StringUtils.hasText(ref)) {
throw new MessagingConfigurationException("'ref' is required");
throw new ConfigurationException("'ref' is required");
}
if (!StringUtils.hasText(method)) {
throw new MessagingConfigurationException("'method' is required");
throw new ConfigurationException("'method' is required");
}
if (!StringUtils.hasText(channel)) {
throw new MessagingConfigurationException("'channel' is required");
throw new ConfigurationException("'channel' is required");
}
RootBeanDefinition adapterDef = null;
RootBeanDefinition invokerDef = null;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -30,7 +30,7 @@ import org.springframework.beans.factory.support.ManagedList;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.endpoint.ConcurrencyPolicy;
import org.springframework.integration.endpoint.DefaultMessageEndpoint;
import org.springframework.integration.handler.DefaultMessageHandlerAdapter;
@@ -167,7 +167,7 @@ public class EndpointParser implements BeanDefinitionParser {
String handlerRef = element.getAttribute(HANDLER_REF_ATTRIBUTE);
if (StringUtils.hasText(handlerRef)) {
if (childHandlerRefs.size() > 0) {
throw new MessagingConfigurationException(
throw new ConfigurationException(
"The 'handler-ref' attribute is only supported when no 'handler' child elements are present");
}
String handlerMethod = element.getAttribute(HANDLER_METHOD_ATTRIBUTE);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -26,7 +26,7 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.core.Conventions;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.bus.MessageBus;
import org.springframework.integration.endpoint.ConcurrencyPolicy;
import org.springframework.util.StringUtils;
@@ -53,7 +53,7 @@ public class MessageBusParser extends AbstractSimpleBeanDefinitionParser {
protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext)
throws BeanDefinitionStoreException {
if (parserContext.getRegistry().containsBeanDefinition(MESSAGE_BUS_BEAN_NAME)) {
throw new MessagingConfigurationException("Only one instance of '" + MESSAGE_BUS_CLASS.getSimpleName()
throw new ConfigurationException("Only one instance of '" + MESSAGE_BUS_CLASS.getSimpleName()
+ "' is allowed per ApplicationContext.");
}
return MESSAGE_BUS_BEAN_NAME;

View File

@@ -33,7 +33,7 @@ import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.core.OrderComparator;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.adapter.DefaultTargetAdapter;
import org.springframework.integration.adapter.MethodInvokingSource;
import org.springframework.integration.adapter.MethodInvokingTarget;
@@ -179,7 +179,7 @@ public class MessageEndpointAnnotationPostProcessor implements BeanPostProcessor
Annotation annotation = AnnotationUtils.getAnnotation(method, DefaultOutput.class);
if (annotation != null) {
if (foundDefaultOutput) {
throw new MessagingConfigurationException("only one @DefaultOutput allowed per endpoint");
throw new ConfigurationException("only one @DefaultOutput allowed per endpoint");
}
MethodInvokingTarget<Object> target = new MethodInvokingTarget<Object>();
target.setObject(bean);
@@ -231,7 +231,7 @@ public class MessageEndpointAnnotationPostProcessor implements BeanPostProcessor
((InitializingBean) handler).afterPropertiesSet();
}
catch (Exception e) {
throw new MessagingConfigurationException("failed to create handler", e);
throw new ConfigurationException("failed to create handler", e);
}
}
if (handler != null) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -27,7 +27,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.Lifecycle;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.handler.MessageHandler;
import org.springframework.integration.message.Message;
@@ -130,7 +130,7 @@ public class DefaultMessageDispatcher implements SchedulingMessageDispatcher {
return;
}
if (this.scheduler == null) {
throw new MessagingConfigurationException("'scheduler' is required");
throw new ConfigurationException("'scheduler' is required");
}
if (!this.scheduler.isRunning()) {
this.scheduler.start();

View File

@@ -119,8 +119,10 @@ public class DefaultMessageDistributor implements MessageDistributor {
attempts++;
}
if (this.dispatcherPolicy.getShouldFailOnRejectionLimit()) {
throw new MessageDeliveryException("Dispatcher reached rejection limit of " + this.dispatcherPolicy.getRejectionLimit()
+ ". Consider increasing the handler's concurrency and/or the dispatcherPolicy's 'rejectionLimit'.");
throw new MessageDeliveryException(message, "Dispatcher reached rejection limit of "
+ this.dispatcherPolicy.getRejectionLimit()
+ ". Consider increasing the handler's concurrency and/or "
+ "the dispatcherPolicy's 'rejectionLimit'.");
}
return false;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -73,14 +73,14 @@ public class ConcurrentHandler implements MessageHandler, DisposableBean {
public Message<?> handle(Message<?> message) {
if (this.executor.isShutdown()) {
throw new MessageHandlerNotRunningException();
throw new MessageHandlerNotRunningException(message);
}
try {
this.executor.execute(new HandlerTask(message));
return null;
}
catch (RuntimeException e) {
throw new MessageHandlerRejectedExecutionException(e);
throw new MessageHandlerRejectedExecutionException(message, e);
}
}

View File

@@ -31,7 +31,7 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.Lifecycle;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.channel.ChannelRegistry;
import org.springframework.integration.channel.ChannelRegistryAware;
import org.springframework.integration.channel.MessageChannel;
@@ -242,16 +242,16 @@ public class DefaultMessageEndpoint implements MessageEndpoint, ChannelRegistryA
logger.debug("endpoint '" + this + "' handling message: " + message);
}
if (!this.isRunning()) {
throw new MessageHandlerNotRunningException();
throw new MessageHandlerNotRunningException(message);
}
for (MessageSelector selector : this.selectors) {
if (!selector.accept(message)) {
throw new MessageSelectorRejectedException();
throw new MessageSelectorRejectedException(message);
}
}
if (this.handler == null) {
if (this.defaultOutputChannelName == null) {
throw new MessagingConfigurationException(
throw new ConfigurationException(
"endpoint must have either a 'handler' or 'defaultOutputChannelName'");
}
MessageChannel outputChannel = this.channelRegistry.lookupChannel(this.defaultOutputChannelName);
@@ -278,7 +278,7 @@ public class DefaultMessageEndpoint implements MessageEndpoint, ChannelRegistryA
}
catch (Throwable t) {
if (this.errorHandler == null) {
throw new MessageHandlingException(
throw new MessageHandlingException(message,
"error occurred in endpoint, and no 'errorHandler' available", t);
}
this.errorHandler.handle(t);
@@ -316,7 +316,8 @@ public class DefaultMessageEndpoint implements MessageEndpoint, ChannelRegistryA
}
MessageChannel replyChannel = resolveReplyChannel(originalMessageHeader);
if (replyChannel == null) {
throw new MessageHandlingException("Unable to determine reply channel for message. " +
throw new MessageHandlingException(replyMessage,
"Unable to determine reply channel for message. " +
"Provide a 'replyChannel' or 'replyChannelName' in the message header " +
"or a 'defaultOutputChannelName' on the message endpoint.");
}

View File

@@ -25,7 +25,6 @@ import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageHeader;
import org.springframework.integration.message.MessageMapper;
import org.springframework.integration.util.SimpleMethodInvoker;
import org.springframework.util.Assert;
/**
@@ -46,7 +45,7 @@ public abstract class AbstractMessageHandlerAdapter<T> implements MessageHandler
private volatile String methodName;
private volatile SimpleMethodInvoker<T> invoker;
private volatile HandlerMethodInvoker<T> invoker;
private volatile int order = Integer.MAX_VALUE;
@@ -83,7 +82,7 @@ public abstract class AbstractMessageHandlerAdapter<T> implements MessageHandler
if (this.initialized) {
return;
}
this.invoker = new SimpleMethodInvoker<T>(this.object, this.methodName);
this.invoker = new HandlerMethodInvoker<T>(this.object, this.methodName);
this.initialized = true;
}
this.initialize();
@@ -129,6 +128,6 @@ public abstract class AbstractMessageHandlerAdapter<T> implements MessageHandler
* the provided target object and method. May return an object of type
* {@link Message}, else rely on the message mapper to convert.
*/
protected abstract Object doHandle(Message<?> message, SimpleMethodInvoker<T> invoker);
protected abstract Object doHandle(Message<?> message, HandlerMethodInvoker<T> invoker);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -18,7 +18,6 @@ package org.springframework.integration.handler;
import org.springframework.core.Ordered;
import org.springframework.integration.message.Message;
import org.springframework.integration.util.SimpleMethodInvoker;
/**
* An implementation of {@link MessageHandler} that invokes the specified method
@@ -45,7 +44,7 @@ public class DefaultMessageHandlerAdapter<T> extends AbstractMessageHandlerAdapt
this.expectsMessage = expectsMessage;
}
public Object doHandle(Message message, SimpleMethodInvoker invoker) {
public Object doHandle(Message message, HandlerMethodInvoker invoker) {
if (this.expectsMessage) {
return invoker.invokeMethod(message);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -14,12 +14,13 @@
* limitations under the License.
*/
package org.springframework.integration.util;
package org.springframework.integration.handler;
import java.lang.reflect.InvocationTargetException;
import org.springframework.beans.support.ArgumentConvertingMethodInvoker;
import org.springframework.integration.MessagingException;
import org.springframework.integration.message.MessagingException;
import org.springframework.integration.util.MethodValidator;
import org.springframework.util.Assert;
import org.springframework.util.MethodInvoker;
import org.springframework.util.ObjectUtils;
@@ -29,7 +30,7 @@ import org.springframework.util.ObjectUtils;
*
* @author Mark Fisher
*/
public class SimpleMethodInvoker<T> {
public class HandlerMethodInvoker<T> {
private T object;
@@ -38,7 +39,7 @@ public class SimpleMethodInvoker<T> {
private MethodValidator methodValidator;
public SimpleMethodInvoker(T object, String method) {
public HandlerMethodInvoker(T object, String method) {
Assert.notNull(object, "'object' must not be null");
Assert.notNull(method, "'method' must not be null");
this.object = object;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -16,6 +16,7 @@
package org.springframework.integration.handler;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageHandlingException;
/**
@@ -23,10 +24,11 @@ import org.springframework.integration.message.MessageHandlingException;
*
* @author Mark Fisher
*/
@SuppressWarnings("serial")
public class MessageHandlerNotRunningException extends MessageHandlingException {
public MessageHandlerNotRunningException() {
super("handler is not running");
public MessageHandlerNotRunningException(Message<?> message) {
super(message, "handler is not running");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -16,6 +16,7 @@
package org.springframework.integration.handler;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageHandlingException;
/**
@@ -24,18 +25,15 @@ import org.springframework.integration.message.MessageHandlingException;
*
* @author Mark Fisher
*/
@SuppressWarnings("serial")
public class MessageHandlerRejectedExecutionException extends MessageHandlingException {
public MessageHandlerRejectedExecutionException() {
super();
public MessageHandlerRejectedExecutionException(Message<?> message) {
super(message);
}
public MessageHandlerRejectedExecutionException(Throwable cause) {
super("handler rejected execution", cause);
}
public MessageHandlerRejectedExecutionException(String message, Throwable cause) {
super(message, cause);
public MessageHandlerRejectedExecutionException(Message<?> message, Throwable cause) {
super(message, "handler rejected execution", cause);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -47,7 +47,8 @@ public class ResponseCorrelator implements MessageHandler {
public Message<?> handle(Message<?> message) {
Object correlationId = this.getCorrelationId(message);
if (correlationId == null) {
throw new MessageHandlingException("unable to handle response, message has no correlationId: " + message);
throw new MessageHandlingException(message,
"unable to handle response, message has no correlationId: " + message);
}
this.messageStore.put(correlationId, message);
return null;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -22,7 +22,7 @@ import java.util.Map;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.annotation.Order;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.handler.AbstractMessageHandlerAdapter;
import org.springframework.integration.handler.MessageHandler;
@@ -50,7 +50,7 @@ public abstract class AbstractMessageHandlerCreator implements MessageHandlerCre
((InitializingBean) handler).afterPropertiesSet();
}
catch (Exception e) {
throw new MessagingConfigurationException("failed to initialize handler", e);
throw new ConfigurationException("failed to initialize handler", e);
}
}
return handler;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -20,7 +20,7 @@ import java.lang.reflect.Method;
import java.util.Map;
import org.springframework.core.annotation.Order;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.handler.DefaultMessageHandlerAdapter;
import org.springframework.integration.handler.MessageHandler;
import org.springframework.integration.message.Message;
@@ -38,7 +38,7 @@ public class DefaultMessageHandlerCreator extends AbstractMessageHandlerCreator
public MessageHandler doCreateHandler(Object object, Method method, Map<String, ?> attributes) {
Class<?>[] types = method.getParameterTypes();
if (types.length != 1) {
throw new MessagingConfigurationException("exactly one method parameter is required");
throw new ConfigurationException("exactly one method parameter is required");
}
DefaultMessageHandlerAdapter<Object> adapter = new DefaultMessageHandlerAdapter<Object>();
adapter.setExpectsMessage(Message.class.isAssignableFrom(types[0]));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -16,8 +16,6 @@
package org.springframework.integration.message;
import org.springframework.integration.MessagingException;
/**
* Exception that indicates an error during message delivery.
*
@@ -26,36 +24,12 @@ import org.springframework.integration.MessagingException;
@SuppressWarnings("serial")
public class MessageDeliveryException extends MessagingException {
private Message<?> undeliveredMessage;
public MessageDeliveryException() {
super();
}
public MessageDeliveryException(Message<?> undeliveredMessage) {
this.undeliveredMessage = undeliveredMessage;
}
public MessageDeliveryException(String description) {
super(description);
super(undeliveredMessage);
}
public MessageDeliveryException(Message<?> undeliveredMessage, String description) {
super(description);
this.undeliveredMessage = undeliveredMessage;
}
public MessageDeliveryException(String description, Throwable cause) {
super(description, cause);
}
/**
* Return the undelivered {@link Message} if available, may be null.
*/
public Message<?> getUndeliveredMessage() {
return this.undeliveredMessage;
super(undeliveredMessage, description);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -16,8 +16,6 @@
package org.springframework.integration.message;
import org.springframework.integration.MessagingException;
/**
* Exception that indicates an error during message handling.
*
@@ -26,36 +24,16 @@ import org.springframework.integration.MessagingException;
@SuppressWarnings("serial")
public class MessageHandlingException extends MessagingException {
private Message<?> failedMessage;
public MessageHandlingException() {
super();
}
public MessageHandlingException(Message<?> failedMessage) {
this.failedMessage = failedMessage;
}
public MessageHandlingException(String description) {
super(description);
super(failedMessage);
}
public MessageHandlingException(Message<?> failedMessage, String description) {
super(description);
this.failedMessage = failedMessage;
super(failedMessage, description);
}
public MessageHandlingException(String description, Throwable cause) {
super(description, cause);
}
/**
* Return the failed {@link Message} if available, may be null.
*/
public Message<?> getFailedMessage() {
return this.failedMessage;
public MessageHandlingException(Message<?> failedMessage, String description, Throwable cause) {
super(failedMessage, description, cause);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -0,0 +1,65 @@
/*
* Copyright 2002-2008 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.message;
/**
* The base exception for any failures within the messaging system.
*
* @author Mark Fisher
*/
@SuppressWarnings("serial")
public class MessagingException extends RuntimeException {
private final Message<?> failedMessage;
public MessagingException(Message<?> message) {
super();
this.failedMessage = message;
}
public MessagingException(String description) {
super(description);
this.failedMessage = null;
}
public MessagingException(String description, Throwable cause) {
super(description, cause);
this.failedMessage = null;
}
public MessagingException(Message<?> message, String description) {
super(description);
this.failedMessage = message;
}
public MessagingException(Message<?> message, Throwable cause) {
super(cause);
this.failedMessage = message;
}
public MessagingException(Message<?> message, String description, Throwable cause) {
super(description, cause);
this.failedMessage = message;
}
public Message<?> getFailedMessage() {
return this.failedMessage;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -16,6 +16,7 @@
package org.springframework.integration.message.selector;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageHandlingException;
/**
@@ -24,14 +25,11 @@ import org.springframework.integration.message.MessageHandlingException;
*
* @author Mark Fisher
*/
@SuppressWarnings("serial")
public class MessageSelectorRejectedException extends MessageHandlingException {
public MessageSelectorRejectedException() {
super();
}
public MessageSelectorRejectedException(String message) {
super(message);
public MessageSelectorRejectedException(Message<?> rejectedMessage) {
super(rejectedMessage);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -22,7 +22,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.channel.ChannelRegistry;
import org.springframework.integration.channel.ChannelRegistryAware;
import org.springframework.integration.channel.MessageChannel;
@@ -78,12 +78,12 @@ public abstract class AbstractRoutingMessageHandler implements MessageHandler, C
public final Message<?> handle(Message<?> message) {
List<MessageChannel> channels = this.resolveChannels(message);
if (channels == null || channels.size() == 0) {
String errorMessage = "failed to resolve any channel for message";
String description = "failed to resolve any channel for message";
if (this.resolutionRequired) {
throw new MessageHandlingException(errorMessage);
throw new MessageHandlingException(message, description);
}
if (logger.isWarnEnabled()) {
logger.warn(errorMessage);
logger.warn(description);
}
return null;
}
@@ -102,11 +102,12 @@ public abstract class AbstractRoutingMessageHandler implements MessageHandler, C
sent = channel.send(message, timeout);
}
if (!sent) {
throw new MessageHandlingException("failed to send message to channel '" + channel.getName() + "'");
throw new MessageHandlingException(message,
"failed to send message to channel '" + channel.getName() + "'");
}
}
protected abstract void validate() throws MessagingConfigurationException;
protected abstract void validate() throws ConfigurationException;
protected abstract List<MessageChannel> resolveChannels(Message<?> message);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -198,8 +198,8 @@ public class AggregatingMessageHandler implements MessageHandler, InitializingBe
}
Object correlationId = message.getHeader().getCorrelationId();
if (correlationId == null) {
throw new MessageHandlingException(this.getClass().getSimpleName() +
" requires the 'correlationId' property");
throw new MessageHandlingException(message,
this.getClass().getSimpleName() + " requires the 'correlationId' property");
}
if (this.trackedCorrelationIds.contains(correlationId)) {
if (logger.isDebugEnabled()) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -23,10 +23,10 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.handler.HandlerMethodInvoker;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.message.Message;
import org.springframework.integration.util.SimpleMethodInvoker;
import org.springframework.util.Assert;
import org.springframework.util.ReflectionUtils;
@@ -40,7 +40,7 @@ import org.springframework.util.ReflectionUtils;
*/
public class AggregatorAdapter implements Aggregator {
private final SimpleMethodInvoker<Object> invoker;
private final HandlerMethodInvoker<Object> invoker;
private final Method method;
@@ -50,21 +50,21 @@ public class AggregatorAdapter implements Aggregator {
Assert.notNull(methodName, "'methodName' must not be null");
this.method = ReflectionUtils.findMethod(object.getClass(), methodName, new Class<?>[] { Collection.class });
if (this.method == null) {
throw new MessagingConfigurationException("Method '" + methodName +
throw new ConfigurationException("Method '" + methodName +
"(Collection<?> args)' not found on '" + object.getClass().getName() + "'.");
}
this.invoker = new SimpleMethodInvoker<Object>(object, this.method.getName());
this.invoker = new HandlerMethodInvoker<Object>(object, this.method.getName());
}
public AggregatorAdapter(Object object, Method method) {
Assert.notNull(object, "'object' must not be null");
Assert.notNull(method, "'method' must not be null");
if (method.getParameterTypes().length != 1 || !method.getParameterTypes()[0].equals(Collection.class)) {
throw new MessagingConfigurationException(
throw new ConfigurationException(
"Aggregator method must accept exactly one parameter, and it must be a Collection.");
}
this.method = method;
this.invoker = new SimpleMethodInvoker<Object>(object, this.method.getName());
this.invoker = new HandlerMethodInvoker<Object>(object, this.method.getName());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -19,7 +19,7 @@ package org.springframework.integration.router;
import java.util.ArrayList;
import java.util.List;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.message.Message;
@@ -52,11 +52,11 @@ public class MultiChannelRouter extends AbstractRoutingMessageHandler {
@Override
public void validate() {
if (!(this.channelResolver != null ^ this.channelNameResolver != null)) {
throw new MessagingConfigurationException(
throw new ConfigurationException(
"exactly one of 'channelResolver' or 'channelNameResolver' must be provided");
}
if (this.channelNameResolver != null && this.getChannelRegistry() == null) {
throw new MessagingConfigurationException("'channelRegistry' is required when resolving by channel name");
throw new ConfigurationException("'channelRegistry' is required when resolving by channel name");
}
}
@@ -66,7 +66,7 @@ public class MultiChannelRouter extends AbstractRoutingMessageHandler {
return this.channelResolver.resolve(message);
}
if (this.channelNameResolver == null || this.getChannelRegistry() == null) {
throw new MessagingConfigurationException("router configuration requires either "
throw new ConfigurationException("router configuration requires either "
+ "a 'channelResolver' or both 'channelNameResolver' and 'channelRegistry'");
}
String[] channelNames = this.channelNameResolver.resolve(message);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -20,15 +20,15 @@ import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Map;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.annotation.Router;
import org.springframework.integration.channel.ChannelRegistry;
import org.springframework.integration.channel.ChannelRegistryAware;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.handler.AbstractMessageHandlerAdapter;
import org.springframework.integration.handler.HandlerMethodInvoker;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageHandlingException;
import org.springframework.integration.util.SimpleMethodInvoker;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -74,9 +74,9 @@ public class RouterMessageHandlerAdapter extends AbstractMessageHandlerAdapter i
}
@Override
protected Object doHandle(Message message, SimpleMethodInvoker invoker) {
protected Object doHandle(Message message, HandlerMethodInvoker invoker) {
if (method.getParameterTypes().length != 1) {
throw new MessagingConfigurationException(
throw new ConfigurationException(
"method must accept exactly one parameter");
}
String propertyName = (String) attributes.get(PROPERTY_KEY);
@@ -84,19 +84,21 @@ public class RouterMessageHandlerAdapter extends AbstractMessageHandlerAdapter i
Object retval = null;
if (StringUtils.hasText(propertyName)) {
if (StringUtils.hasText(attributeName)) {
throw new MessagingConfigurationException(
throw new ConfigurationException(
"cannot accept both 'property' and 'attribute'");
}
String property = message.getHeader().getProperty(propertyName);
if (!StringUtils.hasText(property)) {
throw new MessageHandlingException("no '" + propertyName + "' property available for router method");
throw new MessageHandlingException(message,
"no '" + propertyName + "' property available for router method");
}
retval = this.invokeMethod(invoker, property);
}
else if (StringUtils.hasText(attributeName)) {
Object attribute = message.getHeader().getAttribute(attributeName);
if (attribute == null) {
throw new MessageHandlingException("no '" + attributeName + "' attribute available for router method");
throw new MessageHandlingException(message,
"no '" + attributeName + "' attribute available for router method");
}
retval = this.invokeMethod(invoker, attribute);
}
@@ -120,7 +122,7 @@ public class RouterMessageHandlerAdapter extends AbstractMessageHandlerAdapter i
this.sendMessage(message, (String) channel);
}
else {
throw new MessagingConfigurationException(
throw new ConfigurationException(
"router method must return type 'MessageChannel' or 'String'");
}
}
@@ -142,14 +144,14 @@ public class RouterMessageHandlerAdapter extends AbstractMessageHandlerAdapter i
this.sendMessage(message, (String) retval);
}
else {
throw new MessagingConfigurationException(
throw new ConfigurationException(
"router method must return type 'MessageChannel' or 'String'");
}
}
return null;
}
private Object invokeMethod(SimpleMethodInvoker<?> invoker, Object parameter) {
private Object invokeMethod(HandlerMethodInvoker<?> invoker, Object parameter) {
if (this.logger.isDebugEnabled()) {
logger.debug("invoking method '" + method.getName() + "' with parameter of type '" +
parameter.getClass().getName() + "'");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -19,7 +19,7 @@ package org.springframework.integration.router;
import java.util.ArrayList;
import java.util.List;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.message.Message;
@@ -51,11 +51,11 @@ public class SingleChannelRouter extends AbstractRoutingMessageHandler {
@Override
public void validate() {
if (!(this.channelResolver != null ^ this.channelNameResolver != null)) {
throw new MessagingConfigurationException(
throw new ConfigurationException(
"exactly one of 'channelResolver' or 'channelNameResolver' must be provided");
}
if (this.channelNameResolver != null && this.getChannelRegistry() == null) {
throw new MessagingConfigurationException("'channelRegistry' is required when resolving by channel name");
throw new ConfigurationException("'channelRegistry' is required when resolving by channel name");
}
}
@@ -74,7 +74,7 @@ public class SingleChannelRouter extends AbstractRoutingMessageHandler {
return this.channelResolver.resolve(message);
}
if (this.channelNameResolver == null || this.getChannelRegistry() == null) {
throw new MessagingConfigurationException("router configuration requires either "
throw new ConfigurationException("router configuration requires either "
+ "a 'channelResolver' or both 'channelNameResolver' and 'channelRegistry'");
}
String channelName = this.channelNameResolver.resolve(message);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -20,15 +20,15 @@ import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Map;
import org.springframework.integration.MessagingConfigurationException;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.annotation.Splitter;
import org.springframework.integration.channel.ChannelRegistry;
import org.springframework.integration.channel.ChannelRegistryAware;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.handler.AbstractMessageHandlerAdapter;
import org.springframework.integration.handler.HandlerMethodInvoker;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageHeader;
import org.springframework.integration.util.SimpleMethodInvoker;
import org.springframework.util.Assert;
/**
@@ -71,10 +71,10 @@ public class SplitterMessageHandlerAdapter<T> extends AbstractMessageHandlerAdap
}
@Override
protected final Object doHandle(Message<?> message, SimpleMethodInvoker<T> invoker) {
protected final Object doHandle(Message<?> message, HandlerMethodInvoker<T> invoker) {
final MessageHeader originalMessageHeader = message.getHeader();
if (method.getParameterTypes().length != 1) {
throw new MessagingConfigurationException(
throw new ConfigurationException(
"Splitter method must accept exactly one parameter");
}
String channelName = (String) attributes.get(CHANNEL_KEY);
@@ -121,7 +121,7 @@ public class SplitterMessageHandlerAdapter<T> extends AbstractMessageHandlerAdap
}
}
else {
throw new MessagingConfigurationException(
throw new ConfigurationException(
"splitter method must return either a Collection or array");
}
return null;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -18,8 +18,6 @@ package org.springframework.integration.util;
import java.lang.reflect.Method;
import org.springframework.integration.MessagingConfigurationException;
/**
* Interface for method validation. Implementations should throw an exception if
* the method is invalid for its purpose.
@@ -28,6 +26,6 @@ import org.springframework.integration.MessagingConfigurationException;
*/
public interface MethodValidator {
void validate(Method method) throws MessagingConfigurationException;
void validate(Method method) throws Exception;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.message;
package org.springframework.integration;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -26,6 +26,8 @@ import java.util.Set;
import org.junit.Test;
import org.springframework.integration.message.MessageHeader;
/**
* @author Mark Fisher
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -23,7 +23,7 @@ import java.util.Collection;
import org.junit.Test;
import org.springframework.integration.MessagingException;
import org.springframework.integration.message.MessagingException;
/**
* @author Mark Fisher

Some files were not shown because too many files have changed in this diff Show More