本文整理汇总了Java中org.springframework.beans.factory.support.BeanDefinitionRegistry.getBeanDefinitionNames方法的典型用法代码示例。如果您正苦于以下问题:Java BeanDefinitionRegistry.getBeanDefinitionNames方法的具体用法?Java BeanDefinitionRegistry.getBeanDefinitionNames怎么用?Java BeanDefinitionRegistry.getBeanDefinitionNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.beans.factory.support.BeanDefinitionRegistry
的用法示例。
在下文中一共展示了BeanDefinitionRegistry.getBeanDefinitionNames方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateServiceReferences
import org.springframework.beans.factory.support.BeanDefinitionRegistry; //导入方法依赖的package包/类
protected void validateServiceReferences(Element element, String serviceId, ParserContext parserContext) {
BeanDefinitionRegistry registry = parserContext.getRegistry();
String[] names = registry.getBeanDefinitionNames();
for (String name : names) {
BeanDefinition definition = registry.getBeanDefinition(name);
Collection<String> exporters =
(Collection<String>) definition.getAttribute(ParserUtils.REFERENCE_LISTENER_REF_ATTR);
if (exporters != null && exporters.contains(serviceId)) {
parserContext.getReaderContext()
.error(
"Service exporter '" + serviceId + "' cannot be used as a reference listener by '"
+ name + "'", element);
}
}
}
示例2: registerBeanDefinitionIfNotExists
import org.springframework.beans.factory.support.BeanDefinitionRegistry; //导入方法依赖的package包/类
public static boolean registerBeanDefinitionIfNotExists(BeanDefinitionRegistry registry, String beanName,
Class<?> beanClass) {
if (registry.containsBeanDefinition(beanName)) {
return false;
}
String[] candidates = registry.getBeanDefinitionNames();
for (String candidate : candidates) {
BeanDefinition beanDefinition = registry.getBeanDefinition(candidate);
if (Objects.equals(beanDefinition.getBeanClassName(), beanClass.getName())) {
return false;
}
}
BeanDefinition annotationProcessor = BeanDefinitionBuilder.genericBeanDefinition(beanClass).getBeanDefinition();
registry.registerBeanDefinition(beanName, annotationProcessor);
return true;
}
示例3: registerFactoryMethodForConfigBeans
import org.springframework.beans.factory.support.BeanDefinitionRegistry; //导入方法依赖的package包/类
/**
* 为@ConfigBean的bean注册它的Factory Method,通过静态Factory Method来创建@ConfigBean实例
*
* @param registry
*/
private void registerFactoryMethodForConfigBeans(BeanDefinitionRegistry registry) {
for (String beanName : registry.getBeanDefinitionNames()) {
BeanDefinition beanDefinition = registry.getBeanDefinition(beanName);
registerFactoryMethodForConfigBean(registry, beanName, beanDefinition);
}
}
示例4: getRefreshScopeBeans
import org.springframework.beans.factory.support.BeanDefinitionRegistry; //导入方法依赖的package包/类
/**
* 获取所有可刷新的beans
*
* @param registry
*/
private List<String> getRefreshScopeBeans(BeanDefinitionRegistry registry) {
List<String> beanNames = new ArrayList<>();
for (String beanName : registry.getBeanDefinitionNames()) {
BeanDefinition beanDefinition = registry.getBeanDefinition(beanName);
if (VersionRefreshScope.SCOPE_NAME.equalsIgnoreCase(beanDefinition.getScope())) {
beanNames.add(beanName);
}
}
return beanNames;
}