Java Code Examples for javax.ws.rs.ext.ReaderInterceptorContext#proceed()

The following examples show how to use javax.ws.rs.ext.ReaderInterceptorContext#proceed() . 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: LoggingFilter.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Override
public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException {
    byte[] buffer = IOUtils.toByteArray(context.getInputStream());
    logger.info("The contents of request body is: \n" + new String(buffer, "UTF-8") + "\n");
    context.setInputStream(new ByteArrayInputStream(buffer));
    return context.proceed();
}
 
Example 2
Source File: SnappyReaderInterceptor.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@Override
public Object aroundReadFrom(ReaderInterceptorContext context)  throws IOException, WebApplicationException {
  if (context.getHeaders().containsKey(CONTENT_ENCODING) &&
    context.getHeaders().get(CONTENT_ENCODING).contains(SNAPPY)) {
    InputStream originalInputStream = context.getInputStream();
    context.setInputStream(new SnappyFramedInputStream(originalInputStream, true));
  }
  return context.proceed();
}
 
Example 3
Source File: GZIPReaderInterceptor.java    From wings with Apache License 2.0 5 votes vote down vote up
@Override
public Object aroundReadFrom(ReaderInterceptorContext context)
                throws IOException, WebApplicationException {
  List<String> ce = context.getHeaders().get("content-encoding");
  if (ce != null && ce.contains("gzip")) {
    final InputStream originalInputStream = context.getInputStream();
    context.setInputStream(new GZIPInputStream(originalInputStream));
  }
  return context.proceed();
}
 
Example 4
Source File: RequestServerReaderInterceptor.java    From tutorials with MIT License 5 votes vote down vote up
@Override
public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException {
    LOG.info("Request reader interceptor in the server side");

    InputStream is = context.getInputStream();
    String body = new BufferedReader(new InputStreamReader(is)).lines()
        .collect(Collectors.joining("\n"));

    context.setInputStream(new ByteArrayInputStream((body + " message added in server reader interceptor").getBytes()));

    return context.proceed();
}
 
Example 5
Source File: GZipInterceptor.java    From Alpine with Apache License 2.0 5 votes vote down vote up
@Override
public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException {
    final List<String> header = context.getHeaders().get(HttpHeaders.CONTENT_ENCODING);
    if (header != null && header.contains("gzip")) {
        // DO NOT CLOSE STREAMS
        final InputStream contentInputSteam = context.getInputStream();
        final GZIPInputStream gzipInputStream = new GZIPInputStream(contentInputSteam);
        context.setInputStream(gzipInputStream);
    }
    return context.proceed();
}
 
Example 6
Source File: FormReaderInterceptor.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Override
public Object aroundReadFrom(ReaderInterceptorContext ctx) throws IOException, WebApplicationException {
    BufferedReader br = new BufferedReader(new InputStreamReader(ctx.getInputStream()));
    String line;
    while ((line = br.readLine()) != null) {
        LOG.info("readLine: " + line);
    }

    ByteArrayInputStream bais = new ByteArrayInputStream("value=MODIFIED".getBytes());
    LOG.info("set value=MODIFIED");
    ctx.setInputStream(bais);
    return ctx.proceed();
}
 
Example 7
Source File: TestHttpTarget.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@Override
public Object aroundReadFrom(ReaderInterceptorContext context)  throws IOException, WebApplicationException {
  if (context.getHeaders().containsKey("Content-Encoding") &&
    context.getHeaders().get("Content-Encoding").contains("snappy")) {
    InputStream originalInputStream = context.getInputStream();
    context.setInputStream(new SnappyFramedInputStream(originalInputStream, true));
  }
  return context.proceed();
}
 
Example 8
Source File: LoggingFilter.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException {
    byte[] buffer = IOUtils.toByteArray(context.getInputStream());
    logger.info("The contents of request body is: \n" + new String(buffer, "UTF-8") + "\n");
    context.setInputStream(new ByteArrayInputStream(buffer));
    return context.proceed();
}
 
Example 9
Source File: DynamicTraceInterceptor.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
public Object aroundReadFrom(ReaderInterceptorContext readerInterceptorContext) throws IOException, WebApplicationException {
    System.out.println("Dynamic reader interceptor invoked");
    return readerInterceptorContext.proceed();
}
 
Example 10
Source File: TestReaderInterceptor.java    From microprofile-rest-client with Apache License 2.0 4 votes vote down vote up
@Override
public Object aroundReadFrom(ReaderInterceptorContext readerInterceptorContext) throws IOException, WebApplicationException {
    invocations.incrementAndGet();
    return readerInterceptorContext.proceed();
}
 
Example 11
Source File: DynamicTraceInterceptor.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
public Object aroundReadFrom(ReaderInterceptorContext readerInterceptorContext) throws IOException, WebApplicationException {
    System.out.println("Dynamic reader interceptor invoked");
    return readerInterceptorContext.proceed();
}
 
Example 12
Source File: DynamicTraceInterceptor.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
public Object aroundReadFrom(ReaderInterceptorContext readerInterceptorContext) throws IOException, WebApplicationException {
    System.out.println("Dynamic reader interceptor invoked");
    return readerInterceptorContext.proceed();
}
 
Example 13
Source File: TraceInterceptor.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public Object aroundReadFrom(ReaderInterceptorContext readerInterceptorContext) throws IOException, WebApplicationException {
    System.out.println("Reader interceptor invoked");
    return readerInterceptorContext.proceed();
}
 
Example 14
Source File: TraceInterceptor.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public Object aroundReadFrom(ReaderInterceptorContext readerInterceptorContext) throws IOException, WebApplicationException {
    System.out.println("Reader interceptor invoked");
    return readerInterceptorContext.proceed();
}
 
Example 15
Source File: TraceInterceptor.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public Object aroundReadFrom(ReaderInterceptorContext readerInterceptorContext) throws IOException, WebApplicationException {
    System.out.println("Reader interceptor invoked");
    return readerInterceptorContext.proceed();
}
 
Example 16
Source File: DynamicTraceInterceptor.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public Object aroundReadFrom(ReaderInterceptorContext readerInterceptorContext) throws IOException, WebApplicationException {
    System.out.println("Dynamic reader interceptor invoked");
    return readerInterceptorContext.proceed();
}
 
Example 17
Source File: TraceInterceptor.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public Object aroundReadFrom(ReaderInterceptorContext readerInterceptorContext) throws IOException, WebApplicationException {
    System.out.println("Reader interceptor invoked");
    return readerInterceptorContext.proceed();
}
 
Example 18
Source File: TraceInterceptor.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public Object aroundReadFrom(ReaderInterceptorContext readerInterceptorContext) throws IOException, WebApplicationException {
    System.out.println("Reader interceptor invoked");
    return readerInterceptorContext.proceed();
}
 
Example 19
Source File: DynamicTraceInterceptor.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public Object aroundReadFrom(ReaderInterceptorContext readerInterceptorContext) throws IOException, WebApplicationException {
    System.out.println("Dynamic reader interceptor invoked");
    return readerInterceptorContext.proceed();
}
 
Example 20
Source File: LoggingFilter.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException {
    byte[] buffer = IOUtils.toByteArray(context.getInputStream());
    logger.info("The contents of request body is: \n" + new String(buffer, "UTF-8") + "\n");
    context.setInputStream(new ByteArrayInputStream(buffer));
    return context.proceed();
}