@Override public void writeTo(NioWriteEntity entity, Class<?> cls, Type t, Annotation[] anns, MediaType mt, MultivaluedMap<String, Object> headers, OutputStream os) throws IOException, WebApplicationException { Continuation cont = getContinuationProvider().getContinuation(); NioWriteListenerImpl listener = new NioWriteListenerImpl(cont, entity, os); Message m = JAXRSUtils.getCurrentMessage(); m.put(WriteListener.class, listener); // return the current thread to the pool cont.suspend(0); }
protected void copyUsingNio(InputStream is, OutputStream os, Continuation cont) { NioWriteListenerImpl listener = new NioWriteListenerImpl(cont, new NioWriteEntity(getNioHandler(is), null), new NioOutputStream(os)); Message m = JAXRSUtils.getCurrentMessage(); m.put(WriteListener.class, listener); cont.suspend(0); }