org.glassfish.grizzly.http.server.Response.getNIOWriter()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中org.glassfish.grizzly.http.server.Response.getNIOWriter方法的一些代码示例,展示了Response.getNIOWriter的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.getNIOWriter方法的具体详情如下:
包路径:org.glassfish.grizzly.http.server.Response
类名称:Response
方法名:getNIOWriter

Response.getNIOWriter介绍

[英]Return the NIOWriter associated with this Response. The NIOWriter will write content in a non-blocking manner.
[中]

代码示例

代码示例来源:origin: opentripplanner/OpenTripPlanner

@Override
public void service(Request req, Response resp) throws Exception {
  try {
    OTPRequest oreq = new OTPRequest(req, graph);
    Object result = handlers.get(oreq.action).handle(oreq);
    ObjectMapper mapper;
    if (oreq.sfmt == SerializeFormat.XML) {
      resp.setContentType("application/xml");
      mapper = xmlMapper;
    } else {
      resp.setContentType("application/json");
      mapper = jsonMapper;
    }
    resp.setStatus(200);
    mapper.writeValue(resp.getNIOOutputStream(), result);            
  } catch (Exception ex) {
    resp.setStatus(500);
    resp.setContentType("text/plain");
    resp.getNIOWriter().write("Error: " + ex.toString());
  }
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-http-server

/**
 * <p>
 * Return the {@link NIOWriter} associated with this {@link Response}.
 * </p>
 * 
 * By default the returned {@link NIOWriter} will work as blocking
 * {@link java.io.Writer}, but it will be possible to call {@link NIOWriter#canWrite()} or
 * {@link NIOWriter#notifyCanWrite(org.glassfish.grizzly.WriteHandler)} to
 * avoid blocking.
 *
 * @throws IllegalStateException if {@link #getOutputStream()} or
 *  {@link #getNIOOutputStream()} were already invoked.
 */
public Writer getWriter() {
  return getNIOWriter();
}

代码示例来源:origin: javaee/grizzly

/**
 * <p>
 * Return the {@link NIOWriter} associated with this {@link Response}.
 * </p>
 * 
 * By default the returned {@link NIOWriter} will work as blocking
 * {@link java.io.Writer}, but it will be possible to call {@link NIOWriter#canWrite()} or
 * {@link NIOWriter#notifyCanWrite(org.glassfish.grizzly.WriteHandler)} to
 * avoid blocking.
 *
 * @throws IllegalStateException if {@link #getOutputStream()} or
 *  {@link #getNIOOutputStream()} were already invoked.
 */
public Writer getWriter() {
  return getNIOWriter();
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-http-server-core

/**
 * <p>
 * Return the {@link NIOWriter} associated with this {@link Response}.
 * </p>
 * 
 * By default the returned {@link NIOWriter} will work as blocking
 * {@link java.io.Writer}, but it will be possible to call {@link NIOWriter#canWrite()} or
 * {@link NIOWriter#notifyCanWrite(org.glassfish.grizzly.WriteHandler)} to
 * avoid blocking.
 *
 * @throws IllegalStateException if {@link #getOutputStream()} or
 *  {@link #getNIOOutputStream()} were already invoked.
 */
public Writer getWriter() {
  return getNIOWriter();
}

代码示例来源:origin: javaee/grizzly

/**
 * <p>
 * Return the {@link NIOWriter} associated with this {@link Response}.
 * </p>
 * 
 * By default the returned {@link NIOWriter} will work as blocking
 * {@link java.io.Writer}, but it will be possible to call {@link NIOWriter#canWrite()} or
 * {@link NIOWriter#notifyCanWrite(org.glassfish.grizzly.WriteHandler)} to
 * avoid blocking.
 *
 * @throws IllegalStateException if {@link #getOutputStream()} or
 *  {@link #getNIOOutputStream()} were already invoked.
 */
public Writer getWriter() {
  return getNIOWriter();
}

代码示例来源:origin: org.mule.glassfish.grizzly/grizzly-http-server

/**
 * <p>
 * Return the {@link NIOWriter} associated with this {@link Response}.
 * </p>
 * 
 * By default the returned {@link NIOWriter} will work as blocking
 * {@link java.io.Writer}, but it will be possible to call {@link NIOWriter#canWrite()} or
 * {@link NIOWriter#notifyCanWrite(org.glassfish.grizzly.WriteHandler)} to
 * avoid blocking.
 *
 * @throws IllegalStateException if {@link #getOutputStream()} or
 *  {@link #getNIOOutputStream()} were already invoked.
 */
public Writer getWriter() {
  return getNIOWriter();
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-websockets-server

/**
 * <p>
 * Return the {@link NIOWriter} associated with this {@link Response}.
 * </p>
 * 
 * By default the returned {@link NIOWriter} will work as blocking
 * {@link java.io.Writer}, but it will be possible to call {@link NIOWriter#canWrite()} or
 * {@link NIOWriter#notifyCanWrite(org.glassfish.grizzly.WriteHandler)} to
 * avoid blocking.
 *
 * @throws IllegalStateException if {@link #getOutputStream()} or
 *  {@link #getNIOOutputStream()} were already invoked.
 */
public Writer getWriter() {
  return getNIOWriter();
}

代码示例来源:origin: javaee/grizzly

/**
 * <p>
 * Return the {@link NIOWriter} associated with this {@link Response}.
 * </p>
 * 
 * By default the returned {@link NIOWriter} will work as blocking
 * {@link java.io.Writer}, but it will be possible to call {@link NIOWriter#canWrite()} or
 * {@link NIOWriter#notifyCanWrite(org.glassfish.grizzly.WriteHandler)} to
 * avoid blocking.
 *
 * @throws IllegalStateException if {@link #getOutputStream()} or
 *  {@link #getNIOOutputStream()} were already invoked.
 */
public Writer getWriter() {
  return getNIOWriter();
}

代码示例来源:origin: javaee/grizzly

/**
 * <p>
 * Return the {@link NIOWriter} associated with this {@link Response}.
 * </p>
 * 
 * By default the returned {@link NIOWriter} will work as blocking
 * {@link java.io.Writer}, but it will be possible to call {@link NIOWriter#canWrite()} or
 * {@link NIOWriter#notifyCanWrite(org.glassfish.grizzly.WriteHandler)} to
 * avoid blocking.
 *
 * @throws IllegalStateException if {@link #getOutputStream()} or
 *  {@link #getNIOOutputStream()} were already invoked.
 */
public Writer getWriter() {
  return getNIOWriter();
}

代码示例来源:origin: javaee/grizzly

/**
 * <p>
 * Return the {@link NIOWriter} associated with this {@link Response}.
 * </p>
 * 
 * By default the returned {@link NIOWriter} will work as blocking
 * {@link java.io.Writer}, but it will be possible to call {@link NIOWriter#canWrite()} or
 * {@link NIOWriter#notifyCanWrite(org.glassfish.grizzly.WriteHandler)} to
 * avoid blocking.
 *
 * @throws IllegalStateException if {@link #getOutputStream()} or
 *  {@link #getNIOOutputStream()} were already invoked.
 */
public Writer getWriter() {
  return getNIOWriter();
}

代码示例来源:origin: javaee/grizzly

/**
 * <p>
 * Return the {@link NIOWriter} associated with this {@link Response}.
 * </p>
 * 
 * By default the returned {@link NIOWriter} will work as blocking
 * {@link java.io.Writer}, but it will be possible to call {@link NIOWriter#canWrite()} or
 * {@link NIOWriter#notifyCanWrite(org.glassfish.grizzly.WriteHandler)} to
 * avoid blocking.
 *
 * @throws IllegalStateException if {@link #getOutputStream()} or
 *  {@link #getNIOOutputStream()} were already invoked.
 */
public Writer getWriter() {
  return getNIOWriter();
}

代码示例来源:origin: javaee/grizzly

/**
 * <p>
 * Return the {@link NIOWriter} associated with this {@link Response}.
 * </p>
 * 
 * By default the returned {@link NIOWriter} will work as blocking
 * {@link java.io.Writer}, but it will be possible to call {@link NIOWriter#canWrite()} or
 * {@link NIOWriter#notifyCanWrite(org.glassfish.grizzly.WriteHandler)} to
 * avoid blocking.
 *
 * @throws IllegalStateException if {@link #getOutputStream()} or
 *  {@link #getNIOOutputStream()} were already invoked.
 */
public Writer getWriter() {
  return getNIOWriter();
}

代码示例来源:origin: javaee/grizzly

final NIOWriter out = response.getNIOWriter();

代码示例来源:origin: ch.squaredesk.nova/http

replyInfo -> {
  response.setCharacterEncoding("utf-8");
  try (NIOWriter out = response.getNIOWriter()) {
    response.setContentType("application/json");
    response.setContentLength(replyInfo._1.length());

相关文章

微信公众号

最新文章

更多

Response类方法