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.axonframework.migration.eventstore.JpaEventStoreMigrator.java
public JpaEventStoreMigrator(ApplicationContext context) { context.getAutowireCapableBeanFactory().autowireBean(this); txTemplate = new TransactionTemplate(txManager); txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); upcasters = new ArrayList<EventUpcaster>(context.getBeansOfType(EventUpcaster.class).values()); }
From source file:org.metis.MetisServlet.java
/** * This is where we initialize the web application's strategy objects (rdbs, * pools, etc.) This method is called prior to initFrameworkServlet() being * called./*from w ww .j av a 2s. c o m*/ */ @Override protected void initStrategies(ApplicationContext context) { super.initStrategies(context); // Assign the resource bean this container's info WdsResourceBean.serverInfo = getServletContext().getServerInfo(); // get list of all RDBs and PUSHERs for this application context rdbs = context.getBeansOfType(WdsResourceBean.class); pdbs = context.getBeansOfType(PusherBean.class); if (rdbs.isEmpty() && pdbs.isEmpty()) { LOG.error(getServletConfig().getServletName() + ": Neither RDBs nor PUSHERs have been defined for this web application"); return; } Boolean secure = null; String prop = getInitParameter("secure"); if (prop != null) { secure = Boolean.valueOf(prop); LOG.debug(getServletConfig().getServletName() + ": secure = " + secure.booleanValue()); } Boolean authenticated = null; prop = getInitParameter("authenticated"); if (prop != null) { authenticated = Boolean.valueOf(prop); LOG.debug(getServletConfig().getServletName() + ": authenticated = " + authenticated.booleanValue()); } String agentNames = getInitParameter("agentNames"); if (agentNames != null) { LOG.debug(getServletConfig().getServletName() + ": agentNames = " + agentNames); } String cacheControl = getInitParameter("cacheControl"); if (cacheControl != null) { LOG.debug(getServletConfig().getServletName() + ": cacheControl = " + cacheControl); } try { // assign global init properties to the RDBs for (Iterator<WdsResourceBean> it = rdbs.values().iterator(); it.hasNext();) { WdsResourceBean rdb = it.next(); if (rdb.getAuthenticated() == null && authenticated != null) { rdb.setAuthenticated(authenticated.booleanValue()); } if (rdb.getSecure() == null && secure != null) { rdb.setSecure(secure.booleanValue()); } if (rdb.getAgentNames() == null && agentNames != null) { rdb.setAgentNames(agentNames); } if (rdb.getCacheControl() == null && cacheControl != null) { rdb.setCacheControl(cacheControl); } } } catch (Exception e) { LOG.error(getServletConfig().getServletName() + "initStrategies: ERROR, this exception was caught - " + e.getLocalizedMessage()); } }
From source file:eu.eidas.node.utils.CountrySpecificUtil.java
/** * prepares a cache of country handlers found in the classpath *//* w ww .j av a2 s . c o m*/ public void loadCountryHandlers() { synchronized (CountrySpecificUtil.class) { if (!pluginsLoaded) { ApplicationContext ctx = ApplicationContextProvider.getApplicationContext(); Map<String, Boolean> configuredPlugins = getConfiguredPlugins(ctx); for (String iso : configuredPlugins.keySet()) { registeredCountries.put(iso, new InactiveIntegrationPlugin(iso)); } Map specificCountriesMap = ctx.getBeansOfType(CountrySpecificService.class); for (Object o : specificCountriesMap.values()) { CountrySpecificService handler = (CountrySpecificService) o; //plugins present as jar files but not activated through configuration will be ignored if (registeredCountries.containsKey(handler.getIsoCode()) && configuredPlugins.containsKey(handler.getIsoCode()) && configuredPlugins.get(handler.getIsoCode())) { registeredCountries.put(handler.getIsoCode(), handler); } } pluginsLoaded = true; } } }
From source file:org.talend.components.service.rest.ComponentServiceRest.java
@Autowired public ComponentServiceRest(final ApplicationContext context) { ComponentRegistry registry = new ComponentRegistry(); Map<String, ComponentInstaller> installers = context.getBeansOfType(ComponentInstaller.class); for (ComponentInstaller installer : installers.values()) { installer.install(registry);//from ww w. java2s. c o m } registry.lock(); this.componentServiceDelegate = new ComponentServiceImpl(registry); }
From source file:org.talend.components.api.service.internal.spring.ComponentServiceSpring.java
@Autowired public ComponentServiceSpring(final ApplicationContext context) { this.componentServiceDelegate = new ComponentServiceImpl(new ComponentRegistry() { @Override/*w w w. ja va 2 s .com*/ public Map<String, ComponentDefinition> getComponents() { Map<String, ComponentDefinition> compDefs = context.getBeansOfType(ComponentDefinition.class); return compDefs; } @Override public Map<String, ComponentWizardDefinition> getComponentWizards() { Map<String, ComponentWizardDefinition> wizardDefs = context .getBeansOfType(ComponentWizardDefinition.class); return wizardDefs; } }); }
From source file:io.seldon.api.state.ClientAlgorithmStore.java
@Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; StringBuilder builder = new StringBuilder("Available algorithms: \n"); for (ItemRecommendationAlgorithm inc : applicationContext.getBeansOfType(ItemRecommendationAlgorithm.class) .values()) {/*from w w w .ja v a 2s .c o m*/ builder.append('\t'); builder.append(inc.getClass()); builder.append('\n'); } logger.info(builder.toString()); builder = new StringBuilder("Available includers: \n"); for (ItemIncluder inc : applicationContext.getBeansOfType(ItemIncluder.class).values()) { builder.append('\t'); builder.append(inc.getClass()); builder.append('\n'); } logger.info(builder.toString()); builder = new StringBuilder("Available filters: \n"); for (ItemFilter filt : applicationContext.getBeansOfType(ItemFilter.class).values()) { builder.append('\t'); builder.append(filt.getClass()); builder.append('\n'); } logger.info(builder.toString()); for (AlgorithmResultsCombiner filt : applicationContext.getBeansOfType(AlgorithmResultsCombiner.class) .values()) { builder.append('\t'); builder.append(filt.getClass()); builder.append('\n'); } builder = new StringBuilder("Available combiners: \n"); logger.info(builder.toString()); }
From source file:org.apache.shiro.realm.UserRealm.java
@Autowired public UserRealm(ApplicationContext ctx) { super();//w w w. j a va2 s . com //? ?bean??????bean //why //springfindAutowireCandidatesFactoryBean????Bean?autowire //bean?bean???ObjectTypeRepository //getBean ctx.getBeansOfType(SimpleBaseRepositoryFactoryBean.class); }
From source file:org.pentaho.aggdes.ui.UIMain.java
@SuppressWarnings("unchecked") public void start(ApplicationContext context) throws XulException { XulDomContainer container;/*w w w . j a v a 2s . c o m*/ //check to see if they've specified an alternate resource bundle String bundleStr = configuration.getResourceBundle(); ResourceBundle bundle = null; if (bundleStr != null) { try { bundle = ResourceBundle.getBundle(bundleStr); } catch (MissingResourceException e) { logger.error("Could not load Resource Bundle: " + bundleStr); //$NON-NLS-1$ } } //Set the look and feel based on configuration setLAF(); if (bundle != null) { container = xulLoader.loadXul("org/pentaho/aggdes/ui/resources/mainFrame.xul", bundle); //$NON-NLS-1$ } else { container = xulLoader.loadXul("org/pentaho/aggdes/ui/resources/mainFrame.xul"); //$NON-NLS-1$ } //generically register all Spring-initialized XulEventHandlers Map handlerMap = context.getBeansOfType(XulEventHandler.class); for (Object handler : handlerMap.values()) { container.addEventHandler((XulEventHandler) handler); } xulRunner.addContainer(container); xulRunner.initialize(); xulRunner.start(); }