本文整理了Java中org.springframework.context.ConfigurableApplicationContext.getBeanNamesForAnnotation()
方法的一些代码示例,展示了ConfigurableApplicationContext.getBeanNamesForAnnotation()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ConfigurableApplicationContext.getBeanNamesForAnnotation()
方法的具体详情如下:
包路径:org.springframework.context.ConfigurableApplicationContext
类名称:ConfigurableApplicationContext
方法名:getBeanNamesForAnnotation
暂无
代码示例来源:origin: NationalSecurityAgency/datawave
@Override
public String[] getBeanNamesForAnnotation(Class<? extends Annotation> annotationType) {
lock.readLock().lock();
try {
return configurableApplicationContext.getBeanNamesForAnnotation(annotationType);
} finally {
lock.readLock().unlock();
}
}
代码示例来源:origin: joinfaces/joinfaces
@SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification = "getType() is always non-null when reached")
private void warnAboutJsfManagedBeans(ConfigurableApplicationContext applicationContext, Class<? extends Annotation> managedBeanClass) {
String[] managedBeanNames = applicationContext.getBeanNamesForAnnotation(managedBeanClass);
for (String managedBeanName : managedBeanNames) {
log.warn(
"The spring bean '{}' of type '{}' is also annotated with '@javax.faces.bean.ManagedBean'. This may lead to unexpected behaviour.",
managedBeanName,
applicationContext.getType(managedBeanName).getName()
);
}
}
}
代码示例来源:origin: stackoverflow.com
ConfigurableApplicationContext context = SpringApplication.run(App.class, args);
String[] beanNames = context.getBeanNamesForAnnotation(View.class);
for (String beanName : beanNames) {
Object bean = context.getBean(beanName);
View annotationOnBean = AnnotatedElementUtils.findMergedAnnotation(bean, View.class);
System.out.println(annotationOnBean.name());
}
代码示例来源:origin: cereebro/cereebro
/**
* Detected relationships in annotated bean classes.
*
* @return Relationships detected from annotated classes.
*/
protected Set<Relationship> detectAnnotatedClasses() {
Set<Relationship> result = new HashSet<>();
String[] annotatedBeans = applicationContext.getBeanNamesForAnnotation(annotation);
for (String beanName : annotatedBeans) {
T anno = applicationContext.findAnnotationOnBean(beanName, annotation);
result.addAll(extractFromAnnotation(anno));
}
return result;
}
代码示例来源:origin: org.testifyproject.di/di-spring
Object getQualifiedInstance(Annotation[] qualifiers, TypeToken token) {
Object instance = null;
Annotation annotation = qualifiers[0];
Class<? extends Annotation> annotationType = annotation.annotationType();
String[] beanNames = context.getBeanNamesForAnnotation(annotationType);
for (String beanName : beanNames) {
Class<?> beanType = context.getType(beanName);
if (token.isSupertypeOf(beanType)) {
instance = context.getBean(beanName, beanType);
break;
}
}
if (instance == null && NAME_QUALIFIER.contains(annotationType)) {
instance = context.getBean((String) AnnotationUtils.getValue(annotation));
}
return instance;
}
代码示例来源:origin: io.leangen.graphql/graphql-spqr-spring-boot-autoconfigure
Arrays.stream(context.getBeanNamesForAnnotation(qualifierType))
.filter(beanName -> type.isInstance(context.getBean(beanName)))
.findFirst()
代码示例来源:origin: leangen/graphql-spqr-spring-boot-starter
Arrays.stream(context.getBeanNamesForAnnotation(qualifierType))
.filter(beanName -> type.isInstance(context.getBean(beanName)))
.findFirst()
内容来源于网络,如有侵权,请联系作者删除!