001: /*
002: * $Id: RWGroupJSSProxy.java,v 1.6 2005/11/30 11:27:27 ss150821 Exp $
003: * $Source: /m/portal/ps/srap/src/com/sun/portal/rproxy/https/RWGroupJSSProxy.java,v $
004: * $Log: RWGroupJSSProxy.java,v $
005: * Revision 1.6 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.5 2005/02/25 09:44:17 ss150821
009: * RFE 6223490 - SRA Should use JDK based logging, changed to start throwing the full stacktrace for the exception in the logs
010: *
011: * Revision 1.4 2005/02/23 09:02:01 ss150821
012: * RFE 6223490 - SRA Should use JDK based logging
013: *
014: * Revision 1.3 2005/02/23 08:59:23 ss150821
015: * RFE 6223490 - SRA Should use JDK based logging
016: *
017: * Revision 1.2 2004/07/27 12:58:28 vt126379
018: * RFE#5075809, CRT#99
019: *
020: * Revision 1.1 2002/06/14 09:53:57 rt130506
021: * SRAP rebranding
022: *
023: * Revision 1.2 2002/06/11 16:02:09 bv131302
024: * new branded
025: *
026: * Revision 1.1 2002/05/28 09:38:18 mm132998
027: * Bug id - 4692062 , CRT - 1215 , Desc - Support for iDSAME in https mode.
028: *
029: *
030: */
031: package com.sun.portal.rproxy.https;
032:
033: import java.net.Socket;
034: import java.util.logging.Level;
035: import java.util.logging.Logger;
036:
037: import com.sun.portal.log.common.PortalLogger;
038:
039: public class RWGroupJSSProxy extends ReaderWriterLock {
040: private Socket fromClient;
041:
042: private Socket toServer;
043:
044: private ReaderWriterClear src_to_dst;
045:
046: private ReaderWriterClear dst_to_src;
047:
048: private boolean src_to_dst_clean = false;
049:
050: private boolean dst_to_src_clean = false;
051:
052: // private static Logger logger =
053: // Logger.getLogger("com.sun.portal.sra.rproxy");
054: private static Logger logger = PortalLogger
055: .getLogger(RWGroupJSSProxy.class);
056:
057: public RWGroupJSSProxy(Socket fromSocket, Socket toSocket) {
058: fromClient = fromSocket;
059: toServer = toSocket;
060:
061: src_to_dst = new ReaderWriterClear(this , fromClient, toServer);
062: dst_to_src = new ReaderWriterClear(this , toServer, fromClient);
063: try {
064: JSSThreadPool.run(src_to_dst);
065: JSSThreadPool.run(dst_to_src);
066: } catch (InterruptedException e) {
067: // logger.log(Level.SEVERE, "Could not start ReaderWriterClear
068: // tasks", e);
069: logger.log(Level.SEVERE, "PSSRRPROXY_CSPRH023", e);
070: }
071: }
072:
073: public synchronized void notifyFinished(ReaderWriter obj) {
074: if (obj == src_to_dst) {
075: if (dst_to_src.isAlive()) {
076: dst_to_src.stop();
077: }
078: } else if (obj == dst_to_src) {
079: if (src_to_dst.isAlive()) {
080: src_to_dst.stop();
081: }
082: }
083: cleanup();
084: if (obj == src_to_dst) {
085: src_to_dst_clean = true;
086: } else if (obj == dst_to_src) {
087: dst_to_src_clean = true;
088: }
089: }
090:
091: public void cleanup() {
092: if (fromClient != null) {
093: try {
094: fromClient.close();
095: } catch (Exception e) {
096: } finally {
097: fromClient = null;
098: }
099: }
100: if (toServer != null) {
101: try {
102: toServer.close();
103: } catch (Exception e) {
104: } finally {
105: toServer = null;
106: }
107: }
108: }
109:
110: public boolean isDone() {
111: if (dst_to_src_clean && src_to_dst_clean) {
112: dst_to_src = null;
113: src_to_dst = null;
114: }
115: return (dst_to_src_clean && src_to_dst_clean);
116: }
117: }
|