spring自定义xml标签&自定义注解

时间:2021-06-19 20:36:46
public class YafBeanDefinitionParser implements BeanDefinitionParser {
  
  private BeanDefinitionRegistry beanDefinitionRegistry;
  extensionPointList.stream().forEach(
extensionPoint -> {
GenericBeanDefinition genericBeanDefinition = new GenericBeanDefinition();
genericBeanDefinition.setBeanClass(YafExtensionPointFacotryBean.class);
genericBeanDefinition.setAutowireMode(GenericBeanDefinition.AUTOWIRE_BY_NAME);
genericBeanDefinition.getPropertyValues().add("classType", extensionPoint.getClassMetadata().getClassName());
       //将当前对象设置到Bean中
genericBeanDefinition.getPropertyValues().add("yafMethodAdapter", yafMethodAdapter);
       //将类设置到Bean中
genericBeanDefinition.getPropertyValues().addPropertyValue("yafBeanManager", new RuntimeBeanReference(YafBeanManager.class.getName()));
this.beanDefinitionRegistry.registerBeanDefinition(getBeanName(extensionPoint.getClassMetadata().getClassName()), genericBeanDefinition);
}
  );

}