org.springframework.beans.factory.BeanFactoryUtils#beanOfTypeIncludingAncestors ( )源码实例Demo

下面列出了org.springframework.beans.factory.BeanFactoryUtils#beanOfTypeIncludingAncestors ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: spring-analysis-note   文件: ScriptTemplateView.java
protected ScriptTemplateConfig autodetectViewConfig() throws BeansException {
	try {
		return BeanFactoryUtils.beanOfTypeIncludingAncestors(
				obtainApplicationContext(), ScriptTemplateConfig.class, true, false);
	}
	catch (NoSuchBeanDefinitionException ex) {
		throw new ApplicationContextException("Expected a single ScriptTemplateConfig bean in the current " +
				"web application context or the parent root context: ScriptTemplateConfigurer is " +
				"the usual implementation. This bean may have any name.", ex);
	}
}
 
源代码2 项目: spring-analysis-note   文件: FreeMarkerView.java
/**
 * Autodetect a {@link FreeMarkerConfig} object via the ApplicationContext.
 * @return the Configuration instance to use for FreeMarkerViews
 * @throws BeansException if no Configuration instance could be found
 * @see #setConfiguration
 */
protected FreeMarkerConfig autodetectConfiguration() throws BeansException {
	try {
		return BeanFactoryUtils.beanOfTypeIncludingAncestors(
				obtainApplicationContext(), FreeMarkerConfig.class, true, false);
	}
	catch (NoSuchBeanDefinitionException ex) {
		throw new ApplicationContextException(
				"Must define a single FreeMarkerConfig bean in this web application context " +
						"(may be inherited): FreeMarkerConfigurer is the usual implementation. " +
						"This bean may be given any name.", ex);
	}
}
 
源代码3 项目: spring-analysis-note   文件: ScriptTemplateView.java
protected ScriptTemplateConfig autodetectViewConfig() throws BeansException {
	try {
		return BeanFactoryUtils.beanOfTypeIncludingAncestors(
				obtainApplicationContext(), ScriptTemplateConfig.class, true, false);
	}
	catch (NoSuchBeanDefinitionException ex) {
		throw new ApplicationContextException("Expected a single ScriptTemplateConfig bean in the current " +
				"Servlet web application context or the parent root context: ScriptTemplateConfigurer is " +
				"the usual implementation. This bean may have any name.", ex);
	}
}
 
源代码4 项目: spring-analysis-note   文件: FreeMarkerView.java
/**
 * Autodetect a {@link FreeMarkerConfig} object via the ApplicationContext.
 * @return the Configuration instance to use for FreeMarkerViews
 * @throws BeansException if no Configuration instance could be found
 * @see #getApplicationContext
 * @see #setConfiguration
 */
protected FreeMarkerConfig autodetectConfiguration() throws BeansException {
	try {
		return BeanFactoryUtils.beanOfTypeIncludingAncestors(
				obtainApplicationContext(), FreeMarkerConfig.class, true, false);
	}
	catch (NoSuchBeanDefinitionException ex) {
		throw new ApplicationContextException(
				"Must define a single FreeMarkerConfig bean in this web application context " +
				"(may be inherited): FreeMarkerConfigurer is the usual implementation. " +
				"This bean may be given any name.", ex);
	}
}
 
protected ScriptTemplateConfig autodetectViewConfig() throws BeansException {
	try {
		return BeanFactoryUtils.beanOfTypeIncludingAncestors(
				obtainApplicationContext(), ScriptTemplateConfig.class, true, false);
	}
	catch (NoSuchBeanDefinitionException ex) {
		throw new ApplicationContextException("Expected a single ScriptTemplateConfig bean in the current " +
				"web application context or the parent root context: ScriptTemplateConfigurer is " +
				"the usual implementation. This bean may have any name.", ex);
	}
}
 
源代码6 项目: java-technology-stack   文件: FreeMarkerView.java
/**
 * Autodetect a {@link FreeMarkerConfig} object via the ApplicationContext.
 * @return the Configuration instance to use for FreeMarkerViews
 * @throws BeansException if no Configuration instance could be found
 * @see #setConfiguration
 */
protected FreeMarkerConfig autodetectConfiguration() throws BeansException {
	try {
		return BeanFactoryUtils.beanOfTypeIncludingAncestors(
				obtainApplicationContext(), FreeMarkerConfig.class, true, false);
	}
	catch (NoSuchBeanDefinitionException ex) {
		throw new ApplicationContextException(
				"Must define a single FreeMarkerConfig bean in this web application context " +
						"(may be inherited): FreeMarkerConfigurer is the usual implementation. " +
						"This bean may be given any name.", ex);
	}
}
 
