use of org.springframework.beans.factory.support.BeanDefinitionRegistry in project druid by alibaba.
the class DruidStatBeanDefinitionParser method parse.
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
Object source = parserContext.extractSource(element);
CompositeComponentDefinition compDefinition = new CompositeComponentDefinition(element.getTagName(), source);
parserContext.pushContainingComponent(compDefinition);
BeanDefinitionRegistry registry = parserContext.getRegistry();
if (registry.containsBeanDefinition(STAT_ANNOTATION_PROCESSOR_BEAN_NAME)) {
parserContext.getReaderContext().error("Only one DruidStatBeanDefinitionParser may exist within the context.", source);
} else {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(STAT_ANNOTATION_PROCESSOR_BEAN_CLASS);
builder.getRawBeanDefinition().setSource(source);
registerComponent(parserContext, builder, STAT_ANNOTATION_PROCESSOR_BEAN_NAME);
}
if (!registry.containsBeanDefinition(STAT_ANNOTATION_ADVICE_BEAN_NAME)) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(STAT_ANNOTATION_ADVICE_BEAN_CLASS);
builder.getRawBeanDefinition().setSource(source);
registerComponent(parserContext, builder, STAT_ANNOTATION_ADVICE_BEAN_NAME);
}
parserContext.popAndRegisterContainingComponent();
return null;
}
Aggregations