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


Java BeanFactoryUtils.beansOfTypeIncludingAncestors方法代码示例

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


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

示例1: qualifiedBeanOfType

import org.springframework.beans.factory.BeanFactoryUtils; //导入方法依赖的package包/类
/**
 * Obtain a bean of type {@code T} from the given {@code BeanFactory} declaring a qualifier
 * (e.g. {@code <qualifier>} or {@code @Qualifier}) matching the given qualifier).
 * @param bf the BeanFactory to get the target bean from
 * @param beanType the type of bean to retrieve
 * @param qualifier the qualifier for selecting between multiple bean matches
 * @return the matching bean of type {@code T} (never {@code null})
 * @throws NoSuchBeanDefinitionException if no matching bean of type {@code T} found
 */
private static <T> T qualifiedBeanOfType(ConfigurableListableBeanFactory bf, Class<T> beanType, String qualifier) {
	Map<String, T> candidateBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(bf, beanType);
	T matchingBean = null;
	for (String beanName : candidateBeans.keySet()) {
		if (isQualifierMatch(qualifier, beanName, bf)) {
			if (matchingBean != null) {
				throw new NoSuchBeanDefinitionException(qualifier, "No unique " + beanType.getSimpleName() +
						" bean found for qualifier '" + qualifier + "'");
			}
			matchingBean = candidateBeans.get(beanName);
		}
	}
	if (matchingBean != null) {
		return matchingBean;
	}
	else if (bf.containsBean(qualifier)) {
		// Fallback: target bean at least found by bean name - probably a manually registered singleton.
		return bf.getBean(qualifier, beanType);
	}
	else {
		throw new NoSuchBeanDefinitionException(qualifier, "No matching " + beanType.getSimpleName() +
				" bean found for qualifier '" + qualifier + "' - neither qualifier match nor bean name match!");
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:BeanFactoryAnnotationUtils.java

示例2: afterPropertiesSet

import org.springframework.beans.factory.BeanFactoryUtils; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public void afterPropertiesSet() {

  Map<String, CommandMarker> commands = 
    BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext,
      CommandMarker.class);
  for (CommandMarker command : commands.values()) {
    getSimpleParser().add(command);
  }

  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);
  }
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:22,代码来源:LensJLineShellComponent.java

示例3: configurerConverters

import org.springframework.beans.factory.BeanFactoryUtils; //导入方法依赖的package包/类
/**
 * 注册通过{@link ConfigBeanConverterConfigurer}配置的Converters
 *
 * @param beanFactory
 */
private void configurerConverters(ConfigurableListableBeanFactory beanFactory) {
    // Find all CustomConverterConfigurer in the ApplicationContext, including ancestor contexts.
    Map<String, ConfigBeanConverterConfigurer> matchingBeans =
            BeanFactoryUtils.beansOfTypeIncludingAncestors(beanFactory, ConfigBeanConverterConfigurer.class, true, false);
    if (!matchingBeans.isEmpty()) {
        for (ConfigBeanConverterConfigurer converterConfigurer : matchingBeans.values()) {
            if (converterConfigurer.getConverters() != null) {
                for (ConfigBeanConverter converter : converterConfigurer.getConverters()) {
                    converters.add(converter);
                }
            }
        }
    }
}
 
开发者ID:zouzhirong,项目名称:configx,代码行数:20,代码来源:ConfigBeanConversionService.java

示例4: detectPersistenceExceptionTranslators

import org.springframework.beans.factory.BeanFactoryUtils; //导入方法依赖的package包/类
/**
 * Detect all PersistenceExceptionTranslators in the given BeanFactory.
 * @param beanFactory the ListableBeanFactory to obtaining all
 * PersistenceExceptionTranslators from
 * @return a chained PersistenceExceptionTranslator, combining all
 * PersistenceExceptionTranslators found in the factory
 * @see ChainedPersistenceExceptionTranslator
 */
