Search in sources :

Example 1 with ParamValueFactoryWithSource

use of org.glassfish.jersey.server.spi.internal.ParamValueFactoryWithSource in project jersey by jersey.

the class JavaResourceMethodDispatcherProvider method create.

@Override
public ResourceMethodDispatcher create(final Invocable resourceMethod, final InvocationHandler invocationHandler, final ConfiguredValidator validator) {
    final List<ParamValueFactoryWithSource<?>> valueProviders = ParameterValueHelper.createValueProviders(injectionManager, resourceMethod);
    final Class<?> returnType = resourceMethod.getHandlingMethod().getReturnType();
    ResourceMethodDispatcher resourceMethodDispatcher = null;
    if (Response.class.isAssignableFrom(returnType)) {
        resourceMethodDispatcher = new ResponseOutInvoker(resourceMethod, invocationHandler, valueProviders, validator);
    } else if (returnType != void.class) {
        if (returnType == Object.class || GenericEntity.class.isAssignableFrom(returnType)) {
            resourceMethodDispatcher = new ObjectOutInvoker(resourceMethod, invocationHandler, valueProviders, validator);
        } else {
            resourceMethodDispatcher = new TypeOutInvoker(resourceMethod, invocationHandler, valueProviders, validator);
        }
    } else {
        // return type is void
        int i = 0;
        for (final Parameter parameter : resourceMethod.getParameters()) {
            if (SseEventSink.class.equals(parameter.getRawType())) {
                resourceMethodDispatcher = new SseEventSinkInvoker(resourceMethod, invocationHandler, valueProviders, validator, i);
                break;
            }
            i++;
        }
        if (resourceMethodDispatcher == null) {
            resourceMethodDispatcher = new VoidOutInvoker(resourceMethod, invocationHandler, valueProviders, validator);
        }
    }
    // Inject validator.
    injectionManager.inject(resourceMethodDispatcher);
    return resourceMethodDispatcher;
}
Also used : SseEventSink(javax.ws.rs.sse.SseEventSink) ResourceMethodDispatcher(org.glassfish.jersey.server.spi.internal.ResourceMethodDispatcher) Parameter(org.glassfish.jersey.server.model.Parameter) ParamValueFactoryWithSource(org.glassfish.jersey.server.spi.internal.ParamValueFactoryWithSource)

Aggregations

SseEventSink (javax.ws.rs.sse.SseEventSink)1 Parameter (org.glassfish.jersey.server.model.Parameter)1 ParamValueFactoryWithSource (org.glassfish.jersey.server.spi.internal.ParamValueFactoryWithSource)1 ResourceMethodDispatcher (org.glassfish.jersey.server.spi.internal.ResourceMethodDispatcher)1