当前位置: 首页>>代码示例>>Java>>正文


Java ApplicationContext.getBeansOfType方法代码示例

本文整理汇总了Java中org.springframework.context.ApplicationContext.getBeansOfType方法的典型用法代码示例。如果您正苦于以下问题:Java ApplicationContext.getBeansOfType方法的具体用法?Java ApplicationContext.getBeansOfType怎么用?Java ApplicationContext.getBeansOfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.context.ApplicationContext的用法示例。


在下文中一共展示了ApplicationContext.getBeansOfType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDataSource

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
private DataSource getDataSource(ApplicationContext applicationContext, Persistence persistenceSettings) {
	DataSource dataSource = null;
	Map<String, DataSource> datasources = applicationContext.getBeansOfType(DataSource.class);
	int dsSize = null != datasources ? datasources.size() : 0;
	if (null != datasources && null != persistenceSettings.getDataSourceName()) {
		dataSource = datasources.get(persistenceSettings.getDataSourceName());
	} else if (null != datasources && dsSize == 1 && null == persistenceSettings.getDataSourceName()){
		dataSource = datasources.values().iterator().next();
	}
	
    if (dataSource == null) {
    	throw new BeanInitializationException(
    			"A datasource is required when starting Quartz-Scheduler in persisted mode. " +
    			"No DS found in map with size: " + dsSize + ", and configured DSName: " + persistenceSettings.getDataSourceName());
    }
    return dataSource;
}
 
开发者ID:andrehertwig,项目名称:spring-boot-starter-quartz,代码行数:18,代码来源:QuartzSchedulerAutoConfiguration.java

示例2: refresh

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
@Override
public void refresh(ApplicationContext applicationContext)
{
	unResolvePostProcessList = new ArrayList<>();

	Map<String, UnResolvePostProcess> unResolvePostProcessMap = applicationContext.getBeansOfType(UnResolvePostProcess.class);

	if (!CollectionUtils.isEmpty(unResolvePostProcessMap)) {
		unResolvePostProcessList.addAll(unResolvePostProcessMap.values());
	}
	unResolvePostProcessMap = null;

	unResolveFieldPostProcessList = new ArrayList<>();

	Map<String, UnResolveFieldPostProcess> unResolveFieldPostProcessMap = applicationContext.getBeansOfType(UnResolveFieldPostProcess.class);

	if (!CollectionUtils.isEmpty(unResolveFieldPostProcessMap)) {
		unResolveFieldPostProcessList.addAll(unResolveFieldPostProcessMap.values());
	}
	unResolveFieldPostProcessMap = null;

}
 
开发者ID:yanghao0518,项目名称:cstruct-parser,代码行数:23,代码来源:AbstractResolve.java

示例3: setApplicationContext

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
/**
 * Sets application context.
 *
 * @param applicationContext the application context
 * @throws BeansException the beans exception
 */
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
    this.applicationContext = applicationContext;

    // 初始化spring配置到已发布
    if (applicationContext != null) {
        Map<String, RegistryConfig> registryMaps = applicationContext
                .getBeansOfType(RegistryConfig.class, false, false);
        if (registryMaps != null && !registryMaps.isEmpty()) {
            registryConfigs.addAll(registryMaps.values());
        }

        Map<String, ServerConfig> serverMaps = applicationContext
                .getBeansOfType(ServerConfig.class, false, false);
        if (serverMaps != null && !serverMaps.isEmpty()) {
            serverConfigs.addAll(serverMaps.values());
            for (ServerConfig serverConfig : serverConfigs) {
                serverCache.put(serverConfig.getProtocol() + ":" + serverConfig.getPort(), serverConfig);
            }
        }
    }
}
 
开发者ID:tiglabs,项目名称:jsf-sdk,代码行数:29,代码来源:AnnotationBean.java

示例4: GeodirQueryManagerImpl

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
@Autowired
public GeodirQueryManagerImpl(ApplicationContext ctx) {
	this.queryModels = new TreeMap<>();
	this.queryNames = new ArrayList<>();
	this.queryProperties = new ArrayList<>();
	@SuppressWarnings("rawtypes")
	Map<String, GeodirQuery> producers = ctx.getBeansOfType(GeodirQuery.class);
	Iterator<String> it = producers.keySet().iterator();
	while (it.hasNext()) {
		String key = it.next();
		queryNames.add(producers.get(key).getProperties().getName());
		queryProperties.add(producers.get(key).getProperties());
		queryModels.put(producers.get(key).getProperties().getName(), producers.get(key));
	}
	for (String th : queryNames) {
		log.info("Query name: " + th);
	}
}
 
开发者ID:geodir,项目名称:Layer-Query,代码行数:19,代码来源:GeodirQueryManagerImpl.java

