本文整理了Java中io.micronaut.inject.qualifiers.Qualifiers.byStereotype
方法的一些代码示例,展示了Qualifiers.byStereotype
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Qualifiers.byStereotype
方法的具体详情如下:
包路径:io.micronaut.inject.qualifiers.Qualifiers
类名称:Qualifiers
方法名:byStereotype
[英]Build a qualifier for the given annotation.
[中]为给定注释生成限定符。
代码示例来源:origin: micronaut-projects/micronaut-core
/**
* Processes the startup event and reads common ingress/outgress points to ensure Jackson can
* marshall the method arguments.
*
* @param startupEvent The startup event
*/
@EventListener
public void onStartup(StartupEvent startupEvent) {
processHttpMethods(
registry.getBeanDefinitions(Qualifiers.byStereotype(Client.class))
);
processHttpMethods(
registry.getBeanDefinitions(Qualifiers.byStereotype(Controller.class))
);
}
代码示例来源:origin: io.micronaut/runtime
private void refreshSubsetOfConfigurationProperties(Set<String> keySet) {
Collection<BeanRegistration<?>> registrations =
beanContext.getActiveBeanRegistrations(Qualifiers.byStereotype(ConfigurationProperties.class));
for (BeanRegistration<?> registration : registrations) {
BeanDefinition<?> definition = registration.getBeanDefinition();
Optional<String> value = definition.getValue(ConfigurationReader.class, "prefix", String.class);
if (value.isPresent()) {
String configPrefix = value.get();
if (keySet.stream().anyMatch(key -> key.startsWith(configPrefix))) {
beanContext.refreshBean(registration.getIdentifier());
}
}
}
}
代码示例来源:origin: micronaut-projects/micronaut-spring
@Override
public @Nonnull
String[] getBeanNamesForAnnotation(@Nonnull Class<? extends Annotation> annotationType) {
final String[] beanNamesForAnnotation = super.getBeanNamesForAnnotation(annotationType);
final Collection<BeanDefinition<?>> beanDefinitions = beanContext.getBeanDefinitions(Qualifiers.byStereotype(annotationType));
return ArrayUtils.concat(beansToNames(beanDefinitions), beanNamesForAnnotation);
}
代码示例来源:origin: io.micronaut/runtime
private void refreshAllConfigurationProperties() {
Collection<BeanRegistration<?>> registrations =
beanContext.getActiveBeanRegistrations(Qualifiers.byStereotype(ConfigurationProperties.class));
for (BeanRegistration<?> registration : registrations) {
beanContext.refreshBean(registration.getIdentifier());
}
}
代码示例来源:origin: io.micronaut/runtime
/**
* Finds a fallback method for the given context.
*
* @param context The context
* @return The fallback method if it is present
*/
public Optional<? extends MethodExecutionHandle<?, Object>> findFallbackMethod(MethodInvocationContext<Object, Object> context) {
Class<?> declaringType = context.getTarget().getClass();
Optional<? extends MethodExecutionHandle<?, Object>> result = beanContext
.findExecutionHandle(declaringType, Qualifiers.byStereotype(Fallback.class), context.getMethodName(), context.getArgumentTypes());
if (!result.isPresent()) {
Set<Class> allInterfaces = ReflectionUtils.getAllInterfaces(declaringType);
for (Class i : allInterfaces) {
result = beanContext
.findExecutionHandle(i, Qualifiers.byStereotype(Fallback.class), context.getMethodName(), context.getArgumentTypes());
if (result.isPresent()) {
return result;
}
}
}
return result;
}
代码示例来源:origin: io.micronaut/micronaut-spring
Qualifier<Object> micronautBeanQualifier;
if (micronautBeanQualifierType.isAnnotation()) {
micronautBeanQualifier = Qualifiers.byStereotype((Class<? extends Annotation>) micronautBeanQualifierType);
} else {
micronautBeanQualifier = Qualifiers.byType(micronautBeanQualifierType);
代码示例来源:origin: io.micronaut/spring
Qualifier<Object> micronautBeanQualifier;
if (micronautBeanQualifierType.isAnnotation()) {
micronautBeanQualifier = Qualifiers.byStereotype((Class<? extends Annotation>) micronautBeanQualifierType);
} else {
micronautBeanQualifier = Qualifiers.byType(micronautBeanQualifierType);
代码示例来源:origin: io.micronaut/router
/**
* Executed after the bean creation.
*/
@PostConstruct
public void process() {
Collection<BeanDefinition<?>> filterDefinitions = beanContext.getBeanDefinitions(Qualifiers.byStereotype(Filter.class));
for (BeanDefinition<?> beanDefinition : filterDefinitions) {
if (HttpClientFilter.class.isAssignableFrom(beanDefinition.getBeanType())) {
// ignore http client filters
continue;
}
String[] patterns = beanDefinition.getValue(Filter.class, String[].class).orElse(null);
if (ArrayUtils.isNotEmpty(patterns)) {
HttpMethod[] methods = beanDefinition.getValue(Filter.class, "methods", HttpMethod[].class).orElse(null);
String first = patterns[0];
FilterRoute filterRoute = addFilter(first, () -> beanContext.getBean((Class<HttpFilter>) beanDefinition.getBeanType()));
if (patterns.length > 1) {
for (int i = 1; i < patterns.length; i++) {
String pattern = patterns[i];
filterRoute.pattern(pattern);
}
}
if (ArrayUtils.isNotEmpty(methods)) {
filterRoute.methods(methods);
}
}
}
}
}
代码示例来源:origin: io.micronaut/inject
if (!typeArguments.isEmpty()) {
Class annotationType = typeArguments.get(0).getType();
Collection<BeanDefinition<?>> beanDefinitions = beanContext.getBeanDefinitions(Qualifiers.byStereotype(annotationType));
代码示例来源:origin: io.micronaut/micronaut-inject
if (!typeArguments.isEmpty()) {
final Argument<?> firstArgument = typeArguments.get(0);
Collection<BeanDefinition<?>> beanDefinitions = beanContext.getBeanDefinitions(Qualifiers.byStereotype((Class) firstArgument.getType()));
if (typeArguments.size() == 1) {
final Argument<?> annotation = typeArguments.get(0);
Collection<BeanDefinition<?>> beanDefinitions = beanContext.getBeanDefinitions(Qualifiers.byStereotype((Class) annotation.getType()));
内容来源于网络,如有侵权,请联系作者删除!