1 23 24 package com.sun.enterprise.web.connector.grizzly; 25 26 import java.io.IOException ; 27 import java.nio.ByteBuffer ; 28 import java.nio.channels.SocketChannel ; 29 30 import org.apache.coyote.Response; 31 import org.apache.coyote.http11.InternalOutputBuffer; 32 33 34 35 43 public class SocketChannelOutputBuffer extends InternalOutputBuffer{ 44 45 47 48 51 public SocketChannelOutputBuffer(Response response, int headerBufferSize) { 52 53 super(response,headerBufferSize); 54 55 socketBuffer.allocate(headerBufferSize, headerBufferSize); 56 useSocketBuffer = true; 57 } 58 59 60 62 65 protected SocketChannel socketChannel; 66 67 69 70 73 public void setChannel(SocketChannel socketChannel) { 74 this.socketChannel = socketChannel; 75 } 76 77 78 81 public SocketChannel getChannel() { 82 return socketChannel; 83 } 84 85 86 88 91 public void sendAck() throws IOException { 92 93 if (!committed) 94 flushChannel(ByteBuffer.wrap(Constants.ACK_BYTES)); 95 96 } 97 98 99 102 public void realWriteBytes(byte cbuf[], int off, int len) 103 throws IOException { 104 if (len > 0) { 105 flushChannel(ByteBuffer.wrap(cbuf,off,len)); 106 } 107 } 108 109 110 114 public void flushChannel(ByteBuffer bb) throws IOException { 115 OutputWriter.flushChannel(socketChannel, bb); 116 } 117 } 118 | Popular Tags |