use of org.glassfish.hk2.api.ServiceHandle in project jersey by jersey.
the class InjectionResolverWrapper method resolve.
@Override
public Object resolve(Injectee injectee, ServiceHandle root) {
InjecteeImpl injecteeWrapper = new InjecteeImpl();
injecteeWrapper.setRequiredType(injectee.getRequiredType());
injecteeWrapper.setParent(injectee.getParent());
injecteeWrapper.setRequiredQualifiers(injectee.getRequiredQualifiers());
injecteeWrapper.setOptional(injectee.isOptional());
injecteeWrapper.setPosition(injectee.getPosition());
injecteeWrapper.setFactory(ReflectionHelper.isSubClassOf(injectee.getRequiredType(), Factory.class));
injecteeWrapper.setInjecteeDescriptor(new ForeignDescriptorImpl(injectee.getInjecteeDescriptor()));
Object instance = jerseyResolver.resolve(injecteeWrapper);
if (injecteeWrapper.isFactory()) {
return asFactory(instance);
} else {
return instance;
}
}
use of org.glassfish.hk2.api.ServiceHandle in project jersey by jersey.
the class ContextInjectionResolverImpl method resolve.
@Override
public Object resolve(Injectee injectee, ServiceHandle<?> root) {
Type requiredType = injectee.getRequiredType();
boolean isHk2Factory = ReflectionHelper.isSubClassOf(requiredType, Factory.class);
Injectee newInjectee;
if (isHk2Factory) {
newInjectee = getFactoryInjectee(injectee, ReflectionHelper.getTypeArgument(requiredType, 0));
} else {
newInjectee = foreignRequestScopedInjecteeCache.apply(injectee);
}
ActiveDescriptor<?> ad = descriptorCache.apply(newInjectee);
if (ad != null) {
final ServiceHandle handle = serviceLocator.getServiceHandle(ad, newInjectee);
if (isHk2Factory) {
return asFactory(handle);
} else {
return handle.getService();
}
}
return null;
}
Aggregations