当前位置: 首页>>代码示例>>Java>>正文


Java Named.value方法代码示例

本文整理汇总了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;
}
 
开发者ID:worldiety,项目名称:homunculus,代码行数:28,代码来源:EEControllerEndpoint.java

示例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;
}
 
开发者ID:worldiety,项目名称:homunculus,代码行数:12,代码来源:EEComponentController.java

示例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;
}
 
开发者ID:worldiety,项目名称:homunculus,代码行数:11,代码来源:HCFComponent.java

示例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;
}
 
开发者ID:code-obos,项目名称:servicebuilder,代码行数:16,代码来源:Hk2Helper.java

示例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;
}
 
开发者ID:groupon,项目名称:dependency-injection-checks,代码行数:7,代码来源:DuplicateInjectionInHierarchyCheck.java


注:本文中的javax.inject.Named.value方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。