001: /*
002: * $Id: ReaderWriter.java,v 1.4 2005/11/30 11:27:27 ss150821 Exp $
003: * $Source: /m/portal/ps/srap/src/com/sun/portal/rproxy/https/ReaderWriter.java,v $
004: * $Log: ReaderWriter.java,v $
005: * Revision 1.4 2005/11/30 11:27:27 ss150821
006: * 6356996 - Srap Code base needs to save files in the unix file format and not windows
007: *
008: * Revision 1.3 2005/02/23 08:59:23 ss150821
009: * RFE 6223490 - SRA Should use JDK based logging
010: *
011: * Revision 1.2 2004/07/27 12:58:28 vt126379
012: * RFE#5075809, CRT#99
013: *
014: * Revision 1.1 2002/06/14 09:53:57 rt130506
015: * SRAP rebranding
016: *
017: * Revision 1.2 2002/06/11 16:02:09 bv131302
018: * new branded
019: *
020: * Revision 1.1 2002/05/28 09:38:18 mm132998
021: * Bug id - 4692062 , CRT - 1215 , Desc - Support for iDSAME in https mode.
022: *
023: *
024: */
025: // @(#)ReaderWriter.java 1.11 "@(#)ReaderWriter.java 1.11 99/09/23 Sun Microsystems"
026: package com.sun.portal.rproxy.https;
027:
028: import java.io.DataInputStream;
029: import java.io.DataOutputStream;
030: import java.io.IOException;
031: import java.net.Socket;
032: import java.util.logging.Level;
033: import java.util.logging.Logger;
034:
035: import com.sun.portal.log.common.PortalLogger;
036:
037: public abstract class ReaderWriter implements Runnable {
038: protected ReaderWriterLock rwLock;
039:
040: protected DataInputStream in;
041:
042: protected DataOutputStream out;
043:
044: final protected int MAXBUFFERSIZE = 8 * 1024;
045:
046: protected boolean sent = false;
047:
048: protected volatile boolean go = true;
049:
050: // private static Logger logger =
051: // Logger.getLogger("com.sun.portal.sra.rproxy");
052: private static Logger logger = PortalLogger
053: .getLogger(ReaderWriter.class);
054:
055: public ReaderWriter(ReaderWriterLock l, Socket fs, Socket ts) {
056: rwLock = l;
057:
058: // create data input and output streams
059: try {
060: in = new DataInputStream(fs.getInputStream());
061: out = new DataOutputStream(ts.getOutputStream());
062: } catch (IOException e) {
063: in = null;
064: out = null;
065: //logger.log(Level.SEVERE, "ReaderWriter: Cannot construct ReaderWriter ", e);
066: Object[] params = { e };
067: logger.log(Level.SEVERE, "PSSRRPROXY_CSPRH024", params);
068: }
069: }
070:
071: public abstract void run();
072:
073: void clean() {
074: if (in != null) {
075: try {
076: in.close();
077: } catch (Exception e) {
078: } finally {
079: in = null;
080: }
081: }
082:
083: if (out != null) {
084: try {
085: out.close();
086: } catch (Exception e) {
087: } finally {
088: out = null;
089: }
090: }
091: }
092:
093: public void netletstop() {
094: go = false;
095: clean();
096: }
097:
098: public void stop() {
099: go = false;
100: clean();
101: }
102:
103: public boolean sentDataFlag() {
104: return (sent);
105: }
106:
107: public void clearDataFlag() {
108: sent = false;
109: }
110:
111: public boolean isAlive() {
112: return (go);
113: }
114: }
|