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


Java Injectee.getParent方法代码示例

本文整理汇总了Java中org.glassfish.hk2.api.Injectee.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java Injectee.getParent方法的具体用法?Java Injectee.getParent怎么用?Java Injectee.getParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.glassfish.hk2.api.Injectee的用法示例。


在下文中一共展示了Injectee.getParent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolve

import org.glassfish.hk2.api.Injectee; //导入方法依赖的package包/类
@Override
public Object resolve(Injectee injectee, ServiceHandle<?> serviceHandle) {

	if (injectee.getRequiredType() instanceof Class) {

		TypeLiteral<?> typeLiteral = TypeLiteral.get(injectee.getRequiredType());
		Errors errors = new Errors(injectee.getParent());
		Key<?> key;
		try {
			key = Annotations.getKey(typeLiteral, (Member) injectee.getParent(),
					injectee.getParent().getDeclaredAnnotations(), errors);
		} catch (ErrorsException e) {
			errors.merge(e.getErrors());
			throw new ConfigurationException(errors.getMessages());
		}

		return injector.getInstance(key);
	}

	throw new IllegalStateException("Can't process injection point: " + injectee.getRequiredType());
}
 
开发者ID:bootique,项目名称:bootique-jersey-client,代码行数:22,代码来源:ClientGuiceInjectInjector.java

示例2: provide

import org.glassfish.hk2.api.Injectee; //导入方法依赖的package包/类
@Override
@PerLookup
@Visibility(DescriptorVisibility.LOCAL)
public T provide() {
    Injectee injectee = instantiationService.getInstantiationData().getParentInjectee();
    String   name;
    if (injectee == null) {
        log.warn("Creating metric with no injection context; Use the metric registry directly instead of dynamically creating it "
                 + "through HK2", new Exception());
        name = UUID.randomUUID().toString();
    } else {
        AnnotatedElement parent = injectee.getParent();
        if (parent instanceof Constructor) {
            parent = ((Constructor) parent).getParameters()[injectee.getPosition()];
        }
        if (parent instanceof Method) {
            parent = ((Method) parent).getParameters()[injectee.getPosition()];
        }
        name = nameService.getFormattedMetricName(parent, injectee.getInjecteeClass());
    }
    return metricSupplier.apply(name);
}
 
开发者ID:baharclerode,项目名称:dropwizard-hk2,代码行数:23,代码来源:MetricFactory.java

示例3: getQualifiers

import org.glassfish.hk2.api.Injectee; //导入方法依赖的package包/类
/**
 * NOTE: There can be only one {@link Annotation} that is a {@link Qualifier} or {@link BindingAnnotation}. 
 * They're the same but HK2 does not know about {@link BindingAnnotation}.
 * 
 * @see Qualifier
 * @see BindingAnnotation
 * @see javax.inject.Named
 * @see com.google.inject.name.Named
 */
private static Set<Annotation> getQualifiers(Injectee injectee) {
  // JSR 330's @Qualifier
  Set<Annotation> qualifiers = injectee.getRequiredQualifiers();
  if (!qualifiers.isEmpty()) {
    return qualifiers;
  }
  
  AnnotatedElement element = injectee.getParent();
  int position = injectee.getPosition();
  
  // Guice's @BindingAnnotation is the same as @Qualifier
  Annotation annotation = getBindingAnnotation(element, position);
  if (annotation != null) {
    return Collections.singleton(annotation);
  }
  
  return Collections.emptySet();
}
 
开发者ID:Squarespace,项目名称:jersey2-guice,代码行数:28,代码来源:BindingUtils.java


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