protected ScriptTemplateConfig autodetectViewConfig() throws BeansException {
	try {
		return BeanFactoryUtils.beanOfTypeIncludingAncestors(
				obtainApplicationContext(), ScriptTemplateConfig.class, true, false);
	}
	catch (NoSuchBeanDefinitionException ex) {
		throw new ApplicationContextException("Expected a single ScriptTemplateConfig bean in the current " +
				"Servlet web application context or the parent root context: ScriptTemplateConfigurer is " +
				"the usual implementation. This bean may have any name.", ex);
	}
}
 
源代码8 项目: java-technology-stack   文件: FreeMarkerView.java
/**
 * Autodetect a {@link FreeMarkerConfig} object via the ApplicationContext.
 * @return the Configuration instance to use for FreeMarkerViews
 * @throws BeansException if no Configuration instance could be found
 * @see #getApplicationContext
 * @see #setConfiguration
 */
protected FreeMarkerConfig autodetectConfiguration() throws BeansException {
	try {
		return BeanFactoryUtils.beanOfTypeIncludingAncestors(
				obtainApplicationContext(), FreeMarkerConfig.class, true, false);
	}
	catch (NoSuchBeanDefinitionException ex) {
		throw new ApplicationContextException(
				"Must define a single FreeMarkerConfig bean in this web application context " +
				"(may be inherited): FreeMarkerConfigurer is the usual implementation. " +
				"This bean may be given any name.", ex);
	}
}
 
@Bean
public NacosConfigProperties nacosConfigProperties(ApplicationContext context) {
	if (context.getParent() != null
			&& BeanFactoryUtils.beanNamesForTypeIncludingAncestors(
					context.getParent(), NacosConfigProperties.class).length > 0) {
		return BeanFactoryUtils.beanOfTypeIncludingAncestors(context.getParent(),
				NacosConfigProperties.class);
	}
	return new NacosConfigProperties();
}
 
源代码10 项目: lams   文件: ScriptTemplateView.java
protected ScriptTemplateConfig autodetectViewConfig() throws BeansException {
	try {
		return BeanFactoryUtils.beanOfTypeIncludingAncestors(
				getApplicationContext(), ScriptTemplateConfig.class, true, false);
	}
	catch (NoSuchBeanDefinitionException ex) {
		throw new ApplicationContextException("Expected a single ScriptTemplateConfig bean in the current " +
				"Servlet web application context or the parent root context: ScriptTemplateConfigurer is " +
				"the usual implementation. This bean may have any name.", ex);
	}
}
 
源代码11 项目: lams   文件: FreeMarkerView.java
/**
 * Autodetect a {@link FreeMarkerConfig} object via the ApplicationContext.
 * @return the Configuration instance to use for FreeMarkerViews
 * @throws BeansException if no Configuration instance could be found
 * @see #getApplicationContext
 * @see #setConfiguration
 */
protected FreeMarkerConfig autodetectConfiguration() throws BeansException {
	try {
		return BeanFactoryUtils.beanOfTypeIncludingAncestors(
				getApplicationContext(), FreeMarkerConfig.class, true, false);
	}
	catch (NoSuchBeanDefinitionException ex) {
		throw new ApplicationContextException(
				"Must define a single FreeMarkerConfig bean in this web application context " +
				"(may be inherited): FreeMarkerConfigurer is the usual implementation. " +
				"This bean may be given any name.", ex);
	}
}
 
源代码12 项目: lams   文件: VelocityView.java
/**
 * Autodetect a VelocityEngine via the ApplicationContext.
 * Called if no explicit VelocityEngine has been specified.
 * @return the VelocityEngine to use for VelocityViews
 * @throws BeansException if no VelocityEngine could be found
 * @see #getApplicationContext
 * @see #setVelocityEngine
 */
protected VelocityEngine autodetectVelocityEngine() throws BeansException {
	try {
		VelocityConfig velocityConfig = BeanFactoryUtils.beanOfTypeIncludingAncestors(
				getApplicationContext(), VelocityConfig.class, true, false);
		return velocityConfig.getVelocityEngine();
	}
	catch (NoSuchBeanDefinitionException ex) {
		throw new ApplicationContextException(
				"Must define a single VelocityConfig bean in this web application context " +
				"(may be inherited): VelocityConfigurer is the usual implementation. " +
				"This bean may be given any name.", ex);
	}
}
 
源代码13 项目: scoold   文件: VelocityView.java
/**
 * Autodetect a VelocityEngine via the ApplicationContext. Called if no explicit VelocityEngine has been specified.
 *
 * @return the VelocityEngine to use for VelocityViews
 * @throws BeansException if no VelocityEngine could be found
 * @see #getApplicationContext
 * @see #setVelocityEngine
 */
