java类javax.ws.rs.ext.WriterInterceptorContext的实例源码

AroundWriteMeter.java 文件源码 项目:respiro 阅读 19 收藏 0 点赞 0 评论 0
@Override
public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
    try {
        context.proceed();
    } catch (Throwable e) {
        String path = (String) context.getProperty("metrics.path");
        String name = name("REST", "WRITE", e.getClass().getSimpleName(), path);
        JerseyMetricsPlugin.getMetricRegistry().meter(name).mark();

        throw e;
    }
}
HttpHeaderStatisticInjector.java 文件源码 项目:porcupine 阅读 22 收藏 0 点赞 0 评论 0
@Override
public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
    List<Statistics> pipelines = statistics.get();
    MultivaluedMap<String, Object> headers = context.getHeaders();
    pipelines.forEach(s -> headers.add("x-porcupine-statistics-" + s.getPipelineName(), serializeStatistics(s)));
    context.proceed();
}
GZipWriterInterceptor.java 文件源码 项目:atsd-api-java 阅读 20 收藏 0 点赞 0 评论 0
@Override
public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
    String acceptEncodings = getAcceptEncodingHeader(context.getHeaders());

    if (acceptEncodings.contains("gzip")) {
        final OutputStream outputStream = context.getOutputStream();
        context.setOutputStream(new GZIPOutputStream(outputStream));
    }

    context.proceed();
}
SnappyWriterInterceptor.java 文件源码 项目:datacollector 阅读 25 收藏 0 点赞 0 评论 0
@Override
public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
  context.getHeaders().add(CONTENT_ENCODING, SNAPPY);
  final OutputStream outputStream = context.getOutputStream();
  context.setOutputStream(new SnappyFramedOutputStream(outputStream));
  context.proceed();
}
RestSkolWriterInterceptor.java 文件源码 项目:restskol 阅读 22 收藏 0 点赞 0 评论 0
@Override
public void aroundWriteTo(WriterInterceptorContext writerInterceptorContext)
        throws IOException, WebApplicationException {
    logger.info("Enters RestSkolWriterInterceptor.aroundWriterTo()");

    final OutputStream outputStream = writerInterceptorContext.getOutputStream();
    writerInterceptorContext.setOutputStream(new GZIPOutputStream(outputStream));
    writerInterceptorContext.proceed();
}
RequestLogger.java 文件源码 项目:effektif 阅读 26 收藏 0 点赞 0 评论 0
@Override
public void aroundWriteTo(final WriterInterceptorContext writerInterceptorContext) throws IOException, WebApplicationException {
  final LoggingStream stream = (LoggingStream) writerInterceptorContext.getProperty(ENTITY_LOGGER_PROPERTY);
  writerInterceptorContext.proceed();
  if (stream != null) {
    if (log.isDebugEnabled())
      log.debug(stream.getStringBuilder(MessageUtils.getCharset(writerInterceptorContext.getMediaType())).toString());
  }
}
RequestLogger.java 文件源码 项目:effektif 阅读 23 收藏 0 点赞 0 评论 0
@Override
public void aroundWriteTo(final WriterInterceptorContext writerInterceptorContext) throws IOException, WebApplicationException {
  final LoggingStream stream = (LoggingStream) writerInterceptorContext.getProperty(ENTITY_LOGGER_PROPERTY);
  writerInterceptorContext.proceed();
  if (stream != null) {
    if (log.isDebugEnabled())
      log.debug(stream.getStringBuilder(MessageUtils.getCharset(writerInterceptorContext.getMediaType())).toString());
  }
}
AttachContextInterceptor.java 文件源码 项目:git-webapp 阅读 22 收藏 0 点赞 0 评论 0
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
  if (context.getEntity() != null && context.getEntity() instanceof Viewable) {
    final Viewable viewable = (Viewable) context.getEntity();

    Object model = viewable.getModel();
    if (!(model instanceof Map)) {
      model = new HashMap<String, Object>() {
        private static final long serialVersionUID = 1L;
        {
          put("model", viewable.getModel());
        }
      };
    }
    ((Map) model).put("context", getContextMap());
    ((Map) model).put("session", getSessionMap());

    if (servletRequest.getAttribute(RepositoryContext.ATTR_NAME) != null) {
      RepositoryContext repoContext = (RepositoryContext) servletRequest.getAttribute(RepositoryContext.ATTR_NAME);
      ((Map) model).put("repo", repoContext);
    }

    context.setEntity(new Viewable(viewable.getTemplateName(), model));
  }

  context.proceed();
}
MyClientWriterInterceptor.java 文件源码 项目:JavaIncrementalParser 阅读 23 收藏 0 点赞 0 评论 0
@Override
    public void aroundWriteTo(WriterInterceptorContext wic) throws IOException, WebApplicationException {

        System.out.println("MyClientWriterInterceptor");
        wic.setOutputStream(new FilterOutputStream(wic.getOutputStream()) {

            final ByteArrayOutputStream baos = new ByteArrayOutputStream();

            @Override
            public void write(int b) throws IOException {
                baos.write(b);
                super.write(b);
            }

            @Override
            public void close() throws IOException {
                System.out.println("MyClientWriterInterceptor --> " + baos.toString());
                super.close();
            }
        });

//        wic.setOutputStream(new FilterOutputStream(wic.getOutputStream()) {
//            
//            @Override
//            public void write(int b) throws IOException {
//                System.out.println("**** "  + (char)b);
//                super.write(b);
//            }
//            
//        });

        wic.proceed();
    }
MyClientWriterInterceptor.java 文件源码 项目:JavaIncrementalParser 阅读 21 收藏 0 点赞 0 评论 0
@Override
    public void aroundWriteTo(WriterInterceptorContext wic) throws IOException, WebApplicationException {

        System.out.println("MyClientWriterInterceptor");
        wic.setOutputStream(new FilterOutputStream(wic.getOutputStream()) {

            final ByteArrayOutputStream baos = new ByteArrayOutputStream();

            @Override
            public void write(int b) throws IOException {
                baos.write(b);
                super.write(b);
            }

            @Override
            public void close() throws IOException {
                System.out.println("MyClientWriterInterceptor --> " + baos.toString());
                super.close();
            }
        });

//        wic.setOutputStream(new FilterOutputStream(wic.getOutputStream()) {
//            
//            @Override
//            public void write(int b) throws IOException {
//                System.out.println("**** "  + (char)b);
//                super.write(b);
//            }
//            
//        });

        wic.proceed();
    }


问题


面经


文章

微信
公众号

扫码关注公众号