com.caucho.hessian.mux

Class MuxServer


public class MuxServer
extends java.lang.Object

Hessian Mux, a peer-to-peer protocol.

Field Summary

private Object
READ_LOCK
private Object
WRITE_LOCK
private boolean[]
inputReady
private InputStream
is
private boolean
isClient
private boolean
isClosed
private boolean
isReadLocked
private boolean
isWriteLocked
private OutputStream
os

Constructor Summary

MuxServer()
Null argument constructor.
MuxServer(InputStream is, OutputStream os, boolean isClient)
Create a new multiplexor with input and output streams.

Method Summary

void
close()
Close the mux
(package private) void
close(int channel)
(package private) void
flush(int channel)
(package private) void
freeReadLock()
Frees the channel for reading.
(package private) void
freeWriteLock()
Frees the channel for writing.
InputStream
getInputStream()
Gets the raw input stream.
OutputStream
getOutputStream()
Gets the raw output stream.
(package private) boolean
getReadLock()
void
init(InputStream is, OutputStream os, boolean isClient)
Initialize the multiplexor with input and output streams.
(package private) InputStream
readChannel(int channel)
Reads data from a channel.
private void
readData()
Reads data until a channel packet 'C' or error 'E' is received.
boolean
readRequest(MuxInputStream in, MuxOutputStream out)
Reads a server request.
boolean
startCall(MuxInputStream in, MuxOutputStream out)
Starts a client call.
boolean
startCall(int channel, MuxInputStream in, MuxOutputStream out)
Starts a client call.
(package private) OutputStream
writeChannel(int channel)
Grabs the channel for writing.
(package private) void
yield(int channel)

Field Details

READ_LOCK

private Object READ_LOCK

WRITE_LOCK

private Object WRITE_LOCK

inputReady

private boolean[] inputReady

is

private InputStream is

isClient

private boolean isClient

isClosed

private boolean isClosed

isReadLocked

private boolean isReadLocked

isWriteLocked

private boolean isWriteLocked

os

private OutputStream os

Constructor Details

MuxServer

public MuxServer()
Null argument constructor.

MuxServer

public MuxServer(InputStream is,
                 OutputStream os,
                 boolean isClient)
Create a new multiplexor with input and output streams.
Parameters:
is - the underlying input stream
os - the underlying output stream
isClient - true if this is the connection client.

Method Details

close

public void close()
            throws IOException
Close the mux

close

(package private)  void close(int channel)
            throws IOException

flush

(package private)  void flush(int channel)
            throws IOException

freeReadLock

(package private)  void freeReadLock()
Frees the channel for reading.

freeWriteLock

(package private)  void freeWriteLock()
Frees the channel for writing.

getInputStream

public InputStream getInputStream()
Gets the raw input stream. Clients will normally not call this.

getOutputStream

public OutputStream getOutputStream()
Gets the raw output stream. Clients will normally not call this.

getReadLock

(package private)  boolean getReadLock()

init

public void init(InputStream is,
                 OutputStream os,
                 boolean isClient)
Initialize the multiplexor with input and output streams.
Parameters:
is - the underlying input stream
os - the underlying output stream
isClient - true if this is the connection client.

readChannel

(package private)  InputStream readChannel(int channel)
            throws IOException
Reads data from a channel.
Parameters:
channel - the channel
Returns:
true if the channel is valid.

readData

private void readData()
            throws IOException
Reads data until a channel packet 'C' or error 'E' is received.

readRequest

public boolean readRequest(MuxInputStream in,
                           MuxOutputStream out)
            throws IOException
Reads a server request.

startCall

public boolean startCall(MuxInputStream in,
                         MuxOutputStream out)
            throws IOException
Starts a client call.

startCall

public boolean startCall(int channel,
                         MuxInputStream in,
                         MuxOutputStream out)
            throws IOException
Starts a client call.

writeChannel

(package private)  OutputStream writeChannel(int channel)
            throws IOException
Grabs the channel for writing.
Parameters:
channel - the channel
Returns:
true if the channel has permission to write.

yield

(package private)  void yield(int channel)
            throws IOException