本文整理了Java中io.micronaut.inject.qualifiers.Qualifiers.byAnnotation
方法的一些代码示例,展示了Qualifiers.byAnnotation
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Qualifiers.byAnnotation
方法的具体详情如下:
包路径:io.micronaut.inject.qualifiers.Qualifiers
类名称:Qualifiers
方法名:byAnnotation
[英]Build a qualifier for the given annotation.
[中]
代码示例来源:origin: io.micronaut/router
private UriRoute buildBeanRoute(HttpMethod httpMethod, String uri, BeanDefinition<?> beanDefinition, ExecutableMethod<?, ?> method) {
io.micronaut.context.Qualifier<?> qualifier = beanDefinition.getAnnotationTypeByStereotype(Qualifier.class).map(aClass -> Qualifiers.byAnnotation(beanDefinition, aClass)).orElse(null);
MethodExecutionHandle<?, Object> executionHandle = executionHandleLocator.findExecutionHandle(beanDefinition.getBeanType(), qualifier, method.getMethodName(), method.getArgumentTypes())
.orElseThrow(() -> new RoutingException("No such route: " + beanDefinition.getBeanType().getName() + "." + method));
return buildRoute(httpMethod, uri, executionHandle);
}
代码示例来源:origin: io.micronaut/inject
private Qualifier resolveQualifier(BeanResolutionContext resolutionContext, Argument argument) {
Qualifier qualifier = null;
AnnotationMetadata annotationMetadata = argument.getAnnotationMetadata();
Optional<Class<? extends Annotation>> qualifierType = annotationMetadata.getAnnotationTypeByStereotype(javax.inject.Qualifier.class);
if (qualifierType.isPresent()) {
qualifier = Qualifiers.byAnnotation(
annotationMetadata,
qualifierType.get()
);
}
if (qualifier == null) {
Class<?>[] byType = annotationMetadata.hasDeclaredAnnotation(Type.class) ? annotationMetadata.getValue(Type.class, Class[].class).orElse(null) : null;
if (byType != null) {
qualifier = Qualifiers.byType(byType);
} else {
Optional<Qualifier> optional = resolutionContext.get(javax.inject.Qualifier.class.getName(), Map.class)
.map(map -> (Qualifier) map.get(argument));
qualifier = optional.orElse(null);
if (qualifier == null && isIterable() && argument.isAnnotationPresent(Parameter.class)) {
qualifier = optional.orElseGet(() -> {
final Optional<String> n = resolutionContext.get(Named.class.getName(), String.class);
return n.map(Qualifiers::byName).orElse(null);
});
}
}
}
return qualifier;
}
代码示例来源:origin: io.micronaut/inject
/**
* Resolves the proxied bean instance for this bean.
*
* @param beanContext The {@link BeanContext}
* @return The proxied bean
*/
@SuppressWarnings({"unchecked", "unused"})
@Internal
protected final Object getProxiedBean(BeanContext beanContext) {
DefaultBeanContext defaultBeanContext = (DefaultBeanContext) beanContext;
Optional<String> qualifier = getAnnotationMetadata().getAnnotationNameByStereotype(javax.inject.Qualifier.class);
return defaultBeanContext.getProxyTargetBean(getBeanType(), (Qualifier<T>) qualifier.map(q -> Qualifiers.byAnnotation(getAnnotationMetadata(), q)).orElse(null));
}
代码示例来源:origin: io.micronaut/micronaut-inject
private Qualifier resolveQualifier(BeanResolutionContext resolutionContext, Argument argument) {
Qualifier qualifier = null;
AnnotationMetadata annotationMetadata = argument.getAnnotationMetadata();
Optional<Class<? extends Annotation>> qualifierType = annotationMetadata.getAnnotationTypeByStereotype(javax.inject.Qualifier.class);
if (qualifierType.isPresent()) {
qualifier = Qualifiers.byAnnotation(
annotationMetadata,
qualifierType.get()
);
}
if (qualifier == null) {
Class<?>[] byType = annotationMetadata.hasDeclaredAnnotation(Type.class) ? annotationMetadata.getValue(Type.class, Class[].class).orElse(null) : null;
if (byType != null) {
qualifier = Qualifiers.byType(byType);
} else {
Optional<Qualifier> optional = resolutionContext.get(javax.inject.Qualifier.class.getName(), Map.class)
.map(map -> (Qualifier) map.get(argument));
qualifier = optional.orElse(null);
if (qualifier == null && isIterable() && argument.isAnnotationPresent(Parameter.class)) {
qualifier = optional.orElseGet(() -> {
final Optional<String> n = resolutionContext.get(Named.class.getName(), String.class);
return n.map(Qualifiers::byName).orElse(null);
});
}
}
}
return qualifier;
}
代码示例来源:origin: io.micronaut/micronaut-inject
/**
* Resolves the proxied bean instance for this bean.
*
* @param beanContext The {@link BeanContext}
* @return The proxied bean
*/
@SuppressWarnings({"unchecked", "unused"})
@Internal
protected final Object getProxiedBean(BeanContext beanContext) {
DefaultBeanContext defaultBeanContext = (DefaultBeanContext) beanContext;
Optional<String> qualifier = getAnnotationMetadata().getAnnotationNameByStereotype(javax.inject.Qualifier.class);
return defaultBeanContext.getProxyTargetBean(getBeanType(), (Qualifier<T>) qualifier.map(q -> Qualifiers.byAnnotation(getAnnotationMetadata(), q)).orElse(null));
}
代码示例来源:origin: io.micronaut/micronaut-inject
qualifier = (Qualifier<T>) optional.map(name -> Qualifiers.byAnnotation(beanDefinition, name)).orElse(null);
BeanKey qualifierKey = new BeanKey<>(createdType, Qualifiers.byAnnotation(beanDefinition, annotation.getName()));
if (!qualifierKey.equals(createdBeanKey)) {
singletonObjects.put(qualifierKey, registration);
代码示例来源:origin: io.micronaut/inject
qualifier = (Qualifier<T>) optional.map(name -> Qualifiers.byAnnotation(beanDefinition, name)).orElse(null);
BeanKey qualifierKey = new BeanKey<>(createdType, Qualifiers.byAnnotation(beanDefinition, annotation.getName()));
if (!qualifierKey.equals(createdBeanKey)) {
singletonObjects.put(qualifierKey, registration);
代码示例来源:origin: io.micronaut/inject
} else {
Optional<String> qualifierName = dependentCandidate.getAnnotationNameByStereotype(javax.inject.Qualifier.class);
optional = qualifierName.map(name -> Qualifiers.byAnnotation(dependentCandidate, name));
代码示例来源:origin: io.micronaut/micronaut-inject
} else {
Optional<String> qualifierName = dependentCandidate.getAnnotationNameByStereotype(javax.inject.Qualifier.class);
optional = qualifierName.map(name -> Qualifiers.byAnnotation(dependentCandidate, name));
代码示例来源:origin: io.micronaut/runtime
io.micronaut.context.Qualifier<Object> qualifer = beanDefinition
.getAnnotationTypeByStereotype(Qualifier.class)
.map(type -> Qualifiers.byAnnotation(beanDefinition, type))
.orElse(null);
代码示例来源:origin: micronaut-projects/micronaut-spring
return Qualifiers.byAnnotation(definition, annotationName);
代码示例来源:origin: micronaut-projects/micronaut-spring
if (q.isPresent()) {
try {
return beanContext.getBean(type, Qualifiers.byAnnotation(annotationMetadata, q.get()));
} catch (NoSuchBeanException e) {
throw new NoSuchBeanDefinitionException(type, e.getMessage());
内容来源于网络,如有侵权,请联系作者删除!