List of usage examples for org.springframework.beans.factory ListableBeanFactory getBeansOfType
<T> Map<String, T> getBeansOfType(@Nullable Class<T> type, boolean includeNonSingletons, boolean allowEagerInit) throws BeansException;
From source file:com.mtgi.analytics.servlet.BehaviorTrackingListener.java
private static void addRequestAdapters(Collection<ServletRequestBehaviorTrackingAdapter> accum, ListableBeanFactory beanFactory, boolean hasFilter) { @SuppressWarnings("unchecked") Collection<ServletRequestBehaviorTrackingAdapter> beans = beanFactory .getBeansOfType(ServletRequestBehaviorTrackingAdapter.class, false, false).values(); if (!beans.isEmpty()) { if (hasFilter) throw new IllegalStateException( "You have configured both BehaviorTrackingFilters and BehaviorTrackingListeners in the same web application. Only one of these methods may be used in a single application."); accum.addAll(beans);// w ww . j ava 2 s . c o m } }
From source file:org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.java
private PropertySourcesPlaceholderConfigurer getSinglePropertySourcesPlaceholderConfigurer() { // Take care not to cause early instantiation of all FactoryBeans if (this.beanFactory instanceof ListableBeanFactory) { ListableBeanFactory listableBeanFactory = (ListableBeanFactory) this.beanFactory; Map<String, PropertySourcesPlaceholderConfigurer> beans = listableBeanFactory .getBeansOfType(PropertySourcesPlaceholderConfigurer.class, false, false); if (beans.size() == 1) { return beans.values().iterator().next(); }//from w w w. j av a 2 s. co m if (beans.size() > 1 && logger.isWarnEnabled()) { logger.warn("Multiple PropertySourcesPlaceholderConfigurer " + "beans registered " + beans.keySet() + ", falling back to Environment"); } } return null; }