org.exolab.core.messenger
Class StreamMultiplexer

java.lang.Object
  extended byorg.exolab.core.messenger.StreamMultiplexer
All Implemented Interfaces:
Multiplexer

public class StreamMultiplexer
extends java.lang.Object
implements Multiplexer

This class implements a multiplexer that streams packets from a PacketConnection's outbound queue to an OutputStream.

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, Multiplexer

Constructor Summary
StreamMultiplexer(ManagedPacketConnection connection, java.io.OutputStream stream)
          Construct a new multiplexer
 
Method Summary
 void close()
          Close the multiplexer, freeing any allocated resources.
protected  void multiplex()
          Stream packets from the connection's output queue to its output stream.
 void start()
          Start multiplexing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamMultiplexer

public StreamMultiplexer(ManagedPacketConnection connection,
                         java.io.OutputStream stream)
Construct a new multiplexer

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

start

public void start()
Start multiplexing. This reads packets from an PacketConnection instance, and sends them down the connection's physical connection implementation.

Specified by:
start in interface Multiplexer
Throws:
java.lang.IllegalStateException - if the multiplexer 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 Multiplexer

multiplex

protected void multiplex()
Stream packets from the connection's output queue to its output stream.



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