public class Lake
extends Thread
Modifier and Type | Field and Description |
---|---|
static boolean |
CLIENT
Specifies that this is Lake is client-side.
|
static boolean |
SERVER
Specifies that this is Lake is server-side.
|
Constructor and Description |
---|
Lake(boolean csFlag,
Waterfall nextWaterfall,
java.net.Socket sslSocket)
Instantiate a new Lake object which faciliates support for multi-substream
communications on the single compressed Client/Server socket-stream.
The Lake is the central socket I/O handler, which implements multiple
substreams with multiple River objects that essentially provide a single
point of reference to corresponding RiverInputStream and RiverOutputStream
objects which are subclasses of the InputStream and OutputStream classes so
as to provide transparency for applications development on a per-River basis.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close this resource, relinquishing any underlying resources.
|
River |
createRiver()
Set up a new River with its own pair of I/O streams.
|
boolean |
isClient()
Indicates whether this lake is client-side or server-side.
|
boolean |
isServer()
Indicates whether this lake is client-side or server-side.
|
void |
run()
Main background thread code, is a simple loop that handles inbound data and
places them into the appropriate Lake objects (or sends an error response if
the Lake ID is invalid).
|
void |
send(Iceberg ib)
Sends an Iceberg over the SSLSocket in a thread-safe manner.
|
void |
setWaterfall(Waterfall nextWaterfall)
Sets the next Waterfall callback object that handles new Rivers.
|
String |
toString()
Provide debug-readable output version of this object.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yield
public static final boolean CLIENT
public static final boolean SERVER
public Lake(boolean csFlag, Waterfall nextWaterfall, java.net.Socket sslSocket) throws java.io.IOException
This is helpful for minimizing the total number of socket handles that need to be allocated from the Operating Systems, and also simplifying various application-specific tasks that would normally otherwise open more sockets.
csFlag
- Lake.CLIENT, generate positive River IDs / Lake.SERVER,
generate negative River IDs / This prevents River IDs collisionsnextWaterfall
- The pre-instantiated Waterfall object to use when a new
River is encountered; if NULL, then inbound Icebergs will queue up until
the setWaterfall() method is called to define the next WaterfallsslSocket
- The Socket object to use (SSLSocket is strongly encouraged)java.io.IOException
- - if an I/O error occurs when obtaining the
Socket's streams, the socket is closed or was shut down, or the socket is not
connected to its end-node pairpublic void close()
public River createRiver()
public boolean isClient()
public boolean isServer()
public void run()
run
in interface Runnable
run
in class Thread
public void send(Iceberg ib) throws java.io.IOException
ib
- Iceberg to sendjava.io.IOException
- If an I/O error occurs; in particular, an
IOException
may be thrown if the output stream has been closedpublic void setWaterfall(Waterfall nextWaterfall)
nextWaterfall
- The pre-instantiated Waterfall object to use when a new
River is encountered (cannot be NULL, but can replace a previous Waterfall)public String toString()
toString
in class Thread