1 23 24 package org.continuent.sequoia.common.stream; 25 26 import java.io.BufferedOutputStream ; 27 import java.io.IOException ; 28 import java.net.Socket ; 29 30 import org.continuent.sequoia.driver.SequoiaUrl; 31 32 51 public class DriverBufferedOutputStream 52 extends LongUTFDataOutputStream 53 { 54 private Socket socket; 55 private long dateCreated; 56 private final int debugLevel; 57 58 61 protected void finalize() throws Throwable  62 { 63 try 64 { 65 69 if (!socket.isClosed()) 70 { 71 if (debugLevel >= SequoiaUrl.DEBUG_LEVEL_DEBUG) 72 { 73 System.err 74 .println("Socket was not closed, either someone forgot to" 75 + " call Connection.close() on " + socket); 76 System.err.println("or a finally { close(); } block is missing"); 77 } 78 79 socket.close(); 80 } 81 } 82 finally 83 { 84 super.finalize(); 85 } 86 } 87 88 93 public DriverBufferedOutputStream(Socket clientSocket) throws IOException  94 { 95 this(clientSocket, SequoiaUrl.DEBUG_LEVEL_OFF); 96 } 97 98 106 public DriverBufferedOutputStream(Socket socket, int debugLevel) 107 throws IOException  108 { 109 super(new BufferedOutputStream ((socket.getOutputStream()))); 110 this.socket = socket; 111 this.debugLevel = debugLevel; 112 dateCreated = System.currentTimeMillis(); 113 } 114 115 118 public Socket getSocket() 119 { 120 return socket; 121 } 122 123 126 public long getDateCreated() 127 { 128 return dateCreated; 129 } 130 } 131
| Popular Tags
|