removed spring-xd-dirt dependencies

This commit is contained in:
David Turanski
2015-07-08 14:39:43 -04:00
committed by Mark Fisher
parent 498d9f5c64
commit 3218c39d47
17 changed files with 591 additions and 80 deletions

View File

@@ -31,11 +31,34 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-messaging</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.xd</groupId>
<artifactId>spring-xd-dirt</artifactId>
<artifactId>spring-xd-codec</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.xd</groupId>
<artifactId>spring-xd-module</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.xd</groupId>
<artifactId>spring-xd-messagebus-local</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.xd</groupId>
<artifactId>spring-xd-messagebus-redis</artifactId>

View File

@@ -49,7 +49,7 @@ import org.springframework.xd.dirt.integration.bus.MessageBusAwareRouterBeanPost
*
*/
@Configuration
@ImportResource("classpath*:/META-INF/spring-xd/bus/codec.xml")
@ImportResource("classpath*:/META-INF/spring-bus/codec.xml")
public class ChannelBindingAdapterConfiguration {
@Autowired

View File

@@ -0,0 +1,72 @@
/*
* Copyright 2013-2014 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.xd.dirt.integration.bus;
import java.util.Properties;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.core.BeanFactoryMessageChannelDestinationResolver;
import org.springframework.messaging.core.DestinationResolutionException;
/**
* A {@link org.springframework.messaging.core.DestinationResolver} implementation that first checks for any channel
* whose name begins with a colon in the {@link MessageBus}.
*
* @author Mark Fisher
* @author Gary Russell
*/
public class MessageBusAwareChannelResolver extends BeanFactoryMessageChannelDestinationResolver {
private final MessageBus messageBus;
private final Properties producerProperties;
public MessageBusAwareChannelResolver(MessageBus messageBus, Properties producerProperties) {
this.messageBus = messageBus;
this.producerProperties = producerProperties;
}
@Override
public MessageChannel resolveDestination(String name) {
MessageChannel channel = null;
try {
return super.resolveDestination(name);
}
catch (DestinationResolutionException e) {
}
if (name.indexOf(":") != -1) {
if (messageBus != null) {
String[] tokens = name.split(":", 2);
String type = tokens[0];
if ("queue".equals(type)) {
channel = this.messageBus.bindDynamicProducer(name, this.producerProperties);
}
else if ("topic".equals(type)) {
channel = this.messageBus.bindDynamicPubSubProducer(name, this.producerProperties);
}
else {
throw new IllegalArgumentException("unrecognized channel type: " + type);
}
}
}
if (channel == null) {
channel = super.resolveDestination(name);
}
return channel;
}
}

View File

@@ -0,0 +1,60 @@
/*
* Copyright 2013-2014 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.xd.dirt.integration.bus;
import java.util.Properties;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.integration.router.AbstractMappingMessageRouter;
/**
* A {@link BeanPostProcessor} that sets a {@link MessageBusAwareChannelResolver} on any bean of type
* {@link AbstractMappingMessageRouter} within the context.
*
* @author Mark Fisher
* @author Gary Russell
*/
public class MessageBusAwareRouterBeanPostProcessor implements BeanPostProcessor, BeanFactoryAware {
private final MessageBusAwareChannelResolver channelResolver;
public MessageBusAwareRouterBeanPostProcessor(MessageBus messageBus, Properties producerProperties) {
this.channelResolver = new MessageBusAwareChannelResolver(messageBus, producerProperties);
}
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
channelResolver.setBeanFactory(beanFactory);
}
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof AbstractMappingMessageRouter) {
((AbstractMappingMessageRouter) bean).setChannelResolver(channelResolver);
}
return bean;
}
}

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="codec" class="org.springframework.xd.dirt.integration.bus.serializer.CompositeCodec">
<constructor-arg name="delegates">
<map>
<!-- pulls in spring-xd-tuple -->
<!--<entry key="org.springframework.xd.tuple.Tuple">-->
<!--<bean class="org.springframework.xd.tuple.serializer.kryo.TupleCodec"/>-->
<!--</entry>-->
<entry key="java.io.File">
<bean class="org.springframework.xd.dirt.integration.bus.serializer.kryo.FileCodec"/>
</entry>
</map>
</constructor-arg>
<constructor-arg name="defaultCodec" ref="defaultCodec"/>
</bean>
<bean id="defaultCodec" class="org.springframework.xd.dirt.integration.bus.serializer.kryo.PojoCodec">
<constructor-arg ref="kryoRegistrar"/>
</bean>
<bean id="kryoRegistrar" class="org.springframework.xd.dirt.integration.bus.serializer.kryo.KryoNullRegistrar"/>
</beans>