org.exolab.core.messenger
Class StreamDemultiplexer

java.lang.Object
  extended by org.exolab.core.messenger.StreamDemultiplexer
All Implemented Interfaces:
Demultiplexer

public class StreamDemultiplexer
extends java.lang.Object
implements Demultiplexer

This class implements a demultiplexer that reads packets from an InputStream streams and sends them to their associated Channel instance.

It is intended to run in a separate thread, terminating if one of the following conditions occur:

Version:
$Revision: 1.4 $ $Date: 2003/06/09 06:28:41 $
Author:
Tim Anderson
See Also:
PacketConnection, Demultiplexer

Constructor Summary
StreamDemultiplexer(ManagedPacketConnection connection, java.io.InputStream stream)
          Construct a new multiplexer
 
Method Summary
 void close()
          Close the multiplexer, freeing any allocated resources.
 boolean closed()
          Returns true if the demultiplexer is closed
protected  void demultiplex()
          Stream packets from the connection's input stream, and dispatch them to the appropriate channel
protected  void dispatch(org.exolab.core.messenger.Packet packet)
          Dispatches a packet to its associated channel
 void start()
          Start demultiplexing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamDemultiplexer

public StreamDemultiplexer(ManagedPacketConnection connection,
                           java.io.InputStream stream)
Construct a new multiplexer

Parameters:
connection - the connection to read packets from
stream - the stream to read packets from
Throws:
java.lang.IllegalArgumentException - if any argument is null
Method Detail

start

public void start()
Start demultiplexing. This reads packets from an InputStream instance, and dispatches them to the appropriate channel.

Specified by:
start in interface Demultiplexer
Throws:
java.lang.IllegalStateException - if the demultiplexer is running, or has been closed

close

public void close()
Close the multiplexer, freeing any allocated resources. Once a multiplexer is closed, it may not be restarted.

Specified by:
close in interface Demultiplexer

closed

public boolean closed()
Returns true if the demultiplexer is closed


demultiplex

protected void demultiplex()
Stream packets from the connection's input stream, and dispatch them to the appropriate channel


dispatch

protected void dispatch(org.exolab.core.messenger.Packet packet)
Dispatches a packet to its associated channel

Parameters:
packet - the packet to dispatch


Copyright © 1999-2012 The Exolab Group. All Rights Reserved.