01: // @(#)ReaderWriterLock.java 1.4 "@(#)ReaderWriterLock.java 1.4 99/09/23 Sun Microsystems"
02:
03: package com.sun.portal.netlet.econnection;
04:
05: import java.io.DataInputStream;
06: import java.io.DataOutputStream;
07: import java.io.IOException;
08:
09: public abstract class ReaderWriterLock implements MessageConstants {
10:
11: protected boolean rwDone = false;
12:
13: synchronized public void notifyFinished() {
14: notify();
15: }
16:
17: synchronized public void notifyFinished(ReaderWriter obj) {
18: }
19:
20: //JSS chagnes - implemented atomic (synchronized) methods to avert JSS crashes
21:
22: public synchronized int atomicReadMsg(DataCipherMsg dMsg,
23: DataInputStream in) {
24: if (in != null) {
25: return dMsg.readMsg(in);
26: } else {
27: return -1;
28: }
29: }
30:
31: public synchronized int atomicWriteMsg(DataCipherMsg dMsg,
32: DataOutputStream out) {
33: if (out != null) {
34: return dMsg.writeMsg(out);
35: } else {
36: return -1;
37: }
38: }
39:
40: public synchronized int atomicWriteDummyMsg(DataOutputStream out) {
41: if (out == null) {
42: return -1;
43: }
44: try {
45: out.writeByte(VERSION);
46: out.writeShort(DUMMY_MSG);
47: out.writeInt(0);
48: out.writeInt(0);
49: } catch (IOException ioe) {
50: System.out
51: .println("ReaderWriterEncrypt caught exception while sending dummy msg:");
52: ioe.printStackTrace();
53: return -1;
54: }
55: return 0;
56: }
57:
58: public synchronized void atomicWriteCloseConnectionMsg(
59: DataCipherMsg dMsg, DataOutputStream out) {
60: if (out != null) {
61: dMsg.writeCloseConnectionMsg(out);
62: }
63: }
64:
65: public synchronized void atomicStop(ReaderWriter rw) {
66: rw.stop();
67: }
68:
69: /*
70: * Added by Rajesh T for RFE 4492648.
71: * returns the time in milliseconds at which
72: * the netlet activity took place in this RWGroup
73: */
74: public abstract long getLastActivityTime();
75:
76: /*
77: * Added for RFE 4492648
78: * Stops the ReaderWriter's associated with this group
79: */
80: public abstract void stopAll();
81:
82: /*
83: * Added for Netlet PRD 1.8.1 for Lihue
84: */
85: public abstract int getAppletSrcPort();
86:
87: public abstract long getStartTime();
88:
89: }
|