01: /*
02: * $Id: CompressionSocket.java,v 1.1 2003/12/02 06:39:32 ajzeneski Exp $
03: *
04: * Copyright (c) 1998, 1999 Sun Microsystems, Inc. All Rights Reserved.
05: *
06: * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
07: * modify and redistribute this software in source and binary code form,
08: * provided that i) this copyright notice and license appear on all copies of
09: * the software; and ii) Licensee does not utilize the software in a manner
10: * which is disparaging to Sun.
11: *
12: * This software is provided "AS IS," without a warranty of any kind. ALL
13: * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
14: * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
15: * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
16: * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
17: * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
18: * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
19: * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
20: * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
21: * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
22: * POSSIBILITY OF SUCH DAMAGES.
23: *
24: * This software is not designed or intended for use in on-line control of
25: * aircraft, air traffic, aircraft navigation or aircraft communications; or in
26: * the design, construction, operation or maintenance of any nuclear
27: * facility. Licensee represents and warrants that it will not use or
28: * redistribute the Software for such purposes.
29: */
30:
31: package org.ofbiz.service.rmi.socket;
32:
33: import java.io.IOException;
34: import java.io.InputStream;
35: import java.io.OutputStream;
36: import java.net.Socket;
37:
38: class CompressionSocket extends Socket {
39:
40: /* InputStream used by socket */
41: private InputStream in;
42: /* OutputStream used by socket */
43: private OutputStream out;
44:
45: /*
46: * No-arg constructor for class CompressionSocket
47: */
48: public CompressionSocket() {
49: super ();
50: }
51:
52: /*
53: * Constructor for class CompressionSocket
54: */
55: public CompressionSocket(String host, int port) throws IOException {
56: super (host, port);
57: }
58:
59: /*
60: * Returns a stream of type CompressionInputStream
61: */
62: public InputStream getInputStream() throws IOException {
63: if (in == null) {
64: in = new CompressionInputStream(super .getInputStream());
65: }
66: return in;
67: }
68:
69: /*
70: * Returns a stream of type CompressionOutputStream
71: */
72: public OutputStream getOutputStream() throws IOException {
73: if (out == null) {
74: out = new CompressionOutputStream(super .getOutputStream());
75: }
76: return out;
77: }
78:
79: /*
80: * Flush the CompressionOutputStream before
81: * closing the socket.
82: */
83: public synchronized void close() throws IOException {
84: OutputStream o = getOutputStream();
85: o.flush();
86: super.close();
87: }
88: }
|