本文整理汇总了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());
}
示例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);
}
示例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();
}