Java源码示例:org.glassfish.jersey.server.model.Invocable

示例1
private Router getMockRouter(String methodName, Class<?>... parameterTypes) throws NoSuchMethodException {

        Invocable mockInvocable = PowerMock.createMock(Invocable.class);
        expect(mockInvocable.getHandlingMethod())
                .andReturn(DummyController.class.getDeclaredMethod(methodName, parameterTypes))
                .anyTimes();

        expect(mockInvocable.getHandler())
                .andReturn(MethodHandler.create(DummyController.class))
                .anyTimes();

        org.lambadaframework.jaxrs.model.ResourceMethod mockResourceMethod = PowerMock.createMock(org.lambadaframework.jaxrs.model.ResourceMethod
                .class);
        expect(mockResourceMethod.getInvocable())
                .andReturn(mockInvocable)
                .anyTimes();

        Router mockRouter = PowerMock.createMock(Router.class);
        expect(mockRouter.route(anyObject()))
                .andReturn(mockResourceMethod)
                .anyTimes();

        PowerMock.replayAll();
        return mockRouter;
    }
 
示例2
@Override
public void visitInvocable(final Invocable invocable) {
    methodDefaultStrategies.put(invocable.getHandlingMethod(), computeDefaultExecutionStrategy(invocable));

    validateRouteExecutionStrategyAnnotationIfPresent(
            invocable.getHandlingMethod(), invocable.getHandler().getHandlerClass(),
            id -> routeStrategies.computeIfAbsent(id, strategyFactory::get), resourceMethodDeque.peek(),
            errors);
}
 
示例3
private static HttpExecutionStrategy computeDefaultExecutionStrategy(final Invocable invocable) {
    final Parameter entityParam = invocable.getParameters().stream().filter(p -> p.getSource() == ENTITY)
            .findFirst()
            .orElse(null);

    final boolean consumesStreaming = entityParam != null &&
            Publisher.class.isAssignableFrom(entityParam.getRawType());
    final boolean consumesAsync = consumesStreaming ||
            (entityParam != null && Single.class.isAssignableFrom(entityParam.getRawType()));
    final boolean producesStreaming = Publisher.class.isAssignableFrom(invocable.getRawResponseType());
    final boolean producesAsync = producesStreaming ||
            Single.class.isAssignableFrom(invocable.getRawResponseType()) ||
            Completable.class.isAssignableFrom(invocable.getRawResponseType());

    if (!consumesAsync && !producesAsync) {
        // blocking-aggregated
        // HttpApiConversions/BlockingToStreamingService uses OFFLOAD_RECEIVE_DATA_STRATEGY because we are invoking
        // the service within a callback of Single<HttpRequest>, which may call the service on the eventloop.
        // Here we are not invoking the service as part of collecting the request payload,
        // so OFFLOAD_RECEIVE_META is sufficient.
        return OFFLOAD_RECEIVE_META;
    } else if (consumesAsync && !consumesStreaming && producesAsync && !producesStreaming) {
        // async-aggregated
        return OFFLOAD_RECEIVE_META_AND_SEND;
    } else {
        // default to async-streaming, as it has the most aggressive offloading strategy
        return OFFLOAD_ALL;
    }
}
 
示例4
private void validateMatchingDataset(Validator validator, MatchingDataset matchingDataset) throws MatchingDatasetArgumentValidationError {
    Set<ConstraintViolation<MatchingDataset>> validations = validator.validate(matchingDataset);
    if(!validations.isEmpty()) {
        final String errors = validations
                .stream().map(violation -> ConstraintMessage.getMessage(violation, Invocable.create(request -> null)))
                .collect(Collectors.joining(", "));

        throw new MatchingDatasetArgumentValidationError(String.format("Matching Dataset argument was not valid: %s", errors));
    }
}
 
示例5
@Override
public InvocationHandler create(Invocable invocable) {
    Class<?> returnType = invocable.getRawResponseType();
    if (handlers.containsKey(returnType)) {
        return injectionManager.createAndInitialize(handlers.get(returnType));
    }
    return null;
}
 
示例6
@Override
public InvocationHandler create(Invocable invocable) {
    Class<?> returnType = invocable.getRawResponseType();
    if (handlers.containsKey(returnType)) {
        return injectionManager.createAndInitialize(handlers.get(returnType));
    }
    return null;
}
 
示例7
@Override
public InvocationHandler create(Invocable method) {
    Class returnType = method.getRawResponseType();
    if(Publisher.class.isAssignableFrom(returnType) & !Collection.class.isAssignableFrom(returnType)){
        return injectionManager.createAndInitialize(AsyncInvocationHandler.class);
    }
    return null;
}
 
示例8
/**
 * Invoked prior to request invocation during {@link RequestEventListener#onEvent(RequestEvent)}
 * where the event type is {@link RequestEvent.Type#REQUEST_MATCHED}
 *
 * <p>Adds the tags {@link #RESOURCE_CLASS} and {@link #RESOURCE_METHOD}. Override or use {@link
 * #NOOP} to change this behavior.
 */
protected void requestMatched(RequestEvent event, SpanCustomizer customizer) {
  ResourceMethod method = event.getContainerRequest().getUriInfo().getMatchedResourceMethod();
  if (method == null) return; // This case is extremely odd as this is called on REQUEST_MATCHED!
  Invocable i = method.getInvocable();
  customizer.tag(RESOURCE_CLASS, i.getHandler().getHandlerClass().getSimpleName());
  customizer.tag(RESOURCE_METHOD, i.getHandlingMethod().getName());
}
 
示例9
public Invocable getInvocable() {
    return proxied.getInvocable();
}
 
示例10
@Override
public InvocationHandler create(Invocable resourceMethod) {
        return new MyIncovationHandler();
}
 
示例11
@Override
public InvocationHandler create(Invocable resourceMethod) {
        return new MyIncovationHandler();
}
 
示例12
@Override
public InvocationHandler create(Invocable resourceMethod) {
        return new DirectMyIncovationHandler();
}
 
示例13
@Override
public InvocationHandler create(Invocable resourceMethod) {
        return new MyIncovationHandler();
}
 
示例14
@Override
public InvocationHandler create(Invocable resourceMethod) {
        return new MyIncovationHandler();
}
 
示例15
@Override
public InvocationHandler create(Invocable resourceMethod) {
        return new MyIncovationHandler();
}
 
示例16
@Override
public InvocationHandler create(Invocable resourceMethod) {
        return new DirectMyIncovationHandler();
}
 
示例17
@Override
public InvocationHandler create(Invocable resourceMethod) {
        return new MyIncovationHandler();
}
 
示例18
@Override
public InvocationHandler create(Invocable resourceMethod) {
        return new MyIncovationHandler();
}
 
示例19
@Override
public InvocationHandler create(Invocable resourceMethod) {
        return new MyIncovationHandler();
}
 
示例20
@Override
public InvocationHandler create(Invocable resourceMethod) {
        return new MyIncovationHandler();
}
 
示例21
@Override
public InvocationHandler create(Invocable invocable) {
	return createInvocationHandler(invocable.getHandlingMethod());
}