本文整理匯總了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;
}