本文整理汇总了Java中javax.inject.Named.value方法的典型用法代码示例。如果您正苦于以下问题:Java Named.value方法的具体用法?Java Named.value怎么用?Java Named.value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.inject.Named
的用法示例。
在下文中一共展示了Named.value方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import javax.inject.Named; //导入方法依赖的package包/类
@Nullable
@Override
public AnnotatedMethod process(Method method) {
Named named = method.getAnnotation(Named.class);
if (named != null) {
Class[] parameterTypes = Reflection.getParameterTypes(method);
String[] parameterNames = new String[parameterTypes.length];
AnnotatedMethod res = new AnnotatedMethod(method, named.value(), parameterTypes, parameterNames);
Annotation[][] declaredParameterAnnotations = Reflection.getParameterAnnotations(method);
NEXT_PARAM:
for (int i = 0; i < declaredParameterAnnotations.length; i++) {
Annotation[] annotations = declaredParameterAnnotations[i];
for (Annotation annotation : annotations) {
if (annotation instanceof Named) {
String name = ((Named) annotation).value();
parameterNames[i] = name;
continue NEXT_PARAM;
}
}
//if we come here, no annotation was found -> not good!
LoggerFactory.getLogger(method.getDeclaringClass()).error("{}.{}: {}. Parameter is unnamed and may cause invocation failure at runtime ", method.getDeclaringClass().getSimpleName(), res, i);
}
return res;
}
return null;
}
示例2: process
import javax.inject.Named; //导入方法依赖的package包/类
@Nullable
@Override
public <T> AnnotatedComponent<T> process(Scope scope, Class<T> clazz) {
Singleton controller = clazz.getAnnotation(Singleton.class);
Named requestMapping = clazz.getAnnotation(Named.class);
if (controller != null) {
String name = requestMapping == null ? "" : requestMapping.value();
return new AnnotatedComponent(clazz, name, ComponentType.CONTROLLER);
}
return null;
}
示例3: process
import javax.inject.Named; //导入方法依赖的package包/类
@Nullable
@Override
public <T> AnnotatedComponent<T> process(Scope scope, Class<T> clazz) {
Named widget = clazz.getAnnotation(Named.class);
if (widget != null) {
String name = widget.value();
return new AnnotatedComponent(clazz, name, ComponentType.BEAN);
}
return null;
}
示例4: getInjecteeName
import javax.inject.Named; //导入方法依赖的package包/类
public static String getInjecteeName(InstantiationService instantiationService) {
InstantiationData instantiationData = instantiationService.getInstantiationData();
Injectee parentInjectee = instantiationData.getParentInjectee();
String name = null;
Optional<Annotation> namedAnnotation = parentInjectee.getRequiredQualifiers().stream().filter(Named.class::isInstance).findFirst();
if (namedAnnotation.isPresent()) {
Named named = (Named) namedAnnotation.get();
name = named.value();
}
if (name == null) {
throw new RuntimeException("Named factory bound without name.");
}
return name;
}
示例5: InjectionDefinition
import javax.inject.Named; //导入方法依赖的package包/类
public InjectionDefinition(@NotNull Element element, boolean isProvider) {
injectionType = element.asType().toString();
final Named named = element.getAnnotation(Named.class);
this.named = (named != null) ? named.value() : null;
this.isProvider = isProvider;
}