示例5: setApplicationContext

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
public void setApplicationContext(ApplicationContext applicationContext)
		throws BeansException {
	Map<String,IWebservice> bindingsMap=applicationContext.getBeansOfType(IWebservice.class);
	if(applicationContext.getParent()!=null){
		bindingsMap.putAll(applicationContext.getParent().getBeansOfType(IWebservice.class));			
	}
	if(bindingsMap.size()>0){
		List<Class<?>> list=new ArrayList<Class<?>>();
		for(IWebservice binding:bindingsMap.values()){
			Class<?>[] c=binding.bindClasses();
			if(c!=null){
				for(Class<?> clazz:c){
					list.add(clazz);
				}
			}
		}
		if(list.size()>0){
			this.setClassesToBeBound(list.toArray(new Class<?>[list.size()]));							
		}else{
			this.setClassesToBeBound(new Class[]{String.class});
		}
	}else{
		this.setClassesToBeBound(new Class[]{String.class});			
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:26,代码来源:WSJaxb2Marshaller.java

示例6: setApplicationContext

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
	this.applicationContext = applicationContext;
	Map<String, HibernateSessionFactoryRepository> map = applicationContext
			.getBeansOfType(HibernateSessionFactoryRepository.class);
	if (map.size() > 0) {
		this.sessionFactoryRepository = map.values().iterator().next();
	} else if (applicationContext.getParent() != null) {
		map = applicationContext.getParent().getBeansOfType(HibernateSessionFactoryRepository.class);
		if (map.size() > 0) {
			this.sessionFactoryRepository = map.values().iterator().next();
		}
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:14,代码来源:HibernateDao.java

示例7: getAvailableMultifactorAuthenticationProviders

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
/**
 * Gets all multifactor authentication providers from application context.
 *
 * @param applicationContext the application context
 * @return the all multifactor authentication providers from application context
 */
public static Map<String, MultifactorAuthenticationProvider> getAvailableMultifactorAuthenticationProviders(
        final ApplicationContext applicationContext) {
    try {
        return applicationContext.getBeansOfType(MultifactorAuthenticationProvider.class, false, true);
    } catch (final Exception e) {
        LOGGER.warn("Could not locate beans of type [{}]", MultifactorAuthenticationProvider.class);
    }
    return Collections.emptyMap();
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:16,代码来源:WebUtils.java

示例8: rebindCasConfigurationProperties

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
/**
 * Rebind cas configuration properties.
 *
 * @param binder the binder
 */
public static void rebindCasConfigurationProperties(final ConfigurationPropertiesBindingPostProcessor binder) {
    Assert.notNull(binder, "Configuration binder cannot be null");
    
    final ApplicationContext applicationContext = ApplicationContextProvider.getApplicationContext();
    final Map<String, CasConfigurationProperties> map = applicationContext.getBeansOfType(CasConfigurationProperties.class);
    final String name = map.keySet().iterator().next();
    LOGGER.debug("Reloading CAS configuration via [{}]", name);
    final Object e = applicationContext.getBean(name);
    binder.postProcessBeforeInitialization(e, name);
    final Object bean = applicationContext.getAutowireCapableBeanFactory().initializeBean(e, name);
    applicationContext.getAutowireCapableBeanFactory().autowireBean(bean);
    LOGGER.debug("Reloaded CAS configuration [{}]", name);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:19,代码来源:CasConfigurationPropertiesEnvironmentManager.java

示例9: getBeanFactoryMetaData

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
private ConfigurationBeanFactoryMetaData getBeanFactoryMetaData(
        ApplicationContext context) {
    Map<String, ConfigurationBeanFactoryMetaData> beans = context
            .getBeansOfType(ConfigurationBeanFactoryMetaData.class);
    if (beans.size() == 1) {
        return beans.values().iterator().next();
    }
    return null;
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:10,代码来源:Gatherer.java

示例10: onApplicationEvent

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
    synchronized (lock) {
        if (initialled) {
            return;
        } else {
            ApplicationContext applicationContext = event.getApplicationContext();
            Map<String, ServiceBean> instances = applicationContext.getBeansOfType(ServiceBean.class);
            if (!instances.isEmpty()) {
                ConfigBean configBean = applicationContext.getBean(ConfigBean.class);
                this.thrallProperties = configBean;
                RpcServiceConfig rpcSerivceConfig = new RpcServiceConfig();
                this.addRegistyAddress(rpcSerivceConfig);
                rpcSerivceConfig.setApplication(thrallProperties.getApplication());
                this.addHostAndPort(rpcSerivceConfig);
                rpcSerivceConfig.setMonitorinterval(thrallProperties.getMonitorinterval());
                for (Map.Entry<String, ServiceBean> entry : instances.entrySet()) {
                    ServiceBean serviceBean = entry.getValue();
                    rpcSerivceConfig.addServiceDefinition(serviceBean.getServiceName(), serviceBean.getGroup(),
                                                          serviceBean.getVersion(), serviceBean.getRef());
                }
                this.rpcService = rpcSerivceConfig;
                initialled = true;
                rpcSerivceConfig.export();
            }
        }

    }

}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:31,代码来源:ServiceBean.java

示例11: loadProcessor

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
/**
 * 处理所有处理器排序以及分组逻辑
 */
private void loadProcessor(ContextRefreshedEvent event) {
  ApplicationContext ac = event.getApplicationContext();
  Map<String, FileUploadProcessor> beans = ac.getBeansOfType(FileUploadProcessor.class);
  if (beans != null && beans.size() > 0) {
    /**
     * 分组
     * public M -------
     * group1 1 ---
     *        2 ---
     *        3 ---
     * group2 1 ---
     *        2 ---
     *        3 ---        
     */
    
    for (Map.Entry<String, FileUploadProcessor> entry : beans.entrySet()) {
      
      FileUploadProcessor processor = entry.getValue();
      FileUploadProcessor target = null;//非代理的处理器
      
      
      try {
         target = (FileUploadProcessor) AopTargetUtils.getTarget(processor);
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
      
      ProcessorChannel processorGroup = target.getClass().getAnnotation(ProcessorChannel.class);
      
      String group = AbstractChannelProcessor.KEY;
      // 取出自定义分组
      if (processorGroup != null){
        group = processorGroup.channel();
      }else{
        //取出公共的注册链
        //默认就是公共分组了
      }
      TreeMap<Integer, LinkedList<FileUploadProcessor>> linkedTreeMap = processorLogicDefination.get(group);
      Integer orderIndex = Integer.MAX_VALUE;
      ProcessorOrder processorOrder = target.getClass().getAnnotation(ProcessorOrder.class);
      if (processorOrder != null) {
        orderIndex = processorOrder.order();
      }
      
      if (linkedTreeMap == null) {
        linkedTreeMap = new TreeMap<Integer, LinkedList<FileUploadProcessor>>();
        processorLogicDefination.put(group, linkedTreeMap);
      }
      
      LinkedList<FileUploadProcessor> storage = linkedTreeMap.get(orderIndex);
      if (storage == null) {
        storage = new LinkedList<FileUploadProcessor>();
        linkedTreeMap.put(orderIndex, storage);
      }
      storage.add(processor);
    }
    // linked

  }
}
 
开发者ID:devpage,项目名称:fastdfs-quickstart,代码行数:64,代码来源:FileProcessFactory.java

示例12: getTriggers

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
private Collection<Trigger> getTriggers(ApplicationContext applicationContext) {
	Map<String, Trigger> triggers = applicationContext.getBeansOfType(Trigger.class);
	if (null != triggers && !triggers.isEmpty()) {
		return triggers.values();
	}
	return null;
}
 
开发者ID:andrehertwig,项目名称:spring-boot-starter-quartz,代码行数:8,代码来源:QuartzSchedulerAutoConfiguration.java

示例13: setApplicationContext

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
@Override
public void setApplicationContext(ApplicationContext applicationContext)
		throws BeansException {
	super.setApplicationContext(applicationContext);
	this.keyGeneratorMaps=applicationContext.getBeansOfType(IGenerator.class);
	velocityVariableRegisters=applicationContext.getBeansOfType(VelocityVariableRegister.class).values();
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:8,代码来源:EntityPR.java

示例14: setApplicationContext

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
public void setApplicationContext(ApplicationContext applicationContext)
	throws BeansException {
	iactionMaps=applicationContext.getBeansOfType(IAction.class);
	variables=new ArrayList<VariableInfo>();
	for(VariableRegister reg:applicationContext.getBeansOfType(VariableRegister.class).values()){
		variables.addAll(reg.register().values());
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:9,代码来源:ActionPR.java

示例15: setApplicationContext

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
public void setApplicationContext(ApplicationContext applicationContext)
		throws BeansException {
	this.applicationContext=applicationContext;
	Map<String,HibernateSessionFactoryRepository> map=applicationContext.getBeansOfType(HibernateSessionFactoryRepository.class);
	if(map.size()>0){
		this.sessionFactoryRepository = map.values().iterator().next();
	}else if(applicationContext.getParent()!=null){
		map=applicationContext.getParent().getBeansOfType(HibernateSessionFactoryRepository.class);
		if(map.size()>0){
			this.sessionFactoryRepository = map.values().iterator().next();				
		}
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:14,代码来源:HibernateDao.java


注:本文中的org.springframework.context.ApplicationContext.getBeansOfType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。