GH-2522 polishing previous commit
This commit is contained in:
@@ -38,7 +38,6 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.cloud.function.context.FunctionCatalog;
|
||||
import org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry;
|
||||
import org.springframework.cloud.stream.config.ListenerContainerCustomizer;
|
||||
import org.springframework.cloud.stream.reflection.GenericsUtils;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
@@ -413,27 +412,6 @@ public class DefaultBinderFactory implements BinderFactory, DisposableBean, Appl
|
||||
}
|
||||
else if (this.context != null) {
|
||||
this.propagateSharedBeans(binderProducingContext);
|
||||
Map<String, ListenerContainerCustomizer> customizers = this.context.getBeansOfType(ListenerContainerCustomizer.class);
|
||||
if (!CollectionUtils.isEmpty(customizers)) {
|
||||
for (Entry<String, ListenerContainerCustomizer> customizerEntry : customizers.entrySet()) {
|
||||
ListenerContainerCustomizer customizerWrapper = new ListenerContainerCustomizer() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void configure(Object container, String destinationName, String group) {
|
||||
try {
|
||||
customizerEntry.getValue().configure(container, destinationName, group);
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.warn("Failed while applying ListenerContainerCustomizer. In situations when multiple "
|
||||
+ "binders are used this is expected, since a particular customizer may not be applicable.");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
((GenericApplicationContext) binderProducingContext).registerBean(customizerEntry.getKey(),
|
||||
ListenerContainerCustomizer.class, () -> customizerWrapper);
|
||||
}
|
||||
}
|
||||
binderProducingContext.addApplicationListener(new ApplicationListener<ApplicationEvent>() {
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationEvent event) {
|
||||
|
||||
@@ -22,11 +22,13 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.boot.context.properties.ConfigurationPropertiesBinding;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.context.annotation.Role;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.core.convert.support.ConfigurableConversionService;
|
||||
import org.springframework.expression.EvaluationContext;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.ParseException;
|
||||
@@ -67,8 +69,13 @@ public class SpelExpressionConverterConfiguration {
|
||||
@Bean
|
||||
@ConfigurationPropertiesBinding
|
||||
@IntegrationConverter
|
||||
public Converter<String, Expression> spelConverter() {
|
||||
return new SpelConverter();
|
||||
public Converter<String, Expression> spelConverter(ConfigurableApplicationContext context) {
|
||||
SpelConverter converter = new SpelConverter();
|
||||
ConfigurableConversionService cs = (ConfigurableConversionService) context.getBeanFactory().getConversionService();
|
||||
if (cs != null) {
|
||||
cs.addConverter(converter);
|
||||
}
|
||||
return converter;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user