org.glassfish.jersey.server.model.Invocable Java Examples
The following examples show how to use
org.glassfish.jersey.server.model.Invocable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HandlerTest.java From lambadaframework with MIT License | 6 votes |
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; }
Example #2
Source File: JerseyRouteExecutionStrategyUtils.java From servicetalk with Apache License 2.0 | 5 votes |
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; } }
Example #3
Source File: EventParser.java From brave with Apache License 2.0 | 5 votes |
/** * 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()); }
Example #4
Source File: AsyncInvocationHandler.java From micro-server with Apache License 2.0 | 5 votes |
@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; }
Example #5
Source File: SingleInvocationHandlerProvider.java From rx-jersey with MIT License | 5 votes |
@Override public InvocationHandler create(Invocable invocable) { Class<?> returnType = invocable.getRawResponseType(); if (handlers.containsKey(returnType)) { return injectionManager.createAndInitialize(handlers.get(returnType)); } return null; }
Example #6
Source File: MaybeInvocationHandlerProvider.java From rx-jersey with MIT License | 5 votes |
@Override public InvocationHandler create(Invocable invocable) { Class<?> returnType = invocable.getRawResponseType(); if (handlers.containsKey(returnType)) { return injectionManager.createAndInitialize(handlers.get(returnType)); } return null; }
Example #7
Source File: JerseyRouteExecutionStrategyUtils.java From servicetalk with Apache License 2.0 | 5 votes |
@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); }
Example #8
Source File: ResourceMethod.java From lambadaframework with MIT License | 4 votes |
public Invocable getInvocable() { return proxied.getInvocable(); }
Example #9
Source File: CustomResourceInvocationHandlerProvider.java From micro-server with Apache License 2.0 | 4 votes |
@Override public InvocationHandler create(Invocable resourceMethod) { return new MyIncovationHandler(); }
Example #10
Source File: CustomResourceInvocationHandlerProvider.java From micro-server with Apache License 2.0 | 4 votes |
@Override public InvocationHandler create(Invocable resourceMethod) { return new MyIncovationHandler(); }
Example #11
Source File: DirectCustomResourceInvocationHandlerProvider.java From micro-server with Apache License 2.0 | 4 votes |
@Override public InvocationHandler create(Invocable resourceMethod) { return new DirectMyIncovationHandler(); }
Example #12
Source File: CustomResourceInvocationHandlerProvider.java From micro-server with Apache License 2.0 | 4 votes |
@Override public InvocationHandler create(Invocable resourceMethod) { return new MyIncovationHandler(); }
Example #13
Source File: CustomResourceInvocationHandlerProvider.java From micro-server with Apache License 2.0 | 4 votes |
@Override public InvocationHandler create(Invocable resourceMethod) { return new MyIncovationHandler(); }
Example #14
Source File: CustomResourceInvocationHandlerProvider.java From micro-server with Apache License 2.0 | 4 votes |
@Override public InvocationHandler create(Invocable resourceMethod) { return new MyIncovationHandler(); }
Example #15
Source File: DirectCustomResourceInvocationHandlerProvider.java From micro-server with Apache License 2.0 | 4 votes |
@Override public InvocationHandler create(Invocable resourceMethod) { return new DirectMyIncovationHandler(); }
Example #16
Source File: CustomResourceInvocationHandlerProvider.java From micro-server with Apache License 2.0 | 4 votes |
@Override public InvocationHandler create(Invocable resourceMethod) { return new MyIncovationHandler(); }
Example #17
Source File: IdentityDatasetArgumentResolver.java From verify-service-provider with MIT License | 4 votes |
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)); } }
Example #18
Source File: CustomResourceInvocationHandlerProvider.java From micro-server with Apache License 2.0 | 4 votes |
@Override public InvocationHandler create(Invocable resourceMethod) { return new MyIncovationHandler(); }
Example #19
Source File: CustomResourceInvocationHandlerProvider.java From micro-server with Apache License 2.0 | 4 votes |
@Override public InvocationHandler create(Invocable resourceMethod) { return new MyIncovationHandler(); }
Example #20
Source File: CustomResourceInvocationHandlerProvider.java From micro-server with Apache License 2.0 | 4 votes |
@Override public InvocationHandler create(Invocable resourceMethod) { return new MyIncovationHandler(); }
Example #21
Source File: JerseyServerContainer.java From JaxRSProviders with Apache License 2.0 | 4 votes |
@Override public InvocationHandler create(Invocable invocable) { return createInvocationHandler(invocable.getHandlingMethod()); }