Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@
import org.springframework.aop.scope.ScopedProxyUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.beans.factory.support.BeanDefinitionValidationException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
Expand Down Expand Up @@ -87,8 +85,6 @@ private void registerTemplate(String beanName, Object bean) {
}

ExtRocketMQConsumerConfiguration annotation = clazz.getAnnotation(ExtRocketMQConsumerConfiguration.class);
GenericApplicationContext genericApplicationContext = (GenericApplicationContext) applicationContext;
validate(annotation, genericApplicationContext);

DefaultLitePullConsumer consumer = null;
try {
Expand Down Expand Up @@ -142,14 +138,4 @@ private String resolvePlaceholders(String text, String defaultValue) {
String value = environment.resolvePlaceholders(text);
return StringUtils.hasLength(value) ? value : defaultValue;
}

private void validate(ExtRocketMQConsumerConfiguration annotation,
GenericApplicationContext genericApplicationContext) {
if (genericApplicationContext.isBeanNameInUse(annotation.value())) {
throw new BeanDefinitionValidationException(
String.format("Bean {} has been used in Spring Application Context, " +
"please check the @ExtRocketMQConsumerConfiguration",
annotation.value()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.util.StringUtils;

Expand Down Expand Up @@ -81,8 +80,6 @@ private void registerTemplate(String beanName, Object bean) {
}

ExtRocketMQTemplateConfiguration annotation = clazz.getAnnotation(ExtRocketMQTemplateConfiguration.class);
GenericApplicationContext genericApplicationContext = (GenericApplicationContext) applicationContext;
validate(annotation, genericApplicationContext);

DefaultMQProducer mqProducer = createProducer(annotation);
try {
Expand Down Expand Up @@ -134,13 +131,4 @@ private DefaultMQProducer createProducer(ExtRocketMQTemplateConfiguration annota
producer.setInstanceName(annotation.instanceName());
return producer;
}

private void validate(ExtRocketMQTemplateConfiguration annotation,
GenericApplicationContext genericApplicationContext) {
if (genericApplicationContext.isBeanNameInUse(annotation.value())) {
throw new BeanDefinitionValidationException(String.format("Bean %s has been used in Spring Application Context, " +
"please check the @ExtRocketMQTemplateConfiguration",
annotation.value()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@
import org.springframework.aop.scope.ScopedProxyUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.beans.factory.support.BeanDefinitionValidationException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
Expand Down Expand Up @@ -87,8 +85,6 @@ private void registerTemplate(String beanName, Object bean) {
throw new IllegalStateException(clazz + " is not instance of " + RocketMQClientTemplate.class.getName());
}
org.apache.rocketmq.client.annotation.ExtConsumerResetConfiguration annotation = clazz.getAnnotation(org.apache.rocketmq.client.annotation.ExtConsumerResetConfiguration.class);
GenericApplicationContext genericApplicationContext = (GenericApplicationContext) applicationContext;
validate(annotation, genericApplicationContext);

SimpleConsumerBuilder consumerBuilder = null;
SimpleConsumer simpleConsumer = null;
Expand Down Expand Up @@ -145,16 +141,6 @@ private String resolvePlaceholders(String text, String defaultValue) {
return StringUtils.hasLength(value) ? value : defaultValue;
}

private void validate(org.apache.rocketmq.client.annotation.ExtConsumerResetConfiguration annotation,
GenericApplicationContext genericApplicationContext) {
if (genericApplicationContext.isBeanNameInUse(annotation.value())) {
throw new BeanDefinitionValidationException(
String.format("Bean %s has been used in Spring Application Context, " +
"please check the @ExtRocketMQConsumerConfiguration",
annotation.value()));
}
}

static class SimpleConsumerInfo {
String consumerGroup;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@
import org.springframework.aop.scope.ScopedProxyUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.beans.factory.support.BeanDefinitionValidationException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.util.StringUtils;

Expand Down Expand Up @@ -87,8 +85,6 @@ private void registerTemplate(String beanName, Object bean) {
}

ExtProducerResetConfiguration annotation = clazz.getAnnotation(ExtProducerResetConfiguration.class);
GenericApplicationContext genericApplicationContext = (GenericApplicationContext) applicationContext;
validate(annotation, genericApplicationContext);

ProducerBuilder producerBuilder = createProducer(annotation);
RocketMQClientTemplate rocketMQTemplate = (RocketMQClientTemplate) bean;
Expand Down Expand Up @@ -124,13 +120,4 @@ private ProducerBuilder createProducer(ExtProducerResetConfiguration annotation)
return producerBuilder;
}

private void validate(ExtProducerResetConfiguration annotation,
GenericApplicationContext genericApplicationContext) {
if (genericApplicationContext.isBeanNameInUse(annotation.value())) {
throw new BeanDefinitionValidationException(String.format("Bean %s has been used in Spring Application Context, " +
"please check the @ExtTemplateConfiguration",
annotation.value()));
}
}

}