List of usage examples for org.springframework.beans.factory BeanFactoryUtils beansOfTypeIncludingAncestors
public static <T> Map<String, T> beansOfTypeIncludingAncestors(ListableBeanFactory lbf, Class<T> type) throws BeansException
From source file:org.apache.zeppelin.lens.LensJLineShellComponent.java
@SuppressWarnings("rawtypes") public void afterPropertiesSet() { Map<String, CommandMarker> commands = BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, CommandMarker.class); for (CommandMarker command : commands.values()) { getSimpleParser().add(command);/*from ww w . ja v a 2s . c om*/ } Map<String, Converter> converters = BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, Converter.class); for (Converter<?> converter : converters.values()) { getSimpleParser().add(converter); } setHistorySize(commandLine.getHistorySize()); if (commandLine.getShellCommandsToExecute() != null) { setPrintBanner(false); } }
From source file:com.expressui.core.util.SpringApplicationContext.java
/** * Finds all beans of a given type in the application context. * * @param type type to search for// w w w. j av a2 s . c om * @param <T> type to query * @return set of all beans of a given type */ public static <T> Set<T> getBeansByType(Class<T> type) { Map beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, type); return new HashSet(beans.values()); }
From source file:com.acc.xstream.XmlXStreamMarshallerFactory.java
protected XStreamMarshaller getObjectInternal() throws Exception { final XStreamMarshaller marshaller = createMarshaller(); //we use here BeanFactoryUtils.beansOfTypeIncludingAncestors lookup for assuring the lookup for the 'beans of type' in the parent spring context succeeds final Map<String, TypeAliasMapping> allTypeAliases = BeanFactoryUtils.beansOfTypeIncludingAncestors(ctx, TypeAliasMapping.class); setAliases(marshaller, allTypeAliases.values()); final Map<String, TypeConverterMapping> allTypeConverter = BeanFactoryUtils .beansOfTypeIncludingAncestors(ctx, TypeConverterMapping.class); setConverters(marshaller, allTypeConverter.values()); final Map<String, AttributeOmitMapping> allOmitersConverter = BeanFactoryUtils .beansOfTypeIncludingAncestors(ctx, AttributeOmitMapping.class); setOmitted(marshaller, allOmitersConverter.values()); return marshaller; }
From source file:org.motechproject.server.demo.Activator.java
private void serviceAdded(HttpService service) { try {/*from w w w. j ava 2 s . c om*/ DispatcherServlet dispatcherServlet = new DispatcherServlet(); dispatcherServlet.setContextConfigLocation(CONTEXT_CONFIG_LOCATION); ClassLoader old = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); service.registerServlet(SERVLET_URL_MAPPING, dispatcherServlet, null, null); logger.debug("Servlet registered"); } finally { Thread.currentThread().setContextClassLoader(old); } // register all annotated handlers EventAnnotationBeanPostProcessor.registerHandlers(BeanFactoryUtils .beansOfTypeIncludingAncestors(dispatcherServlet.getWebApplicationContext(), Object.class)); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:org.synyx.hades.extensions.converter.GenericDaoConverter.java
@SuppressWarnings("unchecked") public void setApplicationContext(ApplicationContext context) { @SuppressWarnings("rawtypes") Collection<GenericDao> daos = BeanFactoryUtils.beansOfTypeIncludingAncestors(context, GenericDao.class) .values();/*from w ww . j a v a 2 s .c o m*/ this.daoMap = new HashMap<Class<?>, GenericDao<?, Serializable>>(daos.size()); for (GenericDao<?, ?> dao : daos) { Class<?> domainClass = getDomainClass(dao.getClass()); this.daoMap.put(domainClass, (GenericDao<?, Serializable>) dao); } }
From source file:org.motechproject.server.outbox.Activator.java
private void serviceAdded(HttpService service) { try {// w ww .ja v a2 s.com DispatcherServlet dispatcherServlet = new DispatcherServlet(); dispatcherServlet.setContextConfigLocation(CONTEXT_CONFIG_LOCATION); ClassLoader old = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); service.registerServlet(SERVLET_URL_MAPPING, dispatcherServlet, null, null); logger.debug("Servlet registered"); } finally { Thread.currentThread().setContextClassLoader(old); } // register all annotated handlers EventAnnotationBeanPostProcessor.registerHandlers(BeanFactoryUtils .beansOfTypeIncludingAncestors(dispatcherServlet.getWebApplicationContext(), Object.class)); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:org.motechproject.server.voxeo.Activator.java
private void serviceAdded(HttpService service) { try {//from w w w. j av a 2s. com DispatcherServlet dispatcherServlet = new DispatcherServlet(); dispatcherServlet.setContextConfigLocation(CONTEXT_CONFIG_LOCATION); ClassLoader old = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); service.registerServlet(SERVLET_URL_MAPPING, dispatcherServlet, null, null); logger.debug("Servlet registered"); } finally { Thread.currentThread().setContextClassLoader(old); } // register all annotated handlers EventAnnotationBeanPostProcessor.registerHandlers(BeanFactoryUtils .beansOfTypeIncludingAncestors(dispatcherServlet.getWebApplicationContext(), Object.class)); // create tree objects in the database bootStrap(); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:org.motechproject.server.appointments.Activator.java
private void serviceAdded(HttpService service) { try {/*from w w w . j a v a 2s . c om*/ DispatcherServlet dispatcherServlet = new DispatcherServlet(); dispatcherServlet.setContextConfigLocation(CONTEXT_CONFIG_LOCATION); ClassLoader old = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); service.registerServlet(SERVLET_URL_MAPPING, dispatcherServlet, null, null); logger.debug("Servlet registered"); } finally { Thread.currentThread().setContextClassLoader(old); } // register all annotated handlers EventAnnotationBeanPostProcessor.registerHandlers(BeanFactoryUtils .beansOfTypeIncludingAncestors(dispatcherServlet.getWebApplicationContext(), Object.class)); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:com.acc.xstream.XmlXStreamMarshallerFactory.java
protected void configureXmlMarshaller(final XStreamMarshaller marshaller) { final Map<String, ImplicitCollection> allImplicitCollections = BeanFactoryUtils .beansOfTypeIncludingAncestors(ctx, ImplicitCollection.class); setImplicitCollections(marshaller, allImplicitCollections.values()); }
From source file:org.apereo.portal.soffit.connector.SoffitConnectorController.java
@PostConstruct public void init() { PoolingHttpClientConnectionManager poolingHttpClientConnectionManager = new PoolingHttpClientConnectionManager(); poolingHttpClientConnectionManager.setDefaultMaxPerRoute(maxConnectionsPerRoute); poolingHttpClientConnectionManager.setMaxTotal(maxConnectionsTotal); httpClientBuilder.setConnectionManager(poolingHttpClientConnectionManager); final Map<String, IHeaderProvider> beans = BeanFactoryUtils .beansOfTypeIncludingAncestors(applicationContext, IHeaderProvider.class); final List<IHeaderProvider> values = new ArrayList<>(beans.values()); headerProviders = Collections.unmodifiableList(values); }