Package org.glassfish.jersey.message.internal

Examples of org.glassfish.jersey.message.internal.TracingLogger$Event


     *
     * @param request container request instance to get runtime properties
     *                to check if tracing support is enabled for the request.
     */
    public static void logStart(ContainerRequest request) {
        TracingLogger tracingLogger = TracingLogger.getInstance(request);
        if (tracingLogger.isLogEnabled(ServerTraceEvent.START)) {
            StringBuilder textSB = new StringBuilder();
            textSB.append(String.format("baseUri=[%s] requestUri=[%s] method=[%s] authScheme=[%s]",
                    request.getBaseUri(), request.getRequestUri(), request.getMethod(),
                    toStringOrNA(request.getSecurityContext().getAuthenticationScheme())));
            for (String header : SUMMARY_HEADERS) {
                textSB.append(String.format(" %s=%s", header, toStringOrNA(request.getRequestHeaders().get(header))));
            }
            tracingLogger.log(ServerTraceEvent.START, textSB.toString());
        }
        if (tracingLogger.isLogEnabled(ServerTraceEvent.START_HEADERS)) {
            StringBuilder textSB = new StringBuilder();
            for (String header : request.getRequestHeaders().keySet()) {
                if (!SUMMARY_HEADERS.contains(header)) {
                    textSB.append(String.format(" %s=%s", header, toStringOrNA(request.getRequestHeaders().get(header))));
                }
            }
            if (textSB.length() > 0) {
                textSB.insert(0, "Other request headers:");
            }
            tracingLogger.log(ServerTraceEvent.START_HEADERS, textSB.toString());
        }
    }
View Full Code Here


    @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 TransformableData<RequestProcessingContext, ContainerResponse> result = _apply(context, routingRoot);

            Stage<RequestProcessingContext> nextStage = null;
            if (result.hasInflector()) {
                context.routingContext().setInflector(result.inflector());
                nextStage = getDefaultNext();
            }

            return Continuation.of(result.data(), nextStage);
        } finally {
            tracingLogger.logDuration(ServerTraceEvent.MATCH_SUMMARY, timestamp);
        }
    }
View Full Code Here

        Iterable<ContainerRequestFilter> sortedRequestFilters;
        final boolean postMatching = responseFilters == null;

        final ContainerRequest request = context.request();

        final TracingLogger tracingLogger = TracingLogger.getInstance(request);
        if (postMatching) {
            // post-matching
            final ArrayList<Iterable<RankedProvider<ContainerRequestFilter>>> rankedProviders =
                    new ArrayList<>(2);
            rankedProviders.add(requestFilters);
            rankedProviders.add(request.getRequestFilters());
            sortedRequestFilters = Providers.mergeAndSortRankedProviders(
                    new RankedComparator<ContainerRequestFilter>(), rankedProviders);

            context.monitoringEventBuilder().setContainerRequestFilters(sortedRequestFilters);
            context.triggerEvent(RequestEvent.Type.REQUEST_MATCHED);

        } else {
            // pre-matching (response filter stage is pushed in pre-matching phase, so that if pre-matching filter
            // throws exception, response filters get still invoked)
            context.push(new ResponseFilterStage(context, responseFilters, tracingLogger));
            sortedRequestFilters = Providers.sortRankedProviders(new RankedComparator<ContainerRequestFilter>(), requestFilters);
        }

        final TracingLogger.Event summaryEvent =
                (postMatching ? ServerTraceEvent.REQUEST_FILTER_SUMMARY : ServerTraceEvent.PRE_MATCH_SUMMARY);
        final long timestamp = tracingLogger.timestamp(summaryEvent);
        int processedCount = 0;
        try {
            final TracingLogger.Event filterEvent = (postMatching ? ServerTraceEvent.REQUEST_FILTER : ServerTraceEvent.PRE_MATCH);
            for (ContainerRequestFilter filter : sortedRequestFilters) {
                final long filterTimestamp = tracingLogger.timestamp(filterEvent);
                try {
                    filter.filter(request);
                } catch (Exception exception) {
                    throw new MappableException(exception);
                } finally {
                    processedCount++;
                    tracingLogger.logDuration(filterEvent, filterTimestamp, filter);
                }

                final Response abortResponse = request.getAbortResponse();
                if (abortResponse != null) {
                    // abort accepting & return response
                    return Continuation.of(context, Stages.asStage(
                            new Endpoint() {
                                @Override
                                public ContainerResponse apply(
                                        final RequestProcessingContext requestContext) {
                                    return new ContainerResponse(requestContext.request(), abortResponse);
                                }
                            }));
                }
            }
        } finally {
            if (postMatching) {
                context.triggerEvent(RequestEvent.Type.REQUEST_FILTERED);
            }
            tracingLogger.logDuration(summaryEvent, timestamp, processedCount);
        }

        return Continuation.of(context, getDefaultNext());
    }
