diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/AbstractBindableProxyFactory.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/AbstractBindableProxyFactory.java index 46c20c8bd..92b4d2d9f 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/AbstractBindableProxyFactory.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/AbstractBindableProxyFactory.java @@ -57,8 +57,6 @@ public class AbstractBindableProxyFactory implements Bindable { protected Class type; - private BeanFactory beanFactory; - public AbstractBindableProxyFactory(Class type) { this.type = type; } diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/BindingBeanDefinitionRegistryUtils.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/BindingBeanDefinitionRegistryUtils.java deleted file mode 100644 index 9fb8b92f3..000000000 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/BindingBeanDefinitionRegistryUtils.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2015-2019 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 - * - * https://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.cloud.stream.binding; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.util.Map; - -import org.springframework.beans.factory.BeanDefinitionStoreException; -import org.springframework.beans.factory.support.AutowireCandidateQualifier; -import org.springframework.beans.factory.support.BeanDefinitionRegistry; -import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.core.annotation.AnnotationUtils; -import org.springframework.util.StringUtils; - -/** - * Utility class for registering bean definitions for binding targets. - * - * @author Marius Bogoevici - * @author Dave Syer - * @author Artem Bilan - */ -public abstract class BindingBeanDefinitionRegistryUtils { - - public static void registerInputBindingTargetBeanDefinition(String qualifierValue, - String name, String bindingTargetInterfaceBeanName, - String bindingTargetInterfaceMethodName, BeanDefinitionRegistry registry) { - System.out.println(); -// registerBindingTargetBeanDefinition(Input.class, qualifierValue, name, -// bindingTargetInterfaceBeanName, bindingTargetInterfaceMethodName, -// registry); - } - - public static void registerOutputBindingTargetBeanDefinition(String qualifierValue, - String name, String bindingTargetInterfaceBeanName, - String bindingTargetInterfaceMethodName, BeanDefinitionRegistry registry) { - System.out.println(); -// registerBindingTargetBeanDefinition(Output.class, qualifierValue, name, -// bindingTargetInterfaceBeanName, bindingTargetInterfaceMethodName, -// registry); - } - - private static void registerBindingTargetBeanDefinition( - Class qualifier, String qualifierValue, String name, - String bindingTargetInterfaceBeanName, - String bindingTargetInterfaceMethodName, BeanDefinitionRegistry registry) { - - if (registry.containsBeanDefinition(name)) { - throw new BeanDefinitionStoreException(bindingTargetInterfaceBeanName, name, - "bean definition with this name already exists - " - + registry.getBeanDefinition(name)); - } - - RootBeanDefinition rootBeanDefinition = new RootBeanDefinition(); - rootBeanDefinition.setFactoryBeanName(bindingTargetInterfaceBeanName); - rootBeanDefinition.setUniqueFactoryMethodName(bindingTargetInterfaceMethodName); - rootBeanDefinition - .addQualifier(new AutowireCandidateQualifier(qualifier, qualifierValue)); - registry.registerBeanDefinition(name, rootBeanDefinition); - } - - public static void registerBindingTargetBeanDefinitions(Class type, - final String bindingTargetInterfaceBeanName, - final BeanDefinitionRegistry registry) { -// ReflectionUtils.doWithMethods(type, method -> { -// Input input = AnnotationUtils.findAnnotation(method, Input.class); -// if (input != null) { -// String name = getBindingTargetName(input, method); -// if (!registry.containsBeanDefinition(name)) { -// registerInputBindingTargetBeanDefinition(input.value(), name, -// bindingTargetInterfaceBeanName, method.getName(), registry); -// } -// } -// Output output = AnnotationUtils.findAnnotation(method, Output.class); -// if (output != null) { -// String name = getBindingTargetName(output, method); -// if (!registry.containsBeanDefinition(name)) { -// registerOutputBindingTargetBeanDefinition(output.value(), name, -// bindingTargetInterfaceBeanName, method.getName(), registry); -// } -// } -// }); - } - - public static void registerBindingTargetsQualifiedBeanDefinitions(Class parent, - Class type, final BeanDefinitionRegistry registry) { - - if (type.isInterface()) { - RootBeanDefinition rootBeanDefinition = new RootBeanDefinition( - BindableProxyFactory.class); - rootBeanDefinition.getConstructorArgumentValues() - .addGenericArgumentValue(type); - registry.registerBeanDefinition(type.getName(), rootBeanDefinition); - } - else { - RootBeanDefinition rootBeanDefinition = new RootBeanDefinition(type); - registry.registerBeanDefinition(type.getName(), rootBeanDefinition); - } - } - - public static String getBindingTargetName(Annotation annotation, Method method) { - Map attrs = AnnotationUtils.getAnnotationAttributes(annotation, - false); - if (attrs.containsKey("value") - && StringUtils.hasText((CharSequence) attrs.get("value"))) { - return (String) attrs.get("value"); - } - return method.getName(); - } - -} diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/StreamAnnotationCommonMethodUtils.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/StreamAnnotationCommonMethodUtils.java deleted file mode 100644 index 8c10967aa..000000000 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/StreamAnnotationCommonMethodUtils.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2016-2017 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 - * - * https://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.cloud.stream.binding; - -import java.lang.reflect.Method; - -import org.springframework.core.MethodParameter; -import org.springframework.core.annotation.AnnotationUtils; -import org.springframework.messaging.handler.annotation.SendTo; -import org.springframework.util.Assert; -import org.springframework.util.ObjectUtils; - -/** - * Common methods that can be used across various Stream annotations. - * - * @author Soby Chacko - * @since 1.3.0 - */ -public abstract class StreamAnnotationCommonMethodUtils { - - public static String getOutboundBindingTargetName(Method method) { - SendTo sendTo = AnnotationUtils.findAnnotation(method, SendTo.class); - if (sendTo != null) { - Assert.isTrue(!ObjectUtils.isEmpty(sendTo.value()), - StreamAnnotationErrorMessages.ATLEAST_ONE_OUTPUT); - Assert.isTrue(sendTo.value().length == 1, - StreamAnnotationErrorMessages.SEND_TO_MULTIPLE_DESTINATIONS); - Assert.hasText(sendTo.value()[0], - StreamAnnotationErrorMessages.SEND_TO_EMPTY_DESTINATION); - return sendTo.value()[0]; - } -// Output output = AnnotationUtils.findAnnotation(method, Output.class); -// if (output != null) { -// Assert.isTrue(StringUtils.hasText(output.value()), -// StreamAnnotationErrorMessages.ATLEAST_ONE_OUTPUT); -// return output.value(); -// } - return null; - } - - public static int outputAnnotationCount(Method method) { - int outputAnnotationCount = 0; - for (int parameterIndex = 0; parameterIndex < method - .getParameterTypes().length; parameterIndex++) { - MethodParameter methodParameter = MethodParameter.forExecutable(method, - parameterIndex); -// if (methodParameter.hasParameterAnnotation(Output.class)) { -// outputAnnotationCount++; -// } - } - return outputAnnotationCount; - } - -} diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BindingServiceConfiguration.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BindingServiceConfiguration.java index f959b0052..f3084e0c0 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BindingServiceConfiguration.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BindingServiceConfiguration.java @@ -28,7 +28,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.beans.BeansException; import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; @@ -43,7 +42,6 @@ import org.springframework.cloud.stream.binder.BinderType; import org.springframework.cloud.stream.binder.BinderTypeRegistry; import org.springframework.cloud.stream.binder.DefaultBinderFactory; import org.springframework.cloud.stream.binding.Bindable; -import org.springframework.cloud.stream.binding.BinderAwareRouter; import org.springframework.cloud.stream.binding.BindingService; import org.springframework.cloud.stream.binding.BindingsLifecycleController; import org.springframework.cloud.stream.binding.ContextStartAfterRefreshListener; @@ -62,13 +60,10 @@ import org.springframework.context.annotation.Role; import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.integration.channel.PublishSubscribeChannel; import org.springframework.integration.handler.AbstractReplyProducingMessageHandler; -import org.springframework.integration.router.AbstractMappingMessageRouter; import org.springframework.lang.Nullable; import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.core.DestinationResolver; import org.springframework.scheduling.TaskScheduler; import org.springframework.util.Assert; -import org.springframework.util.CollectionUtils; import org.springframework.util.ObjectUtils; /** @@ -84,7 +79,6 @@ import org.springframework.util.ObjectUtils; * @author Oleg Zhurakousky * @author Soby Chacko */ -@SuppressWarnings("deprecation") @Configuration(proxyBeanMethods = false) @EnableConfigurationProperties({ BindingServiceProperties.class, SpringIntegrationProperties.class, StreamFunctionProperties.class }) @@ -243,16 +237,16 @@ public class BindingServiceConfiguration { return new DynamicDestinationsBindable(); } - @Bean - @ConditionalOnMissingBean - public BinderAwareRouter binderAwareRouterBeanPostProcessor( - @Autowired(required = false) List routers, - @Autowired(required = false) @Qualifier("binderAwareChannelResolver") - DestinationResolver channelResolver) { - final AbstractMappingMessageRouter[] routersArray = CollectionUtils.isEmpty(routers) ? - new AbstractMappingMessageRouter[]{} : routers.toArray(new AbstractMappingMessageRouter[]{}); - return new BinderAwareRouter(routersArray, channelResolver); - } +// @Bean +// @ConditionalOnMissingBean +// public BinderAwareRouter binderAwareRouterBeanPostProcessor( +// @Autowired(required = false) List routers, +// @Autowired(required = false) @Qualifier("binderAwareChannelResolver") +// DestinationResolver channelResolver) { +// final AbstractMappingMessageRouter[] routersArray = CollectionUtils.isEmpty(routers) ? +// new AbstractMappingMessageRouter[]{} : routers.toArray(new AbstractMappingMessageRouter[]{}); +// return new BinderAwareRouter(routersArray, channelResolver); +// } @Bean public ApplicationListener appListener( diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/function/StreamBridge.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/function/StreamBridge.java index 2c2dbeecd..7aab7f1f2 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/function/StreamBridge.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/function/StreamBridge.java @@ -70,7 +70,7 @@ import org.springframework.util.StringUtils; * @since 3.0.3 * */ -@SuppressWarnings("deprecation") +@SuppressWarnings("rawtypes") public final class StreamBridge implements SmartInitializingSingleton { private static String STREAM_BRIDGE_FUNC_NAME = "streamBridge"; @@ -202,7 +202,7 @@ public final class StreamBridge implements SmartInitializingSingleton { * @param outputContentType content type to be used to deal with output type conversion * @return true if data was sent successfully, otherwise false or throws an exception. */ - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({ "unchecked"}) public boolean send(String bindingName, @Nullable String binderName, Object data, MimeType outputContentType) { if (!(data instanceof Message)) { data = MessageBuilder.withPayload(data).build(); @@ -253,7 +253,7 @@ public final class StreamBridge implements SmartInitializingSingleton { this.initialized = true; } - @SuppressWarnings({ "unchecked", "rawtypes"}) + @SuppressWarnings({ "unchecked"}) synchronized MessageChannel resolveDestination(String destinationName, ProducerProperties producerProperties, String binderName) { MessageChannel messageChannel = this.channelCache.get(destinationName); if (messageChannel == null && this.applicationContext.containsBean(destinationName)) {