Rename ChannelResolver to DestinationResolver
This commit is contained in:
parent
9dd7f6e5fb
commit
0c92b85c3d
|
@ -15,8 +15,10 @@
|
|||
*/
|
||||
package org.springframework.messaging.channel;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.core.DestinationResolutionException;
|
||||
import org.springframework.messaging.core.DestinationResolver;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
|
@ -25,12 +27,12 @@ import org.springframework.util.Assert;
|
|||
* @author Mark Fisher
|
||||
* @since 4.0
|
||||
*/
|
||||
public class BeanFactoryChannelResolver implements DestinationResolver<MessageChannel> {
|
||||
public class BeanFactoryMessageChannelDestinationResolver implements DestinationResolver<MessageChannel> {
|
||||
|
||||
private final BeanFactory beanFactory;
|
||||
|
||||
|
||||
public BeanFactoryChannelResolver(BeanFactory beanFactory) {
|
||||
public BeanFactoryMessageChannelDestinationResolver(BeanFactory beanFactory) {
|
||||
Assert.notNull(beanFactory, "beanFactory must not be null");
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
@ -38,7 +40,14 @@ public class BeanFactoryChannelResolver implements DestinationResolver<MessageCh
|
|||
|
||||
@Override
|
||||
public MessageChannel resolveDestination(String name) {
|
||||
return this.beanFactory.getBean(name, MessageChannel.class);
|
||||
Assert.state(this.beanFactory != null, "BeanFactory is required");
|
||||
try {
|
||||
return this.beanFactory.getBean(name, MessageChannel.class);
|
||||
}
|
||||
catch (BeansException e) {
|
||||
throw new DestinationResolutionException(
|
||||
"failed to look up MessageChannel bean with name '" + name + "'", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* Copyright 2002-2013 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.messaging.channel;
|
||||
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
|
||||
/**
|
||||
* Strategy for resolving a name to a {@link MessageChannel}.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface ChannelResolver {
|
||||
|
||||
/**
|
||||
* Return the MessageChannel for the given name.
|
||||
*/
|
||||
MessageChannel resolveChannelName(String channelName);
|
||||
|
||||
}
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.channel;
|
||||
package org.springframework.messaging.core;
|
||||
|
||||
import org.springframework.messaging.MessagingException;
|
||||
|
||||
|
@ -25,13 +25,13 @@ import org.springframework.messaging.MessagingException;
|
|||
* @since 4.0
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class ChannelResolutionException extends MessagingException {
|
||||
public class DestinationResolutionException extends MessagingException {
|
||||
|
||||
/**
|
||||
* Create a new ChannelResolutionException.
|
||||
* @param description the description
|
||||
*/
|
||||
public ChannelResolutionException(String description) {
|
||||
public DestinationResolutionException(String description) {
|
||||
super(description);
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class ChannelResolutionException extends MessagingException {
|
|||
* @param description the description
|
||||
* @param cause the root cause (if any)
|
||||
*/
|
||||
public ChannelResolutionException(String description, Throwable cause) {
|
||||
public DestinationResolutionException(String description, Throwable cause) {
|
||||
super(description, cause);
|
||||
}
|
||||
|
|
@ -22,6 +22,12 @@ package org.springframework.messaging.core;
|
|||
*/
|
||||
public interface DestinationResolver<D> {
|
||||
|
||||
D resolveDestination(String name);
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* @return
|
||||
* @throws DestinationResolutionException
|
||||
*/
|
||||
D resolveDestination(String name) throws DestinationResolutionException;
|
||||
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.springframework.messaging.MessageChannel;
|
|||
import org.springframework.messaging.MessageDeliveryException;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.messaging.channel.BeanFactoryChannelResolver;
|
||||
import org.springframework.messaging.channel.BeanFactoryMessageChannelDestinationResolver;
|
||||
import org.springframework.messaging.support.MessageBuilder;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class GenericMessagingTemplate extends AbstractDestinationResolvingMessag
|
|||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
super.setDestinationResolver(new BeanFactoryChannelResolver(beanFactory));
|
||||
super.setDestinationResolver(new BeanFactoryMessageChannelDestinationResolver(beanFactory));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue