org.springframework.beans.factory.config.BeanDefinition.getOriginatingBeanDefinition()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(64)

本文整理了Java中org.springframework.beans.factory.config.BeanDefinition.getOriginatingBeanDefinition()方法的一些代码示例,展示了BeanDefinition.getOriginatingBeanDefinition()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BeanDefinition.getOriginatingBeanDefinition()方法的具体详情如下:
包路径:org.springframework.beans.factory.config.BeanDefinition
类名称:BeanDefinition
方法名:getOriginatingBeanDefinition

BeanDefinition.getOriginatingBeanDefinition介绍

[英]Return the originating BeanDefinition, or null if none. Allows for retrieving the decorated bean definition, if any.

Note that this method returns the immediate originator. Iterate through the originator chain to find the original BeanDefinition as defined by the user.
[中]返回原始BeanDefinition,如果没有,则返回null。允许检索修饰的bean定义(如果有)。
请注意,此方法返回直接发起人。遍历发起者链以查找用户定义的原始BeanDefinition。

代码示例

代码示例来源:origin: spring-projects/spring-framework

/**
 * Apply the given property value to the corresponding bean.
 */
protected void applyPropertyValue(
    ConfigurableListableBeanFactory factory, String beanName, String property, String value) {
  BeanDefinition bd = factory.getBeanDefinition(beanName);
  BeanDefinition bdToUse = bd;
  while (bd != null) {
    bdToUse = bd;
    bd = bd.getOriginatingBeanDefinition();
  }
  PropertyValue pv = new PropertyValue(property, value);
  pv.setOptional(this.ignoreInvalidKeys);
  bdToUse.getPropertyValues().addPropertyValue(pv);
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Check the given candidate's bean name, determining whether the corresponding
 * bean definition needs to be registered or conflicts with an existing definition.
 * @param beanName the suggested name for the bean
 * @param beanDefinition the corresponding bean definition
 * @return {@code true} if the bean can be registered as-is;
 * {@code false} if it should be skipped because there is an
 * existing, compatible bean definition for the specified name
 * @throws ConflictingBeanDefinitionException if an existing, incompatible
 * bean definition has been found for the specified name
 */
protected boolean checkCandidate(String beanName, BeanDefinition beanDefinition) throws IllegalStateException {
  if (!this.registry.containsBeanDefinition(beanName)) {
    return true;
  }
  BeanDefinition existingDef = this.registry.getBeanDefinition(beanName);
  BeanDefinition originatingDef = existingDef.getOriginatingBeanDefinition();
  if (originatingDef != null) {
    existingDef = originatingDef;
  }
  if (isCompatible(beanDefinition, existingDef)) {
    return false;
  }
  throw new ConflictingBeanDefinitionException("Annotation-specified bean name '" + beanName +
      "' for bean class [" + beanDefinition.getBeanClassName() + "] conflicts with existing, " +
      "non-compatible bean definition of same name and class [" + existingDef.getBeanClassName() + "]");
}

代码示例来源:origin: org.springframework/spring-beans

/**
 * Apply the given property value to the corresponding bean.
 */
protected void applyPropertyValue(
    ConfigurableListableBeanFactory factory, String beanName, String property, String value) {
  BeanDefinition bd = factory.getBeanDefinition(beanName);
  BeanDefinition bdToUse = bd;
  while (bd != null) {
    bdToUse = bd;
    bd = bd.getOriginatingBeanDefinition();
  }
  PropertyValue pv = new PropertyValue(property, value);
  pv.setOptional(this.ignoreInvalidKeys);
  bdToUse.getPropertyValues().addPropertyValue(pv);
}

代码示例来源:origin: org.springframework/spring-context

/**
 * Check the given candidate's bean name, determining whether the corresponding
 * bean definition needs to be registered or conflicts with an existing definition.
 * @param beanName the suggested name for the bean
 * @param beanDefinition the corresponding bean definition
 * @return {@code true} if the bean can be registered as-is;
 * {@code false} if it should be skipped because there is an
 * existing, compatible bean definition for the specified name
 * @throws ConflictingBeanDefinitionException if an existing, incompatible
 * bean definition has been found for the specified name
 */
protected boolean checkCandidate(String beanName, BeanDefinition beanDefinition) throws IllegalStateException {
  if (!this.registry.containsBeanDefinition(beanName)) {
    return true;
  }
  BeanDefinition existingDef = this.registry.getBeanDefinition(beanName);
  BeanDefinition originatingDef = existingDef.getOriginatingBeanDefinition();
  if (originatingDef != null) {
    existingDef = originatingDef;
  }
  if (isCompatible(beanDefinition, existingDef)) {
    return false;
  }
  throw new ConflictingBeanDefinitionException("Annotation-specified bean name '" + beanName +
      "' for bean class [" + beanDefinition.getBeanClassName() + "] conflicts with existing, " +
      "non-compatible bean definition of same name and class [" + existingDef.getBeanClassName() + "]");
}

代码示例来源:origin: spring-projects/spring-framework

BeanDefinition bdCand = holder.getBeanDefinition().getOriginatingBeanDefinition();
if (bdCand == null) {
  bdCand = holder.getBeanDefinition();

代码示例来源:origin: org.springframework/spring-context

BeanDefinition bdCand = holder.getBeanDefinition().getOriginatingBeanDefinition();
if (bdCand == null) {
  bdCand = holder.getBeanDefinition();

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Apply the given property value to the corresponding bean.
 */
protected void applyPropertyValue(
    ConfigurableListableBeanFactory factory, String beanName, String property, String value) {
  BeanDefinition bd = factory.getBeanDefinition(beanName);
  while (bd.getOriginatingBeanDefinition() != null) {
    bd = bd.getOriginatingBeanDefinition();
  }
  PropertyValue pv = new PropertyValue(property, value);
  pv.setOptional(this.ignoreInvalidKeys);
  bd.getPropertyValues().addPropertyValue(pv);
}

代码示例来源:origin: org.tinygroup/org.tinygroup.springmerge

public BeanDefinition getOriginatingBeanDefinition() {
  // TO DO 暂时不替换
  return currentBeanDefinition.getOriginatingBeanDefinition();
}

代码示例来源:origin: org.pustefixframework/pustefix-core

private BeanDefinition getOriginatingBeanDefinition(BeanDefinition beanDef) {
  
  BeanDefinition originBeanDef = beanDef.getOriginatingBeanDefinition();
  if(originBeanDef != null) {
    return getOriginatingBeanDefinition(originBeanDef);
  } else {
    return beanDef;
  }
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Apply the given property value to the corresponding bean.
 */
protected void applyPropertyValue(
    ConfigurableListableBeanFactory factory, String beanName, String property, String value) {
  BeanDefinition bd = factory.getBeanDefinition(beanName);
  while (bd.getOriginatingBeanDefinition() != null) {
    bd = bd.getOriginatingBeanDefinition();
  }
  PropertyValue pv = new PropertyValue(property, value);
  pv.setOptional(this.ignoreInvalidKeys);
  bd.getPropertyValues().addPropertyValue(pv);
}

代码示例来源:origin: org.carewebframework/org.carewebframework.api.core

/**
   * Searches this bean definition and all originating bean definitions until it finds the
   * requested attribute.
   *
   * @param beanDefinition Bean definition.
   * @param attributeName Attribute to locate.
   * @return The value of the attribute, or null if not found.
   */
  private String getAttribute(BeanDefinition beanDefinition, String attributeName) {
    String value = null;
    
    while (beanDefinition != null) {
      value = (String) beanDefinition.getAttribute(attributeName);
      
      if (value != null) {
        break;
      }
      
      beanDefinition = beanDefinition.getOriginatingBeanDefinition();
    }
    
    return value;
  }
}

代码示例来源:origin: org.carewebframework/org.carewebframework.api

/**
   * Searches this bean definition and all originating bean definitions until it finds the
   * requested attribute.
   * 
   * @param beanDefinition Bean definition.
   * @param attributeName Attribute to locate.
   * @return The value of the attribute, or null if not found.
   */
  private String getAttribute(BeanDefinition beanDefinition, String attributeName) {
    String value = null;
    
    while (beanDefinition != null) {
      value = (String) beanDefinition.getAttribute(attributeName);
      
      if (value != null) {
        break;
      }
      
      beanDefinition = beanDefinition.getOriginatingBeanDefinition();
    }
    
    return value;
  }
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Check the given candidate's bean name, determining whether the corresponding
 * bean definition needs to be registered or conflicts with an existing definition.
 * @param beanName the suggested name for the bean
 * @param beanDefinition the corresponding bean definition
 * @return {@code true} if the bean can be registered as-is;
 * {@code false} if it should be skipped because there is an
 * existing, compatible bean definition for the specified name
 * @throws ConflictingBeanDefinitionException if an existing, incompatible
 * bean definition has been found for the specified name
 */
protected boolean checkCandidate(String beanName, BeanDefinition beanDefinition) throws IllegalStateException {
  if (!this.registry.containsBeanDefinition(beanName)) {
    return true;
  }
  BeanDefinition existingDef = this.registry.getBeanDefinition(beanName);
  BeanDefinition originatingDef = existingDef.getOriginatingBeanDefinition();
  if (originatingDef != null) {
    existingDef = originatingDef;
  }
  if (isCompatible(beanDefinition, existingDef)) {
    return false;
  }
  throw new ConflictingBeanDefinitionException("Annotation-specified bean name '" + beanName +
      "' for bean class [" + beanDefinition.getBeanClassName() + "] conflicts with existing, " +
      "non-compatible bean definition of same name and class [" + existingDef.getBeanClassName() + "]");
}

代码示例来源:origin: apache/servicemix-bundles

BeanDefinition bdCand = holder.getBeanDefinition().getOriginatingBeanDefinition();
if (bdCand == null) {
  bdCand = holder.getBeanDefinition();

相关文章

微信公众号

最新文章

更多