Removed ChannelFactory strategy and implementations prior to general channel refactoring.
This commit is contained in:
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
* 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.bus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.integration.channel.ChannelInterceptor;
|
||||
import org.springframework.integration.channel.MessageChannel;
|
||||
import org.springframework.integration.channel.factory.ChannelFactory;
|
||||
import org.springframework.integration.channel.factory.QueueChannelFactory;
|
||||
|
||||
/**
|
||||
* Creates a channel by delegating to the "channelFactory" bean defined
|
||||
* within the {@link ApplicationContext} or else the default implementation
|
||||
* (QueueChannelFactory).
|
||||
* <p>
|
||||
* As a {@link FactoryBean}, this class is solely intended to be used within
|
||||
* an ApplicationContext.
|
||||
*
|
||||
* @author Marius Bogoevici
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class DefaultChannelFactoryBean implements ApplicationContextAware, FactoryBean, BeanNameAware {
|
||||
|
||||
public static final String CHANNEL_FACTORY_BEAN_NAME = "channelFactory";
|
||||
|
||||
private volatile String beanName;
|
||||
|
||||
private volatile List<ChannelInterceptor> interceptors;
|
||||
|
||||
private volatile ApplicationContext applicationContext;
|
||||
|
||||
private volatile MessageChannel channel;
|
||||
|
||||
private final Object initializationMonitor = new Object();
|
||||
|
||||
|
||||
public void setApplicationContext(ApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
public void setBeanName(String beanName) {
|
||||
this.beanName = beanName;
|
||||
}
|
||||
|
||||
public void setInterceptors(List<ChannelInterceptor> interceptors) {
|
||||
this.interceptors = interceptors;
|
||||
}
|
||||
|
||||
public Object getObject() throws Exception {
|
||||
synchronized (this.initializationMonitor) {
|
||||
if (this.channel == null) {
|
||||
ChannelFactory channelFactory = null;
|
||||
if (this.applicationContext.containsBean(CHANNEL_FACTORY_BEAN_NAME)) {
|
||||
channelFactory = (ChannelFactory) this.applicationContext.getBean(CHANNEL_FACTORY_BEAN_NAME);
|
||||
}
|
||||
else {
|
||||
channelFactory = new QueueChannelFactory();
|
||||
}
|
||||
this.channel = channelFactory.getChannel(this.beanName, this.interceptors);
|
||||
}
|
||||
}
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
public Class<?> getObjectType() {
|
||||
if (this.channel == null) {
|
||||
return MessageChannel.class;
|
||||
}
|
||||
return this.channel.getClass();
|
||||
}
|
||||
|
||||
public boolean isSingleton() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* 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.channel.factory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.integration.channel.AbstractMessageChannel;
|
||||
import org.springframework.integration.channel.ChannelInterceptor;
|
||||
import org.springframework.integration.channel.MessageChannel;
|
||||
|
||||
/**
|
||||
* Base class for {@link ChannelFactory} implementations. Subclasses should
|
||||
* override {@literal createChannelInternal()}.
|
||||
*
|
||||
* @author Marius Bogoevici
|
||||
*/
|
||||
public abstract class AbstractChannelFactory implements ChannelFactory {
|
||||
|
||||
public AbstractChannelFactory() {
|
||||
super();
|
||||
}
|
||||
|
||||
public final MessageChannel getChannel(String name, List<ChannelInterceptor> interceptors) {
|
||||
AbstractMessageChannel channel = createChannelInternal();
|
||||
if (null != interceptors) {
|
||||
channel.setInterceptors(interceptors);
|
||||
}
|
||||
if (name != null && channel.getName() == null) {
|
||||
channel.setBeanName(name);
|
||||
}
|
||||
return channel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method to be overridden by subclasses. It assumes that subclasses will return
|
||||
* subclasses of AbstractMessageChannel.
|
||||
*/
|
||||
protected abstract AbstractMessageChannel createChannelInternal();
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* 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.channel.factory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.integration.channel.ChannelInterceptor;
|
||||
import org.springframework.integration.channel.MessageChannel;
|
||||
|
||||
/**
|
||||
* Interface for a channel factory.
|
||||
*
|
||||
* @author Marius Bogoevici
|
||||
*/
|
||||
public interface ChannelFactory {
|
||||
|
||||
/**
|
||||
* Creates a channel based on the provided name and interceptors.
|
||||
*/
|
||||
MessageChannel getChannel(String name, List<ChannelInterceptor> interceptors);
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* 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.channel.factory;
|
||||
|
||||
import org.springframework.integration.channel.AbstractMessageChannel;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
|
||||
/**
|
||||
* A {@link ChannelFactory} for creating {@link DirectChannel} instances.
|
||||
*
|
||||
* @author Marius Bogoevici
|
||||
*/
|
||||
public class DirectChannelFactory extends AbstractChannelFactory {
|
||||
|
||||
@Override
|
||||
protected AbstractMessageChannel createChannelInternal() {
|
||||
return new DirectChannel();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* 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.channel.factory;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.springframework.integration.channel.AbstractMessageChannel;
|
||||
import org.springframework.integration.channel.PriorityChannel;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A {@link ChannelFactory} for creating {@link PriorityChannel} instances.
|
||||
* @author Marius Bogoevici
|
||||
*
|
||||
*/
|
||||
public class PriorityChannelFactory extends AbstractChannelFactory {
|
||||
|
||||
private int capacity = PriorityChannel.DEFAULT_CAPACITY;
|
||||
|
||||
private Comparator<Message<?>> comparator;
|
||||
|
||||
|
||||
public void setCapacity(int capacity) {
|
||||
Assert.isTrue(capacity > 0, "capacity must be a positive value");
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
public void setComparator(Comparator<Message<?>> comparator) {
|
||||
this.comparator = comparator;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractMessageChannel createChannelInternal() {
|
||||
return new PriorityChannel(this.capacity, this.comparator);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* 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.channel.factory;
|
||||
|
||||
import org.springframework.integration.channel.AbstractMessageChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Default implementation of a {@link ChannelFactory}, which will create instances of a
|
||||
* {@link QueueChannel}.
|
||||
*
|
||||
* @author Marius Bogoevici
|
||||
*/
|
||||
public class QueueChannelFactory extends AbstractChannelFactory{
|
||||
|
||||
int queueCapacity = QueueChannel.DEFAULT_CAPACITY;
|
||||
|
||||
public int getQueueCapacity() {
|
||||
return queueCapacity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the queue capacity for the newly created channels.
|
||||
* By default, the queue capacity is {@literal QueueChannel.DEFAULT_CAPACITY}
|
||||
* @param queueCapacity
|
||||
*/
|
||||
public void setQueueCapacity(int queueCapacity) {
|
||||
Assert.state(queueCapacity > 0, "Queue capacity must be greater than zero");
|
||||
this.queueCapacity = queueCapacity;
|
||||
}
|
||||
|
||||
protected AbstractMessageChannel createChannelInternal() {
|
||||
return new QueueChannel(queueCapacity);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* 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.channel.factory;
|
||||
|
||||
import org.springframework.integration.channel.AbstractMessageChannel;
|
||||
import org.springframework.integration.channel.RendezvousChannel;
|
||||
|
||||
/**
|
||||
* A {@link ChannelFactory} for creating {@link RendezvousChannel} instances.
|
||||
*
|
||||
* @author Marius Bogoevici
|
||||
*/
|
||||
public class RendezvousChannelFactory extends AbstractChannelFactory {
|
||||
|
||||
@Override
|
||||
protected AbstractMessageChannel createChannelInternal() {
|
||||
return new RendezvousChannel();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* 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.channel.factory;
|
||||
|
||||
import org.springframework.integration.channel.AbstractMessageChannel;
|
||||
import org.springframework.integration.channel.ThreadLocalChannel;
|
||||
|
||||
/**
|
||||
* A {@link ChannelFactory} implementation for creating {@link ThreadLocalChannel} instances.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class ThreadLocalChannelFactory extends AbstractChannelFactory {
|
||||
|
||||
@Override
|
||||
protected AbstractMessageChannel createChannelInternal() {
|
||||
return new ThreadLocalChannel();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* 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.config;
|
||||
|
||||
import org.springframework.integration.bus.DefaultChannelFactoryBean;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Parser for the <channel> element.
|
||||
*
|
||||
* @author Marius Bogoevici
|
||||
*/
|
||||
public class DefaultChannelParser extends AbstractChannelParser {
|
||||
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return DefaultChannelFactoryBean.class;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -49,7 +49,7 @@ public class IntegrationNamespaceHandler extends NamespaceHandlerSupport {
|
||||
public void init() {
|
||||
registerBeanDefinitionParser("message-bus", new MessageBusParser());
|
||||
registerBeanDefinitionParser("annotation-driven", new AnnotationDrivenParser());
|
||||
registerBeanDefinitionParser("channel", new DefaultChannelParser());
|
||||
registerBeanDefinitionParser("channel", new QueueChannelParser());
|
||||
registerBeanDefinitionParser("queue-channel", new QueueChannelParser());
|
||||
registerBeanDefinitionParser("publish-subscribe-channel", new PublishSubscribeChannelParser());
|
||||
registerBeanDefinitionParser("direct-channel", new DirectChannelParser());
|
||||
|
||||
Reference in New Issue
Block a user