List of usage examples for org.springframework.beans.factory BeanFactoryUtils beanNamesIncludingAncestors
public static String[] beanNamesIncludingAncestors(ListableBeanFactory lbf)
From source file:org.uimafit.spring.SpringContextResourceManager.java
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override/*from ww w. j a v a 2s . c om*/ public void initializeExternalResources(ResourceManagerConfiguration aConfiguration, String aQualifiedContextName, java.util.Map<String, Object> aAdditionalParams) throws ResourceInitializationException { for (String name : BeanFactoryUtils.beanNamesIncludingAncestors(context)) { Object registration = mInternalResourceRegistrationMap.get(name); if (registration == null) { try { // Register resource // ResourceRegistration unfortunately is package private Object reg = newInstance( "org.apache.uima.resource.impl.ResourceManager_impl$ResourceRegistration", Object.class, context.getBean(name), ExternalResourceDescription.class, null, String.class, aQualifiedContextName); ((Map) mInternalResourceRegistrationMap).put(name, reg); // Perform binding if (isAutowireEnabled()) { mResourceMap.put(aQualifiedContextName + name, context.getBean(name)); } } catch (Exception e1) { throw new ResourceInitializationException(e1); } } else { try { Object desc = getFieldValue(registration, "description"); if (desc != null) { String definingContext = getFieldValue(registration, "definingContext"); if (aQualifiedContextName.startsWith(definingContext)) { UIMAFramework.getLogger().logrb(Level.CONFIG, ResourceManager_impl.class.getName(), "initializeExternalResources", LOG_RESOURCE_BUNDLE, "UIMA_overridden_resource__CONFIG", new Object[] { name, aQualifiedContextName, definingContext }); } else { UIMAFramework.getLogger().logrb(Level.WARNING, ResourceManager_impl.class.getName(), "initializeExternalResources", LOG_RESOURCE_BUNDLE, "UIMA_duplicate_resource_name__WARNING", new Object[] { name, definingContext, aQualifiedContextName }); } } } catch (Exception e1) { throw new ResourceInitializationException(e1); } } } super.initializeExternalResources(aConfiguration, aQualifiedContextName, aAdditionalParams); }
From source file:jetbrains.buildServer.server.rest.jersey.JerseyWebComponent.java
/** * Checks for all beans that have @Provider annotation and * registers them into Jersey ResourceConfig * @param rc config//from ww w .ja va2 s .com * @param springContext spring context */ private void registerResourceProfiders(ResourceConfig rc, ConfigurableApplicationContext springContext) { //TODO: restrict search to current spring context without parent for speedup for (String name : BeanFactoryUtils.beanNamesIncludingAncestors(springContext)) { final Class<?> type = ClassUtils.getUserClass(springContext.getType(name)); if (ResourceConfig.isProviderClass(type)) { LOG.info("Registering Spring bean, " + name + ", of type " + type.getName() + " as a provider class"); rc.getClasses().add(type); } else if (ResourceConfig.isRootResourceClass(type)) { LOG.info("Registering Spring bean, " + name + ", of type " + type.getName() + " as a root resource class"); rc.getClasses().add(type); } } }
From source file:io.neba.core.selftests.SelftestRegistrar.java
public void registerSelftests(ConfigurableListableBeanFactory factory, Bundle bundle) { String[] beanNames = BeanFactoryUtils.beanNamesIncludingAncestors(factory); for (String beanName : beanNames) { if (factory.containsBeanDefinition(beanName) && !isInternal(beanName)) { findSelftests(factory, beanName, bundle); }// w w w . j av a2 s . co m } }
From source file:org.jasig.cas.web.report.InternalConfigStateController.java
/** * Gets beans in the application context. * * @param ctx the ctx// w w w .j a v a 2 s . co m * @return the beans */ private static Map<String, Object> getBeans(final ApplicationContext ctx) { final String[] all = BeanFactoryUtils.beanNamesIncludingAncestors(ctx); final Map<String, Object> singletons = new HashMap<>(all.length); for (final String name : all) { try { final Object object = ctx.getBean(name); if (object != null) { boolean foundPackage = false; final String packageName = object.getClass().getPackage().getName(); for (int i = 0; !foundPackage && i < INCLUDE_PACKAGES.length; i++) { foundPackage = (packageName.startsWith(INCLUDE_PACKAGES[i])); } if (foundPackage) { singletons.put(name, object); } } } catch (final BeanIsAbstractException e) { LOGGER.debug("Skipping abstract bean definition. {}", e.getMessage()); } catch (final Throwable e) { LOGGER.trace(e.getMessage(), e); } } return singletons; }