List of usage examples for org.springframework.beans.factory.config BeanDefinition setRole
void setRole(int role);
From source file:org.springframework.boot.autoconfigure.AutoConfigurationPackages.java
/** * Programmatically registers the auto-configuration package names. Subsequent * invocations will add the given package names to those that have already been * registered. You can use this method to manually define the base packages that will * be used for a given {@link BeanDefinitionRegistry}. Generally it's recommended that * you don't call this method directly, but instead rely on the default convention * where the package name is set from your {@code @EnableAutoConfiguration} * configuration class or classes./* www .ja v a 2 s .c om*/ * @param registry the bean definition registry * @param packageNames the package names to set */ public static void register(BeanDefinitionRegistry registry, String... packageNames) { if (registry.containsBeanDefinition(BEAN)) { BeanDefinition beanDefinition = registry.getBeanDefinition(BEAN); ConstructorArgumentValues constructorArguments = beanDefinition.getConstructorArgumentValues(); constructorArguments.addIndexedArgumentValue(0, addBasePackages(constructorArguments, packageNames)); } else { GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(BasePackages.class); beanDefinition.getConstructorArgumentValues().addIndexedArgumentValue(0, packageNames); beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); registry.registerBeanDefinition(BEAN, beanDefinition); } }