當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。