use of org.springframework.beans.factory.HierarchicalBeanFactory in project spring-security by spring-projects.
the class UserDetailsServiceFactoryBean method getBeansOfType.
private Map<String, ?> getBeansOfType(Class<?> type) {
Map<String, ?> beans = beanFactory.getBeansOfType(type);
// Check ancestor bean factories if they exist and the current one has none of the
// required type
BeanFactory parent = beanFactory.getParentBeanFactory();
while (parent != null && beans.size() == 0) {
if (parent instanceof ListableBeanFactory) {
beans = ((ListableBeanFactory) parent).getBeansOfType(type);
}
if (parent instanceof HierarchicalBeanFactory) {
parent = ((HierarchicalBeanFactory) parent).getParentBeanFactory();
} else {
break;
}
}
return beans;
}
use of org.springframework.beans.factory.HierarchicalBeanFactory in project grails-core by grails.
the class ClosureClassIgnoringComponentScanBeanDefinitionParser method createScanner.
@Override
protected ClassPathBeanDefinitionScanner createScanner(XmlReaderContext readerContext, boolean useDefaultFilters) {
final ClassPathBeanDefinitionScanner scanner = super.createScanner(readerContext, useDefaultFilters);
BeanDefinitionRegistry beanDefinitionRegistry = readerContext.getRegistry();
GrailsPluginManager pluginManager = null;
if (beanDefinitionRegistry instanceof HierarchicalBeanFactory) {
HierarchicalBeanFactory beanFactory = (HierarchicalBeanFactory) beanDefinitionRegistry;
BeanFactory parent = beanFactory.getParentBeanFactory();
if (parent != null && parent.containsBean(GrailsPluginManager.BEAN_NAME)) {
pluginManager = parent.getBean(GrailsPluginManager.BEAN_NAME, GrailsPluginManager.class);
}
}
if (pluginManager != null) {
List<TypeFilter> typeFilters = pluginManager.getTypeFilters();
for (TypeFilter typeFilter : typeFilters) {
scanner.addIncludeFilter(typeFilter);
}
}
return scanner;
}
Aggregations