@Override public Stage.Continuation<DATA> apply(DATA data) { return Continuation.of(transformation.apply(data), nextStage); } }
@Override public Stage.Continuation<DATA> apply(DATA data) { return Continuation.of(transformation.apply(data), nextStage); } }
/** * {@inheritDoc} * <p/> * Routing stage navigates through the nested {@link Router routing hierarchy} * using a depth-first transformation strategy until a request-to-response * inflector is {@link org.glassfish.jersey.process.internal.Inflecting found on * a leaf stage node}, in which case the request routing is terminated and an * {@link org.glassfish.jersey.process.Inflector inflector} (if found) is pushed * to the {@link RoutingContext routing context}. */ @Override public Continuation<RequestProcessingContext> apply(final RequestProcessingContext context) { final ContainerRequest request = context.request(); context.triggerEvent(RequestEvent.Type.MATCHING_START); final TracingLogger tracingLogger = TracingLogger.getInstance(request); final long timestamp = tracingLogger.timestamp(ServerTraceEvent.MATCH_SUMMARY); try { final RoutingResult result = _apply(context, routingRoot); Stage<RequestProcessingContext> nextStage = null; if (result.endpoint != null) { context.routingContext().setEndpoint(result.endpoint); nextStage = getDefaultNext(); } return Continuation.of(result.context, nextStage); } finally { tracingLogger.logDuration(ServerTraceEvent.MATCH_SUMMARY, timestamp); } }
/** * {@inheritDoc} * <p/> * Routing stage navigates through the nested {@link Router routing hierarchy} * using a depth-first transformation strategy until a request-to-response * inflector is {@link org.glassfish.jersey.process.internal.Inflecting found on * a leaf stage node}, in which case the request routing is terminated and an * {@link org.glassfish.jersey.process.Inflector inflector} (if found) is pushed * to the {@link RoutingContext routing context}. */ @Override public Continuation<RequestProcessingContext> apply(final RequestProcessingContext context) { final ContainerRequest request = context.request(); context.triggerEvent(RequestEvent.Type.MATCHING_START); final TracingLogger tracingLogger = TracingLogger.getInstance(request); final long timestamp = tracingLogger.timestamp(ServerTraceEvent.MATCH_SUMMARY); try { final RoutingResult result = _apply(context, routingRoot); Stage<RequestProcessingContext> nextStage = null; if (result.endpoint != null) { context.routingContext().setEndpoint(result.endpoint); nextStage = getDefaultNext(); } return Continuation.of(result.context, nextStage); } finally { tracingLogger.logDuration(ServerTraceEvent.MATCH_SUMMARY, timestamp); } }
/** * Run the data through a chain of stages identified by the root stage. * * If an inflector is found in the leaf stage, it's reference is set into the {@code inflectorRef} * parameter. * * @param <DATA> processed data type. * @param data data to be processed. * @param rootStage root stage of the stage chain. * @param inflectorRef a mutable reference to an inflector. * @return processing result. */ public static <DATA, RESULT, T extends Inflector<DATA, RESULT>> DATA process( DATA data, Stage<DATA> rootStage, Ref<T> inflectorRef) { Stage<DATA> lastStage = rootStage; Stage.Continuation<DATA> continuation = Stage.Continuation.of(data, lastStage); while (continuation.next() != null) { lastStage = continuation.next(); continuation = lastStage.apply(continuation.result()); } inflectorRef.set(Stages.<DATA, RESULT, T>extractInflector(lastStage)); return continuation.result(); }
/** * Run the data through a chain of stages identified by the root stage. * * If an inflector is found in the leaf stage, it's reference is set into the {@code inflectorRef} * parameter. * * @param <DATA> processed data type. * @param data data to be processed. * @param rootStage root stage of the stage chain. * @param inflectorRef a mutable reference to an inflector. * @return processing result. */ public static <DATA, RESULT, T extends Inflector<DATA, RESULT>> DATA process( DATA data, Stage<DATA> rootStage, Ref<T> inflectorRef) { Stage<DATA> lastStage = rootStage; Stage.Continuation<DATA> continuation = Stage.Continuation.of(data, lastStage); while (continuation.next() != null) { lastStage = continuation.next(); continuation = lastStage.apply(continuation.result()); } inflectorRef.set(Stages.<DATA, RESULT, T>extractInflector(lastStage)); return continuation.result(); }
@Override public Continuation<ClientRequest> apply(ClientRequest requestContext) { for (ClientRequestFilter filter : requestFilters) { try { filter.filter(requestContext); final Response abortResponse = requestContext.getAbortResponse(); if (abortResponse != null) { throw new AbortException(new ClientResponse(requestContext, abortResponse)); } } catch (IOException ex) { throw new ProcessingException(ex); } } return Continuation.of(requestContext, getDefaultNext()); } }
@Override public Continuation<ClientResponse> apply(ClientResponse responseContext) { try { for (ClientResponseFilter filter : filters) { filter.filter(responseContext.getRequestContext(), responseContext); } } catch (IOException ex) { InboundJaxrsResponse response = new InboundJaxrsResponse(responseContext, null); throw new ResponseProcessingException(response, ex); } return Continuation.of(responseContext, getDefaultNext()); } }
/** * Run the data through a chain of stages identified by the root stage. * * @param <DATA> processed data type. * @param data data to be processed. * @param rootStage root stage of the stage chain. * @return processing result. */ public static <DATA> DATA process(DATA data, Stage<DATA> rootStage) { Stage.Continuation<DATA> continuation = Stage.Continuation.of(data, rootStage); Stage<DATA> currentStage; while ((currentStage = continuation.next()) != null) { continuation = currentStage.apply(continuation.result()); } return continuation.result(); }
/** * Run the data through a chain of stages identified by the root stage. * * @param <DATA> processed data type. * @param data data to be processed. * @param rootStage root stage of the stage chain. * @return processing result. */ public static <DATA> DATA process(DATA data, Stage<DATA> rootStage) { Stage.Continuation<DATA> continuation = Stage.Continuation.of(data, rootStage); Stage<DATA> currentStage; while ((currentStage = continuation.next()) != null) { continuation = currentStage.apply(continuation.result()); } return continuation.result(); }
@Override public Continuation<ClientRequest> apply(ClientRequest requestContext) { for (ClientRequestFilter filter : requestFilters) { try { filter.filter(requestContext); final Response abortResponse = requestContext.getAbortResponse(); if (abortResponse != null) { throw new AbortException(new ClientResponse(requestContext, abortResponse)); } } catch (IOException ex) { throw new ProcessingException(ex); } } return Continuation.of(requestContext, getDefaultNext()); } }
@Override public Continuation<ClientRequest> apply(ClientRequest requestContext) { for (ClientRequestFilter filter : requestFilters) { try { filter.filter(requestContext); final Response abortResponse = requestContext.getAbortResponse(); if (abortResponse != null) { throw new AbortException(new ClientResponse(requestContext, abortResponse)); } } catch (IOException ex) { throw new ProcessingException(ex); } } return Continuation.of(requestContext, getDefaultNext()); } }
@Override public Continuation<ClientResponse> apply(ClientResponse responseContext) { try { for (ClientResponseFilter filter : filters) { filter.filter(responseContext.getRequestContext(), responseContext); } } catch (IOException ex) { InboundJaxrsResponse response = new InboundJaxrsResponse(responseContext, null); throw new ResponseProcessingException(response, ex); } return Continuation.of(responseContext, getDefaultNext()); } }
@Override public Continuation<ClientResponse> apply(ClientResponse responseContext) { try { for (ClientResponseFilter filter : filters) { filter.filter(responseContext.getRequestContext(), responseContext); } } catch (IOException ex) { InboundJaxrsResponse response = new InboundJaxrsResponse(responseContext, null); throw new ResponseProcessingException(response, ex); } return Continuation.of(responseContext, getDefaultNext()); } }
@Override public Continuation<RequestProcessingContext> apply(final RequestProcessingContext processingContext) { final Endpoint endpoint = processingContext.routingContext().getEndpoint(); return endpoint != null ? Continuation.of(processingContext, Stages.asStage(endpoint)) : Continuation.of(processingContext); } }
@Override public Continuation apply(Object o) { //noinspection unchecked return Continuation.of(o, getDefaultNext()); } };
@Override public Stage.Continuation<DATA> apply(DATA request) { return Continuation.of(request); } }
@Override public Continuation apply(Object o) { //noinspection unchecked return Continuation.of(o, getDefaultNext()); } };
@Override public Continuation<RequestProcessingContext> apply(final RequestProcessingContext processingContext) { final Endpoint endpoint = processingContext.routingContext().getEndpoint(); return endpoint != null ? Continuation.of(processingContext, Stages.asStage(endpoint)) : Continuation.of(processingContext); } }
@Override public Stage.Continuation<DATA> apply(DATA request) { return Continuation.of(request); } }