Search in sources :

Example 1 with InjecteeImpl

use of org.glassfish.jersey.internal.inject.InjecteeImpl 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;
    }
}
Also used : InjecteeImpl(org.glassfish.jersey.internal.inject.InjecteeImpl) Factory(org.glassfish.hk2.api.Factory) ForeignDescriptorImpl(org.glassfish.jersey.internal.inject.ForeignDescriptorImpl)

Example 2 with InjecteeImpl

use of org.glassfish.jersey.internal.inject.InjecteeImpl in project jersey by jersey.

the class DelegatedInjectionValueSupplierProvider method getInjectee.

/**
     * Creates a new object {@link Injectee} corresponding to the injecting point. The injectee contains basic information
     * about the injection point types and {@link ForeignDescriptor} of the underlying DI provider to make delegated injection
     * resolver as simple as possible.
     *
     * @param parameter jersey-like parameter corresponding to one resource-method's parameter.
     * @return injectee instance as a source of the information about the injecting point.
     */
private Injectee getInjectee(Parameter parameter) {
    InjecteeImpl injectee = new InjecteeImpl();
    injectee.setRequiredType(parameter.getType());
    injectee.setInjecteeClass(parameter.getRawType());
    ForeignDescriptor proxyDescriptor = descriptorCache.apply(parameter);
    if (proxyDescriptor != null) {
        injectee.setInjecteeDescriptor(proxyDescriptor);
    }
    return injectee;
}
Also used : InjecteeImpl(org.glassfish.jersey.internal.inject.InjecteeImpl) ForeignDescriptor(org.glassfish.jersey.internal.inject.ForeignDescriptor)

Aggregations

InjecteeImpl (org.glassfish.jersey.internal.inject.InjecteeImpl)2 Factory (org.glassfish.hk2.api.Factory)1 ForeignDescriptor (org.glassfish.jersey.internal.inject.ForeignDescriptor)1 ForeignDescriptorImpl (org.glassfish.jersey.internal.inject.ForeignDescriptorImpl)1