protected VelocityEngine autodetectVelocityEngine() throws BeansException {
	try {
		VelocityConfig velocityConfig = BeanFactoryUtils.beanOfTypeIncludingAncestors(
				getApplicationContext(), VelocityConfig.class, true, false);
		return velocityConfig.getVelocityEngine();
	} catch (NoSuchBeanDefinitionException ex) {
		throw new ApplicationContextException(
				"Must define a single VelocityConfig bean in this web application context "
				+ "(may be inherited): VelocityConfigurer is the usual implementation. "
				+ "This bean may be given any name.", ex);
	}
}
 
源代码14 项目: spring4-understanding   文件: ScriptTemplateView.java
protected ScriptTemplateConfig autodetectViewConfig() throws BeansException {
	try {
		return BeanFactoryUtils.beanOfTypeIncludingAncestors(
				getApplicationContext(), ScriptTemplateConfig.class, true, false);
	}
	catch (NoSuchBeanDefinitionException ex) {
		throw new ApplicationContextException("Expected a single ScriptTemplateConfig bean in the current " +
				"Servlet web application context or the parent root context: ScriptTemplateConfigurer is " +
				"the usual implementation. This bean may have any name.", ex);
	}
}
 
源代码15 项目: spring4-understanding   文件: FreeMarkerView.java
/**
 * Autodetect a {@link FreeMarkerConfig} object via the ApplicationContext.
 * @return the Configuration instance to use for FreeMarkerViews
 * @throws BeansException if no Configuration instance could be found
 * @see #getApplicationContext
 * @see #setConfiguration
 */
protected FreeMarkerConfig autodetectConfiguration() throws BeansException {
	try {
		return BeanFactoryUtils.beanOfTypeIncludingAncestors(
				getApplicationContext(), FreeMarkerConfig.class, true, false);
	}
	catch (NoSuchBeanDefinitionException ex) {
		throw new ApplicationContextException(
				"Must define a single FreeMarkerConfig bean in this web application context " +
				"(may be inherited): FreeMarkerConfigurer is the usual implementation. " +
				"This bean may be given any name.", ex);
	}
}
 
源代码16 项目: spring4-understanding   文件: VelocityView.java
/**
 * Autodetect a VelocityEngine via the ApplicationContext.
 * Called if no explicit VelocityEngine has been specified.
 * @return the VelocityEngine to use for VelocityViews
 * @throws BeansException if no VelocityEngine could be found
 * @see #getApplicationContext
 * @see #setVelocityEngine
 */
protected VelocityEngine autodetectVelocityEngine() throws BeansException {
	try {
		VelocityConfig velocityConfig = BeanFactoryUtils.beanOfTypeIncludingAncestors(
				getApplicationContext(), VelocityConfig.class, true, false);
		return velocityConfig.getVelocityEngine();
	}
	catch (NoSuchBeanDefinitionException ex) {
		throw new ApplicationContextException(
				"Must define a single VelocityConfig bean in this web application context " +
				"(may be inherited): VelocityConfigurer is the usual implementation. " +
				"This bean may be given any name.", ex);
	}
}
 
@Bean
public ConfigClientProperties configClientProperties(Environment environment,
		ApplicationContext context) {
	if (context.getParent() != null
			&& BeanFactoryUtils.beanNamesForTypeIncludingAncestors(
					context.getParent(), ConfigClientProperties.class).length > 0) {
		return BeanFactoryUtils.beanOfTypeIncludingAncestors(context.getParent(),
				ConfigClientProperties.class);
	}
	ConfigClientProperties client = new ConfigClientProperties(environment);
	return client;
}
 
源代码18 项目: spring-music   文件: AlbumRepositoryPopulator.java
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
    if (event.getApplicationContext().equals(applicationContext)) {
        CrudRepository albumRepository =
                BeanFactoryUtils.beanOfTypeIncludingAncestors(applicationContext, CrudRepository.class);

        if (albumRepository != null && albumRepository.count() == 0) {
            populate(albumRepository);
        }
    }

}
 
源代码19 项目: Lottery   文件: SimpleFreeMarkerView.java
/**
 * 自动检测FreeMarkerConfig
 * 
 * @return
 * @throws BeansException
 */
protected FreeMarkerConfig autodetectConfiguration() throws BeansException {
	try {
		return (FreeMarkerConfig) BeanFactoryUtils
				.beanOfTypeIncludingAncestors(getApplicationContext(),
						FreeMarkerConfig.class, true, false);
	} catch (NoSuchBeanDefinitionException ex) {
		throw new ApplicationContextException(
				"Must define a single FreeMarkerConfig bean in this web application context "
						+ "(may be inherited): FreeMarkerConfigurer is the usual implementation. "
						+ "This bean may be given any name.", ex);
	}
}
 
源代码20 项目: Lottery   文件: DbFileServlet.java
@Override
public void init() throws ServletException {
	WebApplicationContext appCtx = WebApplicationContextUtils
			.getWebApplicationContext(getServletContext());
	dbFileMng = BeanFactoryUtils.beanOfTypeIncludingAncestors(appCtx,
			DbFileMng.class);
}