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

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

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

BeanDefinition.getRole介绍

[英]Get the role hint for this BeanDefinition. The role hint provides the frameworks as well as tools with an indication of the role and importance of a particular BeanDefinition.
[中]获取此BeanDefinition的角色提示。角色提示为框架和工具提供了特定BeanDefinition的角色和重要性指示。

代码示例

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

@Override
protected boolean isEligibleAdvisorBean(String beanName) {
  return (this.beanFactory != null && this.beanFactory.containsBeanDefinition(beanName) &&
      this.beanFactory.getBeanDefinition(beanName).getRole() == BeanDefinition.ROLE_INFRASTRUCTURE);
}

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

private boolean isInfrastructureBean(@Nullable String beanName) {
    if (beanName != null && this.beanFactory.containsBeanDefinition(beanName)) {
      BeanDefinition bd = this.beanFactory.getBeanDefinition(beanName);
      return (bd.getRole() == RootBeanDefinition.ROLE_INFRASTRUCTURE);
    }
    return false;
  }
}

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

private boolean isInfrastructureBean(@Nullable String beanName) {
    if (beanName != null && this.beanFactory.containsBeanDefinition(beanName)) {
      BeanDefinition bd = this.beanFactory.getBeanDefinition(beanName);
      return (bd.getRole() == RootBeanDefinition.ROLE_INFRASTRUCTURE);
    }
    return false;
  }
}

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

/**
 * Determine whether the specified bean is eligible for inclusion in the
 * LiveBeansView JSON snapshot.
 * @param beanName the name of the bean
 * @param bd the corresponding bean definition
 * @param bf the containing bean factory
 * @return {@code true} if the bean is to be included; {@code false} otherwise
 */
protected boolean isBeanEligible(String beanName, BeanDefinition bd, ConfigurableBeanFactory bf) {
  return (bd.getRole() != BeanDefinition.ROLE_INFRASTRUCTURE &&
      (!bd.isLazyInit() || bf.containsSingleton(beanName)));
}

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

/**
 * Determine whether the specified bean is eligible for inclusion in the
 * LiveBeansView JSON snapshot.
 * @param beanName the name of the bean
 * @param bd the corresponding bean definition
 * @param bf the containing bean factory
 * @return {@code true} if the bean is to be included; {@code false} otherwise
 */
protected boolean isBeanEligible(String beanName, BeanDefinition bd, ConfigurableBeanFactory bf) {
  return (bd.getRole() != BeanDefinition.ROLE_INFRASTRUCTURE &&
      (!bd.isLazyInit() || bf.containsSingleton(beanName)));
}

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

throw new BeanDefinitionOverrideException(beanName, beanDefinition, existingDefinition);
else if (existingDefinition.getRole() < beanDefinition.getRole()) {

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

throw new BeanDefinitionOverrideException(beanName, beanDefinition, existingDefinition);
else if (existingDefinition.getRole() < beanDefinition.getRole()) {

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

if (existingBeanDef.getRole() > BeanDefinition.ROLE_APPLICATION) {
  return false;

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

@Test
public void onBeanMethod() {
  AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
  ctx.register(Config.class);
  ctx.refresh();
  assertThat("Expected bean to have ROLE_APPLICATION",
      ctx.getBeanDefinition("foo").getRole(), is(BeanDefinition.ROLE_APPLICATION));
  assertThat(ctx.getBeanDefinition("foo").getDescription(), is((Object) null));
  assertThat("Expected bean to have ROLE_INFRASTRUCTURE",
      ctx.getBeanDefinition("bar").getRole(), is(BeanDefinition.ROLE_INFRASTRUCTURE));
  assertThat(ctx.getBeanDefinition("bar").getDescription(), is("A Bean method with a role"));
}

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

@Test
public void onComponentClass() {
  AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
  ctx.register(ComponentWithoutRole.class, ComponentWithRole.class);
  ctx.refresh();
  assertThat("Expected bean to have ROLE_APPLICATION",
      ctx.getBeanDefinition("componentWithoutRole").getRole(), is(BeanDefinition.ROLE_APPLICATION));
  assertThat(ctx.getBeanDefinition("componentWithoutRole").getDescription(), is((Object) null));
  assertThat("Expected bean to have ROLE_INFRASTRUCTURE",
      ctx.getBeanDefinition("componentWithRole").getRole(), is(BeanDefinition.ROLE_INFRASTRUCTURE));
  assertThat(ctx.getBeanDefinition("componentWithRole").getDescription(), is("A Component with a role"));
}

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

@Test
public void viaComponentScanning() {
  AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
  ctx.scan("org.springframework.context.annotation.role");
  ctx.refresh();
  assertThat("Expected bean to have ROLE_APPLICATION",
      ctx.getBeanDefinition("componentWithoutRole").getRole(), is(BeanDefinition.ROLE_APPLICATION));
  assertThat(ctx.getBeanDefinition("componentWithoutRole").getDescription(), is((Object) null));
  assertThat("Expected bean to have ROLE_INFRASTRUCTURE",
      ctx.getBeanDefinition("componentWithRole").getRole(), is(BeanDefinition.ROLE_INFRASTRUCTURE));
  assertThat(ctx.getBeanDefinition("componentWithRole").getDescription(), is("A Component with a role"));
}

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

if (existingBeanDef.getRole() > BeanDefinition.ROLE_APPLICATION) {
  return false;

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

proxyDefinition.setOriginatingBeanDefinition(targetDefinition);
proxyDefinition.setSource(definition.getSource());
proxyDefinition.setRole(targetDefinition.getRole());

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

setFactoryMethodName(other.getFactoryMethodName());
setRole(other.getRole());
setSource(other.getSource());
copyAttributesFrom(other);

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

setFactoryMethodName(other.getFactoryMethodName());
setRole(other.getRole());
setSource(other.getSource());
copyAttributesFrom(other);

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

setFactoryBeanName(original.getFactoryBeanName());
setFactoryMethodName(original.getFactoryMethodName());
setRole(original.getRole());
setSource(original.getSource());
copyAttributesFrom(original);

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

private static boolean isBeanEligible(String beanName, BeanDefinition bd,
    ConfigurableBeanFactory bf) {
  return (bd.getRole() != BeanDefinition.ROLE_INFRASTRUCTURE
      && (!bd.isLazyInit() || bf.containsSingleton(beanName)));
}

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

setFactoryBeanName(original.getFactoryBeanName());
setFactoryMethodName(original.getFactoryMethodName());
setRole(original.getRole());
setSource(original.getSource());
copyAttributesFrom(original);

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

setRole(other.getRole());
getConstructorArgumentValues().addArgumentValues(other.getConstructorArgumentValues());
getPropertyValues().addPropertyValues(other.getPropertyValues());

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

setAbstract(original.isAbstract());
setLazyInit(original.isLazyInit());
setRole(original.getRole());
setConstructorArgumentValues(new ConstructorArgumentValues(original.getConstructorArgumentValues()));
setPropertyValues(new MutablePropertyValues(original.getPropertyValues()));

相关文章

微信公众号

最新文章

更多