@Override protected boolean isEligibleAdvisorBean(String beanName) { return (this.beanFactory != null && this.beanFactory.containsBeanDefinition(beanName) && this.beanFactory.getBeanDefinition(beanName).getRole() == BeanDefinition.ROLE_INFRASTRUCTURE); }
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; } }
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; } }
/** * 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))); }
/** * 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))); }
if (existingBeanDef.getRole() > BeanDefinition.ROLE_APPLICATION) { return false;
@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")); }
@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")); }
@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")); }
if (existingBeanDef.getRole() > BeanDefinition.ROLE_APPLICATION) { return false;
proxyDefinition.setOriginatingBeanDefinition(targetDefinition); proxyDefinition.setSource(definition.getSource()); proxyDefinition.setRole(targetDefinition.getRole());
setFactoryMethodName(other.getFactoryMethodName()); setRole(other.getRole()); setSource(other.getSource()); copyAttributesFrom(other);
setFactoryMethodName(other.getFactoryMethodName()); setRole(other.getRole()); setSource(other.getSource()); copyAttributesFrom(other);
setFactoryBeanName(original.getFactoryBeanName()); setFactoryMethodName(original.getFactoryMethodName()); setRole(original.getRole()); setSource(original.getSource()); copyAttributesFrom(original);
private static boolean isBeanEligible(String beanName, BeanDefinition bd, ConfigurableBeanFactory bf) { return (bd.getRole() != BeanDefinition.ROLE_INFRASTRUCTURE && (!bd.isLazyInit() || bf.containsSingleton(beanName))); }
setFactoryBeanName(original.getFactoryBeanName()); setFactoryMethodName(original.getFactoryMethodName()); setRole(original.getRole()); setSource(original.getSource()); copyAttributesFrom(original);
setRole(other.getRole()); getConstructorArgumentValues().addArgumentValues(other.getConstructorArgumentValues()); getPropertyValues().addPropertyValues(other.getPropertyValues());
setAbstract(original.isAbstract()); setLazyInit(original.isLazyInit()); setRole(original.getRole()); setConstructorArgumentValues(new ConstructorArgumentValues(original.getConstructorArgumentValues())); setPropertyValues(new MutablePropertyValues(original.getPropertyValues()));