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


Java ApplicationContext.findAnnotationOnBean方法代码示例

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


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

示例1: extractPrefix

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
/**
 * Extract configuration prefix from {@link ConfigurationProperties} annotation.
 * @param context the application context
 * @param beanFactoryMetaData the bean factory meta-data
 * @param beanName the bean name
 * @param bean the bean
 * @return the prefix
 */
private String extractPrefix(ApplicationContext context,
                             ConfigurationBeanFactoryMetaData beanFactoryMetaData, String beanName,
                             Object bean) {
    ConfigurationProperties annotation = context.findAnnotationOnBean(beanName,
            ConfigurationProperties.class);
    if (beanFactoryMetaData != null) {
        ConfigurationProperties override = beanFactoryMetaData
                .findFactoryAnnotation(beanName, ConfigurationProperties.class);
        if (override != null) {
            // The @Bean-level @ConfigurationProperties overrides the one at type
            // level when binding. Arguably we should render them both, but this one
            // might be the most relevant for a starting point.
            annotation = override;
        }
    }
    return (StringUtils.hasLength(annotation.value()) ? annotation.value()
            : annotation.prefix());
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:27,代码来源:Gatherer.java

示例2: findAnnotatedBeans

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
/**
 * Find the names of beans annotated with
 * {@linkplain ControllerAdvice @ControllerAdvice} in the given
 * ApplicationContext and wrap them as {@code ControllerAdviceBean} instances.
 */
public static List<ControllerAdviceBean> findAnnotatedBeans(ApplicationContext applicationContext) {
	List<ControllerAdviceBean> beans = new ArrayList<ControllerAdviceBean>();
	for (String name : BeanFactoryUtils.beanNamesForTypeIncludingAncestors(applicationContext, Object.class)) {
		if (applicationContext.findAnnotationOnBean(name, ControllerAdvice.class) != null) {
			beans.add(new ControllerAdviceBean(name, applicationContext));
		}
	}
	return beans;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:ControllerAdviceBean.java


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