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

112
pom.xml
View File

@@ -10,12 +10,13 @@
<name>Pivotal Software, Inc.</name>
<url>http://www.spring.io</url>
</organization>
<properties>
<java.version>1.7</java.version>
<spring-boot.version>1.3.0.BUILD-SNAPSHOT</spring-boot.version>
<spring-cloud.version>Brixton.BUILD-SNAPSHOT</spring-cloud.version>
<spring-xd.version>2.0.0.BUILD-SNAPSHOT</spring-xd.version>
</properties>
<properties>
<java.version>1.7</java.version>
<spring-boot.version>1.3.0.BUILD-SNAPSHOT</spring-boot.version>
<spring-cloud.version>Brixton.BUILD-SNAPSHOT</spring-cloud.version>
<spring-xd.version>2.0.0.BUILD-SNAPSHOT</spring-xd.version>
<spring-framework.version>4.2.0.RC2</spring-framework.version>
</properties>
<modules>
<module>spring-cloud-streams</module>
<module>spring-xd-runner</module>
@@ -47,75 +48,36 @@
<artifactId>spring-xd-runner</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.xd</groupId>
<artifactId>spring-xd-dirt</artifactId>
<version>${spring-xd.version}</version>
<exclusions>
<exclusion>
<artifactId>jackson-core-asl</artifactId>
<groupId>org.codehaus.jackson</groupId>
</exclusion>
<exclusion>
<groupId>org.springframework.xd</groupId>
<artifactId>spring-xd-spark-streaming</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.xd</groupId>
<artifactId>spring-xd-hadoop</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.xd</groupId>
<artifactId>spring-xd-batch</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.xd</groupId>
<artifactId>spring-xd-ui</artifactId>
</exclusion>
<exclusion>
<artifactId>slf4j-log4j12</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
<exclusion>
<artifactId>zookeeper</artifactId>
<groupId>org.apache.zookeeper</groupId>
</exclusion>
<exclusion>
<artifactId>spring-boot-starter-security</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
<exclusion>
<artifactId>spring-security-ldap</artifactId>
<groupId>org.springframework.security</groupId>
</exclusion>
<exclusion>
<artifactId>spring-jdbc</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-batch-integration</artifactId>
<groupId>org.springframework.batch</groupId>
</exclusion>
<exclusion>
<artifactId>spring-batch-admin-manager</artifactId>
<groupId>org.springframework.batch</groupId>
</exclusion>
<exclusion>
<artifactId>spring-data-mongodb</artifactId>
<groupId>org.springframework.data</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.xd</groupId>
<artifactId>spring-xd-messagebus-redis</artifactId>
<version>${spring-xd.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.xd</groupId>
<artifactId>spring-xd-messagebus-rabbit</artifactId>
<version>${spring-xd.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.xd</groupId>
<artifactId>spring-xd-codec</artifactId>
<version>${spring-xd.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.xd</groupId>
<artifactId>spring-xd-module</artifactId>
<version>${spring-xd.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.xd</groupId>
<artifactId>spring-xd-messagebus-local</artifactId>
<version>${spring-xd.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.xd</groupId>
<artifactId>spring-xd-messagebus-redis</artifactId>
<version>${spring-xd.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.xd</groupId>
<artifactId>spring-xd-messagebus-rabbit</artifactId>
<version>${spring-xd.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-messaging</artifactId>
<version>${spring-framework.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>

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>

View File

@@ -33,7 +33,12 @@
</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>

View File

@@ -35,7 +35,6 @@ import org.springframework.core.annotation.Order;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.core.env.MapPropertySource;
import org.springframework.xd.dirt.plugins.job.JobPluginMetadataResolver;
import org.springframework.xd.dirt.plugins.stream.ModuleTypeConversionPluginMetadataResolver;
import org.springframework.xd.module.ModuleDefinition;
import org.springframework.xd.module.ModuleDefinitions;
@@ -104,7 +103,6 @@ ApplicationContextInitializer<ConfigurableApplicationContext> {
List<ModuleOptionsMetadataResolver> delegates = new ArrayList<ModuleOptionsMetadataResolver>();
delegates.add(defaultResolver());
delegates.add(new ModuleTypeConversionPluginMetadataResolver());
delegates.add(new JobPluginMetadataResolver());
DelegatingModuleOptionsMetadataResolver delegatingResolver = new DelegatingModuleOptionsMetadataResolver();
delegatingResolver.setDelegates(delegates);
ModuleOptionsMetadataResolver resolver = delegatingResolver;

View File

@@ -0,0 +1,41 @@
/*
* Copyright 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.xd.dirt.plugins.stream;
import org.springframework.core.convert.converter.Converter;
import org.springframework.http.MediaType;
import org.springframework.util.MimeType;
/**
* A custom converter for {@link MediaType} that accepts a plain java class name as a shorthand for
* {@code application/x-java-object;type=the.qualified.ClassName}.
*
*
* @author Eric Bottard
* @author David Turanski
*/
public class CustomMimeTypeConverter implements Converter<String, MimeType> {
@Override
public MimeType convert(String source) {
if (!source.contains("/")) {
return MimeType.valueOf("application/x-java-object;type=" + source);
}
return MimeType.valueOf(source);
}
}

View File

@@ -0,0 +1,117 @@
/*
* Copyright 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.xd.dirt.plugins.stream;
import static org.springframework.xd.module.ModuleType.processor;
import static org.springframework.xd.module.ModuleType.sink;
import static org.springframework.xd.module.ModuleType.source;
import java.util.ArrayList;
import java.util.List;
import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.util.MimeType;
import org.springframework.xd.module.ModuleDefinition;
import org.springframework.xd.module.ModuleType;
import org.springframework.xd.module.options.FlattenedCompositeModuleOptionsMetadata;
import org.springframework.xd.module.options.ModuleOptionsMetadata;
import org.springframework.xd.module.options.ModuleOptionsMetadataResolver;
import org.springframework.xd.module.options.PojoModuleOptionsMetadata;
import org.springframework.xd.module.options.spi.ModuleOption;
/**
* A {@link ModuleOptionsMetadataResolver} that will dynamically add {@code inputType} and {@code outputType} options to
* every module, according to their type.
*
* @see ModuleTypeConversionPlugin
* @author Eric Bottard
* @author David Turanski
*/
public class ModuleTypeConversionPluginMetadataResolver implements ModuleOptionsMetadataResolver {
private final GenericConversionService conversionService = new GenericConversionService();
public ModuleTypeConversionPluginMetadataResolver() {
conversionService.addConverter(new CustomMimeTypeConverter());
}
@Override
public ModuleOptionsMetadata resolve(ModuleDefinition moduleDefinition) {
List<ModuleOptionsMetadata> moms = new ArrayList<ModuleOptionsMetadata>();
ModuleType type = moduleDefinition.getType();
if (type == source || type == processor) {
moms.add(new PojoModuleOptionsMetadata(OutputOptionsMetadata.class, conversionService));
}
if (type == sink || type == processor) {
moms.add(new PojoModuleOptionsMetadata(InputOptionsMetadata.class, conversionService));
}
// Don't force deep layering if it's not needed
switch (moms.size()) {
case 0:
return null;
case 1:
return moms.iterator().next();
default:
return new FlattenedCompositeModuleOptionsMetadata(moms);
}
}
/**
* Provides info about the {@code inputType} option.
*
* @author Eric Bottard
*/
@SuppressWarnings("unused")
private static class InputOptionsMetadata {
private MimeType inputType;
public MimeType getInputType() {
return inputType;
}
@ModuleOption("how this module should interpret messages it consumes")
public void setInputType(MimeType inputType) {
this.inputType = inputType;
}
}
/**
* Provides info about the {@code outputType} option.
*
* @author Eric Bottard
*/
@SuppressWarnings("unused")
private static class OutputOptionsMetadata {
private MimeType outputType;
public MimeType getOutputType() {
return outputType;
}
@ModuleOption("how this module should emit messages it produces")
public void setOutputType(MimeType outputType) {
this.outputType = outputType;
}
}
}

View File

@@ -37,6 +37,10 @@
<artifactId>spring-cloud-lattice-connector</artifactId>
<version>1.0.2.BUILD-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>

View File

@@ -0,0 +1,69 @@
/*
* Copyright 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.modules.metadata;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.xd.module.options.spi.ModuleOption;
import org.springframework.xd.module.options.spi.ModulePlaceholders;
/**
* Captures options for the {@code log} sink module.
*
* @author Eric Bottard
* @author Gary Russell
*/
public class LogSinkOptionsMetadata {
private String name = ModulePlaceholders.XD_STREAM_NAME;
private String expression = "payload";
private String level = "INFO";
@NotBlank
public String getName() {
return name;
}
@ModuleOption("the name of the log category to log to (will be prefixed by 'xd.sink.')")
public void setName(String name) {
this.name = name;
}
@NotBlank
public String getExpression() {
return expression;
}
@ModuleOption("the expression to be evaluated for the log content; use '#root' to log the full message")
public void setExpression(String expression) {
this.expression = expression;
}
@NotBlank
public String getLevel() {
return level;
}
@ModuleOption("the log level")
public void setLevel(String level) {
this.level = level.toUpperCase();
}
}

View File

@@ -37,6 +37,10 @@
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>

View File

@@ -0,0 +1,61 @@
/*
* Copyright 2013-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.xd.dirt.modules.metadata;
import org.springframework.xd.module.options.mixins.MaxMessagesDefaultOneMixin;
import org.springframework.xd.module.options.mixins.PeriodicTriggerMixin;
import org.springframework.xd.module.options.spi.Mixin;
import org.springframework.xd.module.options.spi.ModuleOption;
import org.springframework.xd.module.options.validation.DateFormat;
/**
* Describes options to the {@code time} source module.
*
* @author Eric Bottard
* @author Gary Russell
*/
@Mixin({ PeriodicTriggerMixin.class, MaxMessagesDefaultOneMixin.class })
public class TimeSourceOptionsMetadata {
private String format = "yyyy-MM-dd HH:mm:ss";
private int fixedDelay = 1;
@DateFormat
public String getFormat() {
return format;
}
@ModuleOption("how to render the current time, using SimpleDateFormat")
public void setFormat(String format) {
this.format = format;
}
public int getFixedDelay() {
return fixedDelay;
}
@ModuleOption("time delay between messages, expressed in TimeUnits (seconds by default)")
public void setFixedDelay(int fixedDelay) {
this.fixedDelay = fixedDelay;
}
}

View File

@@ -42,6 +42,10 @@
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>

View File

@@ -0,0 +1,61 @@
/*
* Copyright 2013-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.xd.dirt.modules.metadata;
import org.springframework.xd.module.options.mixins.MaxMessagesDefaultOneMixin;
import org.springframework.xd.module.options.mixins.PeriodicTriggerMixin;
import org.springframework.xd.module.options.spi.Mixin;
import org.springframework.xd.module.options.spi.ModuleOption;
import org.springframework.xd.module.options.validation.DateFormat;
/**
* Describes options to the {@code time} source module.
*
* @author Eric Bottard
* @author Gary Russell
*/
@Mixin({ PeriodicTriggerMixin.class, MaxMessagesDefaultOneMixin.class })
public class TimeSourceOptionsMetadata {
private String format = "yyyy-MM-dd HH:mm:ss";
private int fixedDelay = 1;
@DateFormat
public String getFormat() {
return format;
}
@ModuleOption("how to render the current time, using SimpleDateFormat")
public void setFormat(String format) {
this.format = format;
}
public int getFixedDelay() {
return fixedDelay;
}
@ModuleOption("time delay between messages, expressed in TimeUnits (seconds by default)")
public void setFixedDelay(int fixedDelay) {
this.fixedDelay = fixedDelay;
}
}

View File

@@ -37,6 +37,10 @@
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>