com.caucho.hessian.mux
Class MuxServer

java.lang.Object
  extended bycom.caucho.hessian.mux.MuxServer

public class MuxServer
extends java.lang.Object

Hessian Mux, a peer-to-peer protocol.


Field Summary
private  boolean[] inputReady
           
private  java.io.InputStream is
           
private  boolean isClient
           
private  boolean isClosed
           
private  boolean isReadLocked
           
private  boolean isWriteLocked
           
private  java.io.OutputStream os
           
private  java.lang.Object READ_LOCK
           
private  java.lang.Object WRITE_LOCK
           
 
Constructor Summary
MuxServer()
          Null argument constructor.
MuxServer(java.io.InputStream is, java.io.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.
 java.io.InputStream getInputStream()
          Gets the raw input stream.
 java.io.OutputStream getOutputStream()
          Gets the raw output stream.
(package private)  boolean getReadLock()
           
 void init(java.io.InputStream is, java.io.OutputStream os, boolean isClient)
          Initialize the multiplexor with input and output streams.
(package private)  java.io.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(int channel, MuxInputStream in, MuxOutputStream out)
          Starts a client call.
 boolean startCall(MuxInputStream in, MuxOutputStream out)
          Starts a client call.
(package private)  java.io.OutputStream writeChannel(int channel)
          Grabs the channel for writing.
(package private)  void yield(int channel)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

READ_LOCK

private java.lang.Object READ_LOCK

WRITE_LOCK

private java.lang.Object WRITE_LOCK

is

private java.io.InputStream is

os

private java.io.OutputStream os

isClient

private boolean isClient

isClosed

private transient boolean isClosed

inputReady

private boolean[] inputReady

isReadLocked

private boolean isReadLocked

isWriteLocked

private boolean isWriteLocked
Constructor Detail

MuxServer

public MuxServer()
Null argument constructor.


MuxServer

public MuxServer(java.io.InputStream is,
                 java.io.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 Detail

init

public void init(java.io.InputStream is,
                 java.io.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.

getInputStream

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


getOutputStream

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


startCall

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

Throws:
java.io.IOException

startCall

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

Throws:
java.io.IOException

readRequest

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

Throws:
java.io.IOException

writeChannel

java.io.OutputStream writeChannel(int channel)
                            throws java.io.IOException
Grabs the channel for writing.

Parameters:
channel - the channel
Returns:
true if the channel has permission to write.
Throws:
java.io.IOException

yield

void yield(int channel)
     throws java.io.IOException
Throws:
java.io.IOException

flush

void flush(int channel)
     throws java.io.IOException
Throws:
java.io.IOException

close

void close(int channel)
     throws java.io.IOException
Throws:
java.io.IOException

freeWriteLock

void freeWriteLock()
Frees the channel for writing.


readChannel

java.io.InputStream readChannel(int channel)
                          throws java.io.IOException
Reads data from a channel.

Parameters:
channel - the channel
Returns:
true if the channel is valid.
Throws:
java.io.IOException

getReadLock

boolean getReadLock()

freeReadLock

void freeReadLock()
Frees the channel for reading.


readData

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

Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Close the mux

Throws:
java.io.IOException