renamed ChannelFactory to BindableChannelFactory
This clarifies the contract as this interface is intended for creation/configuration of the bindable channels only.
This commit is contained in:
@@ -13,39 +13,36 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.stream.binding;
|
||||
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
|
||||
/**
|
||||
* Class that {@link BindableProxyFactory} uses to create and configure message channels.
|
||||
* Defines methods to create/configure the {@link org.springframework.messaging.MessageChannel}s defined
|
||||
* in {@link org.springframework.cloud.stream.annotation.EnableBinding}.
|
||||
*
|
||||
* @author Marius Bogoevici
|
||||
* @author David Syer
|
||||
* @author Ilayaperumal Gopinathan
|
||||
*/
|
||||
public class BindableChannelFactory implements ChannelFactory {
|
||||
public interface BindableChannelFactory {
|
||||
|
||||
private final MessageConverterConfigurer messageConverterConfigurer;
|
||||
/**
|
||||
* Create a {@link SubscribableChannel} that will be bound via the message channel
|
||||
* {@link org.springframework.cloud.stream.binder.Binder}.
|
||||
*
|
||||
* @param name name of the message channel
|
||||
* @return subscribable message channel
|
||||
*/
|
||||
SubscribableChannel createSubscribableChannel(String name);
|
||||
|
||||
public BindableChannelFactory(MessageConverterConfigurer messageConverterConfigurer) {
|
||||
this.messageConverterConfigurer = messageConverterConfigurer;
|
||||
}
|
||||
/**
|
||||
* Create a {@link PollableChannel} that will be bound via the message channel
|
||||
* {@link org.springframework.cloud.stream.binder.Binder}.
|
||||
*
|
||||
* @param name name of the message channel
|
||||
* @return pollable message channel
|
||||
*/
|
||||
PollableChannel createPollableChannel(String name);
|
||||
|
||||
@Override
|
||||
public PollableChannel createPollableChannel(String name) {
|
||||
PollableChannel pollableChannel = new QueueChannel();
|
||||
messageConverterConfigurer.configureMessageConverters(pollableChannel, name);
|
||||
return pollableChannel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubscribableChannel createSubscribableChannel(String name) {
|
||||
SubscribableChannel subscribableChannel = new DirectChannel();
|
||||
messageConverterConfigurer.configureMessageConverters(subscribableChannel, name);
|
||||
return subscribableChannel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public class BindableProxyFactory implements MethodInterceptor, FactoryBean<Obje
|
||||
private int pollableBridgeDefaultFrequency;
|
||||
|
||||
@Autowired
|
||||
private ChannelFactory channelFactory;
|
||||
private BindableChannelFactory channelFactory;
|
||||
|
||||
@Autowired(required = false)
|
||||
private SharedChannelRegistry sharedChannelRegistry;
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015 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.cloud.stream.binding;
|
||||
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
|
||||
/**
|
||||
* Defines methods to create/configure the {@link org.springframework.messaging.MessageChannel} defined
|
||||
* in {@link org.springframework.cloud.stream.annotation.EnableBinding}.
|
||||
*
|
||||
* @author Ilayaperumal Gopinathan
|
||||
*/
|
||||
public interface ChannelFactory {
|
||||
|
||||
/**
|
||||
* Create a {@link SubscribableChannel} that will be bound via the message channel
|
||||
* {@link org.springframework.cloud.stream.binder.Binder}.
|
||||
*
|
||||
* @param name name of the message channel
|
||||
* @return Subscribable message channel
|
||||
*/
|
||||
SubscribableChannel createSubscribableChannel(String name);
|
||||
|
||||
/**
|
||||
* Create a {@link PollableChannel} that will be bound via the message channel
|
||||
* {@link org.springframework.cloud.stream.binder.Binder}.
|
||||
*
|
||||
* @param name name of the message channel
|
||||
* @return Pollable message channel
|
||||
*/
|
||||
PollableChannel createPollableChannel(String name);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2015 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.cloud.stream.binding;
|
||||
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
|
||||
/**
|
||||
* Class that {@link BindableProxyFactory} uses to create and configure message channels.
|
||||
*
|
||||
* @author Marius Bogoevici
|
||||
* @author David Syer
|
||||
* @author Ilayaperumal Gopinathan
|
||||
*/
|
||||
public class DefaultBindableChannelFactory implements BindableChannelFactory {
|
||||
|
||||
private final MessageConverterConfigurer messageConverterConfigurer;
|
||||
|
||||
public DefaultBindableChannelFactory(MessageConverterConfigurer messageConverterConfigurer) {
|
||||
this.messageConverterConfigurer = messageConverterConfigurer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PollableChannel createPollableChannel(String name) {
|
||||
PollableChannel pollableChannel = new QueueChannel();
|
||||
messageConverterConfigurer.configureMessageConverters(pollableChannel, name);
|
||||
return pollableChannel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubscribableChannel createSubscribableChannel(String name) {
|
||||
SubscribableChannel subscribableChannel = new DirectChannel();
|
||||
messageConverterConfigurer.configureMessageConverters(subscribableChannel, name);
|
||||
return subscribableChannel;
|
||||
}
|
||||
}
|
||||
@@ -31,9 +31,9 @@ import org.springframework.cloud.stream.binder.BinderFactory;
|
||||
import org.springframework.cloud.stream.binding.BinderAwareChannelResolver;
|
||||
import org.springframework.cloud.stream.binding.BinderAwareRouterBeanPostProcessor;
|
||||
import org.springframework.cloud.stream.binding.ChannelBindingService;
|
||||
import org.springframework.cloud.stream.binding.ChannelFactory;
|
||||
import org.springframework.cloud.stream.binding.ContextStartAfterRefreshListener;
|
||||
import org.springframework.cloud.stream.binding.BindableChannelFactory;
|
||||
import org.springframework.cloud.stream.binding.ContextStartAfterRefreshListener;
|
||||
import org.springframework.cloud.stream.binding.DefaultBindableChannelFactory;
|
||||
import org.springframework.cloud.stream.binding.InputBindingLifecycle;
|
||||
import org.springframework.cloud.stream.binding.MessageConverterConfigurer;
|
||||
import org.springframework.cloud.stream.binding.OutputBindingLifecycle;
|
||||
@@ -79,8 +79,8 @@ public class ChannelBindingServiceConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ChannelFactory channelFactory(ChannelBindingServiceProperties channelBindingServiceProperties) {
|
||||
return new BindableChannelFactory(messageConverterConfigurer(channelBindingServiceProperties));
|
||||
public BindableChannelFactory channelFactory(ChannelBindingServiceProperties channelBindingServiceProperties) {
|
||||
return new DefaultBindableChannelFactory(messageConverterConfigurer(channelBindingServiceProperties));
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.cloud.stream.aggregate.AggregateApplication;
|
||||
import org.springframework.cloud.stream.aggregate.SharedChannelRegistry;
|
||||
import org.springframework.cloud.stream.annotation.EnableBinding;
|
||||
import org.springframework.cloud.stream.binding.ChannelFactory;
|
||||
import org.springframework.cloud.stream.binding.BindableChannelFactory;
|
||||
import org.springframework.cloud.stream.messaging.Processor;
|
||||
import org.springframework.cloud.stream.messaging.Source;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
@@ -44,7 +44,7 @@ public class ModuleAggregationTest {
|
||||
ConfigurableApplicationContext aggregatedApplicationContext = AggregateApplication.run(TestSource.class,
|
||||
TestProcessor.class);
|
||||
SharedChannelRegistry sharedChannelRegistry = aggregatedApplicationContext.getBean(SharedChannelRegistry.class);
|
||||
ChannelFactory channelFactory = aggregatedApplicationContext.getBean(ChannelFactory.class);
|
||||
BindableChannelFactory channelFactory = aggregatedApplicationContext.getBean(BindableChannelFactory.class);
|
||||
assertNotNull(channelFactory);
|
||||
assertThat(sharedChannelRegistry.getAll().keySet(), hasSize(2));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user