@@ -16,13 +16,18 @@
|
||||
|
||||
package org.springframework.cloud.stream.binder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.reactivestreams.Publisher;
|
||||
|
||||
@@ -44,6 +49,7 @@ import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.ApplicationEventPublisherAware;
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.integration.channel.AbstractMessageChannel;
|
||||
import org.springframework.integration.channel.AbstractSubscribableChannel;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
@@ -145,6 +151,10 @@ public abstract class AbstractMessageChannelBinder<C extends ConsumerProperties,
|
||||
@Nullable ListenerContainerCustomizer<?> containerCustomizer,
|
||||
@Nullable MessageSourceCustomizer<?> sourceCustomizer) {
|
||||
|
||||
SimpleModule module = new SimpleModule();
|
||||
module.addSerializer(Expression.class, new ExpressionSerializer(Expression.class));
|
||||
objectMapper.registerModule(module);
|
||||
|
||||
this.headersToEmbed = headersToEmbed == null ? new String[0] : headersToEmbed;
|
||||
this.provisioningProvider = provisioningProvider;
|
||||
this.containerCustomizer = containerCustomizer == null ? (c, q, g) -> {
|
||||
@@ -464,7 +474,7 @@ public abstract class AbstractMessageChannelBinder<C extends ConsumerProperties,
|
||||
|
||||
MessageSource<?> messageSource = resources.getSource();
|
||||
if (messageSource instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware)messageSource).setBeanFactory(getApplicationContext().getBeanFactory());
|
||||
((BeanFactoryAware) messageSource).setBeanFactory(getApplicationContext().getBeanFactory());
|
||||
}
|
||||
bindingTarget.setSource(messageSource);
|
||||
if (resources.getErrorInfrastructure() != null) {
|
||||
@@ -1146,4 +1156,17 @@ public abstract class AbstractMessageChannelBinder<C extends ConsumerProperties,
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private static class ExpressionSerializer extends StdSerializer<Expression> {
|
||||
|
||||
protected ExpressionSerializer(Class<Expression> t) {
|
||||
super(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(Expression value, JsonGenerator gen, SerializerProvider provider) throws IOException {
|
||||
gen.writeString(value.getExpressionString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user