View Full Code Here

        // SPI could supply instance of ResolvedViewable but we would like to keep the backward
        // compatibility, so the cast is here.
        final ResolvedViewable resolvedViewable = (ResolvedViewable) viewable;


        final TracingLogger tracingLogger = TracingLogger.getInstance(containerRequestProvider.get().getPropertiesDelegate());
        if (tracingLogger.isLogEnabled(MvcJspEvent.JSP_FORWARD)) {
            tracingLogger.log(MvcJspEvent.JSP_FORWARD, templateReference, resolvedViewable.getModel());
        }

        final RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(templateReference);
        if (dispatcher == null) {
            throw new ContainerException(LocalizationMessages.NO_REQUEST_DISPATCHER_FOR_RESOLVED_PATH(templateReference));
View Full Code Here

      {
         throw new NotYetImplemented("Need to support multiple events at once...");
      }

      // since we currently don't support sending multiple events to process at once, assume there's only one
      Event event = events.get(0);

      eventInvocation.setName(event.getName());
      eventInvocation.setPayload(PayloadUtils.getPayloadAsSerializable(event));

      // Extensions
      processExtensionsFrom(eventParams.getClass(), eventParams.getExtensions());
View Full Code Here

      }

      // events
      QName name = invocation.getName();
      Serializable payload = invocation.getPayload();
      Event event = WSRPTypeFactory.createEvent(name, payload);
      EventParams eventParams = WSRPTypeFactory.createEventParams(Collections.singletonList(event), WSRPUtils.getStateChangeFromAccessMode(accessMode));

      return WSRPTypeFactory.createHandleEvents(requestPrecursor.getRegistrationContext(), portletContext,
         requestPrecursor.getRuntimeContext(), requestPrecursor.getUserContext(), requestPrecursor.getMarkupParams(), eventParams);
   }
View Full Code Here

      }

      // events
      QName name = invocation.getName();
      Serializable payload = invocation.getPayload();
      Event event = WSRPTypeFactory.createEvent(name, payload);
      EventParams eventParams = WSRPTypeFactory.createEventParams(Collections.singletonList(event), WSRPUtils.getStateChangeFromAccessMode(accessMode));
      eventParams.getExtensions().addAll(ExtensionAccess.getConsumerExtensionAccessor().getRequestExtensionsFor(EventParams.class));

      return WSRPTypeFactory.createHandleEvents(requestPrecursor.getRegistrationContext(), portletContext,
         requestPrecursor.getRuntimeContext(), requestPrecursor.getUserContext(), requestPrecursor.getMarkupParams(), eventParams);
View Full Code Here

   }

   public static Event createEvent(QName name, Serializable payload)
   {
      ParameterValidation.throwIllegalArgExceptionIfNull(name, "Event name");
      Event event = new Event();
      event.setName(name);
      if (payload != null)
      {
         event.setPayload(PayloadUtils.getPayloadAsEventPayload(event, payload));
      }
      return event;
   }
View Full Code Here

      {
         throw new NotYetImplemented("Need to support multiple events at once...");
      }

      // since we currently don't support sending multiple events to process at once, assume there's only one
      Event event = events.get(0);

      eventInvocation.setName(event.getName());
      eventInvocation.setPayload(PayloadUtils.getPayloadAsSerializable(event));

      // Extensions
      processExtensionsFrom(eventParams.getClass(), eventParams.getExtensions());
View Full Code Here

   }

   public static Event createEvent(QName name, Serializable payload)
   {
      ParameterValidation.throwIllegalArgExceptionIfNull(name, "Event name");
      Event event = new Event();
      event.setName(name);
      if (payload != null)
      {
         event.setPayload(PayloadUtils.getPayloadAsEventPayload(event, payload));
      }
      return event;
   }
View Full Code Here

TOP

Related Classes of org.glassfish.jersey.message.internal.TracingLogger$Event

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.