protected PersistenceExceptionTranslator detectPersistenceExceptionTranslators(ListableBeanFactory beanFactory) {
	// Find all translators, being careful not to activate FactoryBeans.
	Map<String, PersistenceExceptionTranslator> pets = BeanFactoryUtils.beansOfTypeIncludingAncestors(
			beanFactory, PersistenceExceptionTranslator.class, false, false);
	ChainedPersistenceExceptionTranslator cpet = new ChainedPersistenceExceptionTranslator();
	for (PersistenceExceptionTranslator pet : pets.values()) {
		cpet.addDelegate(pet);
	}
	return cpet;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:PersistenceExceptionTranslationInterceptor.java

示例5: findAutowireCandidates

import org.springframework.beans.factory.BeanFactoryUtils; //导入方法依赖的package包/类
/**
 * Obtain all beans of the given type as autowire candidates.
 * @param type the type of the bean
 * @return the target beans, or an empty Collection if no bean of this type is found
 * @throws BeansException if bean retrieval failed
 */
protected <T> Map<String, T> findAutowireCandidates(Class<T> type) throws BeansException {
	if (this.beanFactory == null) {
		throw new IllegalStateException("No BeanFactory configured - " +
				"override the getBeanOfType method or specify the 'beanFactory' property");
	}
	return BeanFactoryUtils.beansOfTypeIncludingAncestors(this.beanFactory, type);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:AutowiredAnnotationBeanPostProcessor.java

示例6: initHandlerMappings

import org.springframework.beans.factory.BeanFactoryUtils; //导入方法依赖的package包/类
/**
 * Initialize the HandlerMappings used by this class.
 * <p>If no HandlerMapping beans are defined in the BeanFactory
 * for this namespace, we default to PortletModeHandlerMapping.
 */
private void initHandlerMappings(ApplicationContext context) {
	this.handlerMappings = null;

	if (this.detectAllHandlerMappings) {
		// Find all HandlerMappings in the ApplicationContext, including ancestor contexts.
		Map<String, HandlerMapping> matchingBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(
				context, HandlerMapping.class, true, false);
		if (!matchingBeans.isEmpty()) {
			this.handlerMappings = new ArrayList<HandlerMapping>(matchingBeans.values());
			// We keep HandlerMappings in sorted order.
			AnnotationAwareOrderComparator.sort(this.handlerMappings);
		}
	}
	else {
		try {
			HandlerMapping hm = context.getBean(HANDLER_MAPPING_BEAN_NAME, HandlerMapping.class);
			this.handlerMappings = Collections.singletonList(hm);
		}
		catch (NoSuchBeanDefinitionException ex) {
			// Ignore, we'll add a default HandlerMapping later.
		}
	}

	// Ensure we have at least one HandlerMapping, by registering
	// a default HandlerMapping if no other mappings are found.
	if (this.handlerMappings == null) {
		this.handlerMappings = getDefaultStrategies(context, HandlerMapping.class);
		if (logger.isDebugEnabled()) {
			logger.debug("No HandlerMappings found in portlet '" + getPortletName() + "': using default");
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:38,代码来源:DispatcherPortlet.java

示例7: initHandlerAdapters

import org.springframework.beans.factory.BeanFactoryUtils; //导入方法依赖的package包/类
/**
 * Initialize the HandlerAdapters used by this class.
 * <p>If no HandlerAdapter beans are defined in the BeanFactory
 * for this namespace, we default to SimpleControllerHandlerAdapter.
 */
private void initHandlerAdapters(ApplicationContext context) {
	this.handlerAdapters = null;

	if (this.detectAllHandlerAdapters) {
		// Find all HandlerAdapters in the ApplicationContext, including ancestor contexts.
		Map<String, HandlerAdapter> matchingBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(
				context, HandlerAdapter.class, true, false);
		if (!matchingBeans.isEmpty()) {
			this.handlerAdapters = new ArrayList<HandlerAdapter>(matchingBeans.values());
			// We keep HandlerAdapters in sorted order.
			AnnotationAwareOrderComparator.sort(this.handlerAdapters);
		}
	}
	else {
		try {
			HandlerAdapter ha = context.getBean(HANDLER_ADAPTER_BEAN_NAME, HandlerAdapter.class);
			this.handlerAdapters = Collections.singletonList(ha);
		}
		catch (NoSuchBeanDefinitionException ex) {
			// Ignore, we'll add a default HandlerAdapter later.
		}
	}

	// Ensure we have at least some HandlerAdapters, by registering
	// default HandlerAdapters if no other adapters are found.
	if (this.handlerAdapters == null) {
		this.handlerAdapters = getDefaultStrategies(context, HandlerAdapter.class);
		if (logger.isDebugEnabled()) {
			logger.debug("No HandlerAdapters found in portlet '" + getPortletName() + "': using default");
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:38,代码来源:DispatcherPortlet.java

示例8: initHandlerExceptionResolvers

import org.springframework.beans.factory.BeanFactoryUtils; //导入方法依赖的package包/类
/**
 * Initialize the HandlerExceptionResolver used by this class.
 * <p>If no bean is defined with the given name in the BeanFactory
 * for this namespace, we default to no exception resolver.
 */
private void initHandlerExceptionResolvers(ApplicationContext context) {
	this.handlerExceptionResolvers = null;

	if (this.detectAllHandlerExceptionResolvers) {
		// Find all HandlerExceptionResolvers in the ApplicationContext, including ancestor contexts.
		Map<String, HandlerExceptionResolver> matchingBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(
				context, HandlerExceptionResolver.class, true, false);
		if (!matchingBeans.isEmpty()) {
			this.handlerExceptionResolvers = new ArrayList<HandlerExceptionResolver>(matchingBeans.values());
			// We keep HandlerExceptionResolvers in sorted order.
			AnnotationAwareOrderComparator.sort(this.handlerExceptionResolvers);
		}
	}
	else {
		try {
			HandlerExceptionResolver her = context.getBean(
					HANDLER_EXCEPTION_RESOLVER_BEAN_NAME, HandlerExceptionResolver.class);
			this.handlerExceptionResolvers = Collections.singletonList(her);
		}
		catch (NoSuchBeanDefinitionException ex) {
			// Ignore, no HandlerExceptionResolver is fine too.
		}
	}

	// Just for consistency, check for default HandlerExceptionResolvers...
	// There aren't any in usual scenarios.
	if (this.handlerExceptionResolvers == null) {
		this.handlerExceptionResolvers = getDefaultStrategies(context, HandlerExceptionResolver.class);
		if (logger.isDebugEnabled()) {
			logger.debug("No HandlerExceptionResolvers found in portlet '" + getPortletName() + "': using default");
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:39,代码来源:DispatcherPortlet.java

示例9: initViewResolvers

import org.springframework.beans.factory.BeanFactoryUtils; //导入方法依赖的package包/类
/**
 * Initialize the ViewResolvers used by this class.
 * <p>If no ViewResolver beans are defined in the BeanFactory
 * for this namespace, we default to InternalResourceViewResolver.
 */
private void initViewResolvers(ApplicationContext context) {
	this.viewResolvers = null;

	if (this.detectAllViewResolvers) {
		// Find all ViewResolvers in the ApplicationContext, including ancestor contexts.
		Map<String, ViewResolver> matchingBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(
				context, ViewResolver.class, true, false);
		if (!matchingBeans.isEmpty()) {
			this.viewResolvers = new ArrayList<ViewResolver>(matchingBeans.values());
			// We keep ViewResolvers in sorted order.
			AnnotationAwareOrderComparator.sort(this.viewResolvers);
		}
	}
	else {
		try {
			ViewResolver vr = context.getBean(VIEW_RESOLVER_BEAN_NAME, ViewResolver.class);
			this.viewResolvers = Collections.singletonList(vr);
		}
		catch (NoSuchBeanDefinitionException ex) {
			// Ignore, we'll add a default ViewResolver later.
		}
	}

	// Ensure we have at least one ViewResolver, by registering
	// a default ViewResolver if no other resolvers are found.
	if (this.viewResolvers == null) {
		this.viewResolvers = getDefaultStrategies(context, ViewResolver.class);
		if (logger.isDebugEnabled()) {
			logger.debug("No ViewResolvers found in portlet '" + getPortletName() + "': using default");
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:38,代码来源:DispatcherPortlet.java

示例10: assertOneMessageSourceOnly

import org.springframework.beans.factory.BeanFactoryUtils; //导入方法依赖的package包/类
private void assertOneMessageSourceOnly(ClassPathXmlApplicationContext ctx, Object myMessageSource) {
	String[] beanNamesForType = ctx.getBeanNamesForType(StaticMessageSource.class);
	assertEquals(1, beanNamesForType.length);
	assertEquals("myMessageSource", beanNamesForType[0]);
	beanNamesForType = ctx.getBeanNamesForType(StaticMessageSource.class, true, true);
	assertEquals(1, beanNamesForType.length);
	assertEquals("myMessageSource", beanNamesForType[0]);
	beanNamesForType = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(ctx, StaticMessageSource.class);
	assertEquals(1, beanNamesForType.length);
	assertEquals("myMessageSource", beanNamesForType[0]);
	beanNamesForType = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(ctx, StaticMessageSource.class, true, true);
	assertEquals(1, beanNamesForType.length);
	assertEquals("myMessageSource", beanNamesForType[0]);

	Map<?, StaticMessageSource> beansOfType = ctx.getBeansOfType(StaticMessageSource.class);
	assertEquals(1, beansOfType.size());
	assertSame(myMessageSource, beansOfType.values().iterator().next());
	beansOfType = ctx.getBeansOfType(StaticMessageSource.class, true, true);
	assertEquals(1, beansOfType.size());
	assertSame(myMessageSource, beansOfType.values().iterator().next());
	beansOfType = BeanFactoryUtils.beansOfTypeIncludingAncestors(ctx, StaticMessageSource.class);
	assertEquals(1, beansOfType.size());
	assertSame(myMessageSource, beansOfType.values().iterator().next());
	beansOfType = BeanFactoryUtils.beansOfTypeIncludingAncestors(ctx, StaticMessageSource.class, true, true);
	assertEquals(1, beansOfType.size());
	assertSame(myMessageSource, beansOfType.values().iterator().next());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:28,代码来源:ClassPathXmlApplicationContextTests.java

示例11: initHandlerMappings

import org.springframework.beans.factory.BeanFactoryUtils; //导入方法依赖的package包/类
/**
 * Initialize the HandlerMappings used by this class.
 * <p>If no HandlerMapping beans are defined in the BeanFactory for this namespace,
 * we default to BeanNameUrlHandlerMapping.
 */
private void initHandlerMappings(ApplicationContext context) {
	this.handlerMappings = null;

	if (this.detectAllHandlerMappings) {
		// Find all HandlerMappings in the ApplicationContext, including ancestor contexts.
		Map<String, HandlerMapping> matchingBeans =
				BeanFactoryUtils.beansOfTypeIncludingAncestors(context, HandlerMapping.class, true, false);
		if (!matchingBeans.isEmpty()) {
			this.handlerMappings = new ArrayList<HandlerMapping>(matchingBeans.values());
			// We keep HandlerMappings in sorted order.
			AnnotationAwareOrderComparator.sort(this.handlerMappings);
		}
	}
	else {
		try {
			HandlerMapping hm = context.getBean(HANDLER_MAPPING_BEAN_NAME, HandlerMapping.class);
			this.handlerMappings = Collections.singletonList(hm);
		}
		catch (NoSuchBeanDefinitionException ex) {
			// Ignore, we'll add a default HandlerMapping later.
		}
	}

	// Ensure we have at least one HandlerMapping, by registering
	// a default HandlerMapping if no other mappings are found.
	if (this.handlerMappings == null) {
		this.handlerMappings = getDefaultStrategies(context, HandlerMapping.class);
		if (logger.isDebugEnabled()) {
			logger.debug("No HandlerMappings found in servlet '" + getServletName() + "': using default");
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:38,代码来源:DispatcherServlet.java

示例12: initHandlerAdapters

import org.springframework.beans.factory.BeanFactoryUtils; //导入方法依赖的package包/类
/**
 * Initialize the HandlerAdapters used by this class.
 * <p>If no HandlerAdapter beans are defined in the BeanFactory for this namespace,
 * we default to SimpleControllerHandlerAdapter.
 */
private void initHandlerAdapters(ApplicationContext context) {
	this.handlerAdapters = null;

	if (this.detectAllHandlerAdapters) {
		// Find all HandlerAdapters in the ApplicationContext, including ancestor contexts.
		Map<String, HandlerAdapter> matchingBeans =
				BeanFactoryUtils.beansOfTypeIncludingAncestors(context, HandlerAdapter.class, true, false);
		if (!matchingBeans.isEmpty()) {
			this.handlerAdapters = new ArrayList<HandlerAdapter>(matchingBeans.values());
			// We keep HandlerAdapters in sorted order.
			AnnotationAwareOrderComparator.sort(this.handlerAdapters);
		}
	}
	else {
		try {
			HandlerAdapter ha = context.getBean(HANDLER_ADAPTER_BEAN_NAME, HandlerAdapter.class);
			this.handlerAdapters = Collections.singletonList(ha);
		}
		catch (NoSuchBeanDefinitionException ex) {
			// Ignore, we'll add a default HandlerAdapter later.
		}
	}

	// Ensure we have at least some HandlerAdapters, by registering
	// default HandlerAdapters if no other adapters are found.
	if (this.handlerAdapters == null) {
		this.handlerAdapters = getDefaultStrategies(context, HandlerAdapter.class);
		if (logger.isDebugEnabled()) {
			logger.debug("No HandlerAdapters found in servlet '" + getServletName() + "': using default");
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:38,代码来源:DispatcherServlet.java

示例13: initHandlerExceptionResolvers

import org.springframework.beans.factory.BeanFactoryUtils; //导入方法依赖的package包/类
/**
 * Initialize the HandlerExceptionResolver used by this class.
 * <p>If no bean is defined with the given name in the BeanFactory for this namespace,
 * we default to no exception resolver.
 */
private void initHandlerExceptionResolvers(ApplicationContext context) {
	this.handlerExceptionResolvers = null;

	if (this.detectAllHandlerExceptionResolvers) {
		// Find all HandlerExceptionResolvers in the ApplicationContext, including ancestor contexts.
		Map<String, HandlerExceptionResolver> matchingBeans = BeanFactoryUtils
				.beansOfTypeIncludingAncestors(context, HandlerExceptionResolver.class, true, false);
		if (!matchingBeans.isEmpty()) {
			this.handlerExceptionResolvers = new ArrayList<HandlerExceptionResolver>(matchingBeans.values());
			// We keep HandlerExceptionResolvers in sorted order.
			AnnotationAwareOrderComparator.sort(this.handlerExceptionResolvers);
		}
	}
	else {
		try {
			HandlerExceptionResolver her =
					context.getBean(HANDLER_EXCEPTION_RESOLVER_BEAN_NAME, HandlerExceptionResolver.class);
			this.handlerExceptionResolvers = Collections.singletonList(her);
		}
		catch (NoSuchBeanDefinitionException ex) {
			// Ignore, no HandlerExceptionResolver is fine too.
		}
	}

	// Ensure we have at least some HandlerExceptionResolvers, by registering
	// default HandlerExceptionResolvers if no other resolvers are found.
	if (this.handlerExceptionResolvers == null) {
		this.handlerExceptionResolvers = getDefaultStrategies(context, HandlerExceptionResolver.class);
		if (logger.isDebugEnabled()) {
			logger.debug("No HandlerExceptionResolvers found in servlet '" + getServletName() + "': using default");
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:39,代码来源:DispatcherServlet.java

示例14: initViewResolvers

import org.springframework.beans.factory.BeanFactoryUtils; //导入方法依赖的package包/类
/**
 * Initialize the ViewResolvers used by this class.
 * <p>If no ViewResolver beans are defined in the BeanFactory for this
 * namespace, we default to InternalResourceViewResolver.
 */
private void initViewResolvers(ApplicationContext context) {
	this.viewResolvers = null;

	if (this.detectAllViewResolvers) {
		// Find all ViewResolvers in the ApplicationContext, including ancestor contexts.
		Map<String, ViewResolver> matchingBeans =
				BeanFactoryUtils.beansOfTypeIncludingAncestors(context, ViewResolver.class, true, false);
		if (!matchingBeans.isEmpty()) {
			this.viewResolvers = new ArrayList<ViewResolver>(matchingBeans.values());
			// We keep ViewResolvers in sorted order.
			AnnotationAwareOrderComparator.sort(this.viewResolvers);
		}
	}
	else {
		try {
			ViewResolver vr = context.getBean(VIEW_RESOLVER_BEAN_NAME, ViewResolver.class);
			this.viewResolvers = Collections.singletonList(vr);
		}
		catch (NoSuchBeanDefinitionException ex) {
			// Ignore, we'll add a default ViewResolver later.
		}
	}

	// Ensure we have at least one ViewResolver, by registering
	// a default ViewResolver if no other resolvers are found.
	if (this.viewResolvers == null) {
		this.viewResolvers = getDefaultStrategies(context, ViewResolver.class);
		if (logger.isDebugEnabled()) {
			logger.debug("No ViewResolvers found in servlet '" + getServletName() + "': using default");
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:38,代码来源:DispatcherServlet.java

示例15: init

import org.springframework.beans.factory.BeanFactoryUtils; //导入方法依赖的package包/类
public void init() {
	DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory) LeopardBeanFactoryAware.getBeanFactory();
	Map<String, VoFiller> matchingBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(beanFactory, VoFiller.class, true, false);
	if (!matchingBeans.isEmpty()) {
		this.fillerHandlers = new ArrayList<VoFiller>(matchingBeans.values());
		AnnotationAwareOrderComparator.sort(this.fillerHandlers);
	}
}
 
开发者ID:tanhaichao,项目名称:leopard,代码行数:9,代码来源:VoFillerImpl.java


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