List of usage examples for org.springframework.context ApplicationContext getBeansOfType
<T> Map<String, T> getBeansOfType(@Nullable Class<T> type) throws BeansException;
From source file:org.bpmscript.process.spring.ApplicationContextDefinitionConfigurationLookup.java
/** * @see org.bpmscript.process.IProperties#getProperty(java.lang.String, java.lang.String) *///from w w w . j a v a2 s .c o m @SuppressWarnings("unchecked") public IDefinitionConfiguration getDefinitionConfiguration(String definitionName) { if (context != null) { HashMap<String, IDefinitionConfiguration> beansOfType = new HashMap<String, IDefinitionConfiguration>(); ApplicationContext temp = context; while (temp != null) { beansOfType.putAll(temp.getBeansOfType(IDefinitionConfiguration.class)); temp = temp.getParent(); } Object result = beansOfType.get(prefix + definitionName); if (result != null) { return (IDefinitionConfiguration) result; } } return new DefinitionConfiguration(); }
From source file:org.apache.karaf.webconsole.cxf.internal.DefaultBusFinder.java
private Collection<Bus> findSpringBus(ServiceReference reference) { ApplicationContext appContext = (ApplicationContext) context.getService(reference); Map<String, Bus> contextBuses = appContext.getBeansOfType(Bus.class); context.ungetService(reference);//from www . ja va 2s .c om return contextBuses.values(); }
From source file:com.github.djabry.platform.service.DomainServiceRegistration.java
@Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { DomainServices dSP = DomainServices.getInstance(); Map<String, DomainService> beans = applicationContext.getBeansOfType(DomainService.class); Iterator<Map.Entry<String, DomainService>> iterator = beans.entrySet().iterator(); while (iterator.hasNext()) { dSP.registerDomainService(iterator.next().getValue()); }/*ww w. jav a 2 s .c o m*/ }
From source file:net.cpollet.jixture.support.BaseDatabaseTestSupport.java
@Override public DatabaseTestSupport addFixtures(String... contexts) { for (String context : contexts) { ApplicationContext springContext = new ClassPathXmlApplicationContext(context); addFixtures(springContext.getBeansOfType(Fixture.class).values()); }// www . jav a 2 s. c o m return this; }
From source file:org.vaadin.spring.stuff.i18n.CompositeMessageSource.java
/** * Creates a new {@code CompositeMessageSource}. * * @param applicationContext the application context to use when looking up {@link org.vaadin.spring.stuff.i18n.MessageProvider}s, must not be {@code null}. *//*from w w w .j a va2 s . c om*/ public CompositeMessageSource(ApplicationContext applicationContext) { LOGGER.info("Looking up MessageProviders"); messageProviders = applicationContext.getBeansOfType(MessageProvider.class).values(); if (LOGGER.isDebugEnabled()) { for (MessageProvider messageProvider : messageProviders) { LOGGER.debug("Found MessageProvider [{}]", messageProvider); } } LOGGER.info("Found {} MessageProvider(s)", messageProviders.size()); }
From source file:it.pronetics.madstore.crawler.impl.grid.support.MadStoreGridListener.java
public void contextInitialized(ServletContextEvent event) { if (MadStoreConfigurationManager.getInstance().getMadStoreConfiguration().isGridModeEnabled()) { ApplicationContext context = WebApplicationContextUtils .getWebApplicationContext(event.getServletContext()); Collection beans = context.getBeansOfType(MadStoreGrid.class).values(); try {/* ww w.jav a 2s. c o m*/ if (beans.size() == 1) { madstoreGrid = (MadStoreGrid) beans.iterator().next(); madstoreGrid.startGrid(); } else if (beans.size() == 0) { throw new IllegalStateException("No grid factory found in Spring application context!"); } else { throw new IllegalStateException( "More than one grid factory found in Spring application context!"); } } catch (GridException ex) { throw new RuntimeException("Error during grid startup", ex); } } }
From source file:it.pronetics.madstore.common.configuration.spring.MadStoreConfigurationManager.java
private void loadMadStoreConfigurationFromFilesystem() { String contextPath = "file:" + madStoreHome + SEPARATOR + "conf" + SEPARATOR + MADSTORE_CONFIGURATION_NAME; try {//from w ww.ja v a 2s. c o m ApplicationContext context = new FileSystemXmlApplicationContext(contextPath); Map configurations = context.getBeansOfType(MadStoreConfigurationBean.class); if (configurations.size() != 1) { LOG.warn("Error loading MadStore configuration from path: {}", contextPath); madStoreConfiguration = null; } else { LOG.info("MadStore configuration successfully loaded from path: {}", contextPath); madStoreConfiguration = (MadStoreConfigurationBean) configurations.values().iterator().next(); } } catch (Exception ex) { LOG.warn(ex.getMessage(), ex); LOG.warn("Error loading MadStore configuration from path: {}", contextPath); throw new MadStoreConfigurationException(ex.getMessage(), ex); } }
From source file:it.pronetics.madstore.common.configuration.spring.MadStoreConfigurationManager.java
private void loadMadStoreConfigurationFromClasspathIfNotFound() { String contextPath = "classpath:" + MADSTORE_CONFIGURATION_NAME; try {/*from w w w . j a va 2s .c o m*/ if (madStoreConfiguration == null) { ApplicationContext context = new ClassPathXmlApplicationContext(contextPath); Map configurations = context.getBeansOfType(MadStoreConfigurationBean.class); if (configurations.size() != 1) { LOG.warn("Error loading MadStore configuration from path: {}", contextPath); madStoreConfiguration = null; } else { LOG.info("MadStore configuration successfully loaded from path: {}", contextPath); madStoreConfiguration = (MadStoreConfigurationBean) configurations.values().iterator().next(); } } } catch (Exception ex) { LOG.warn(ex.getMessage(), ex); LOG.warn("Error loading MadStore configuration from path: {}", contextPath); } }
From source file:org.vaadin.spring.i18n.CompositeMessageSource.java
/** * Creates a new {@code CompositeMessageSource}. * * @param applicationContext the application context to use when looking up * {@link org.vaadin.spring.i18n.MessageProvider}s, must not be {@code null}. *//* w w w .j a v a2s. c om*/ public CompositeMessageSource(ApplicationContext applicationContext) { LOGGER.info("Looking up MessageProviders"); messageProviders = applicationContext.getBeansOfType(MessageProvider.class).values(); if (LOGGER.isDebugEnabled()) { for (MessageProvider messageProvider : messageProviders) { LOGGER.debug("Found MessageProvider [{}]", messageProvider); } } LOGGER.info("Found {} MessageProvider(s)", messageProviders.size()); setMessageFormatCacheEnabled(applicationContext.getEnvironment() .getProperty(ENV_PROP_MESSAGE_FORMAT_CACHE_ENABLED, Boolean.class, true)); }