All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class connection.ConnectionManager

java.lang.Object
   |
   +----connection.ConnectionManager

public class ConnectionManager
extends Object
ConnectionManager is a class for delivering messages (reading, writing, and handling). It is composed of a MessageHandler, a MessageReader, and a MessageWriter.

Version:
0.30, 1998/04/01
Author:
FRED development team, Antti Viljamaa
See Also:
MessageHandler, MessageReader, MessageWriter

Variable Index

 o exceptionObservers
The objetcs that are notified upon an exception during a read or a write.
 o messageHandler
The handler for incoming messages.
 o messagePrintingEnabled
Determies whether to print debug info to System.out.
 o messageReader
The message reader.
 o messageWriter
The message writer.

Constructor Index

 o ConnectionManager(InputStream, OutputStream)
Constructs a connection manager and initilises it with a message reader attached to the given input stream and a message writer attached to the given output stream.
 o ConnectionManager(InputStream, OutputStream, MessageHandler)
Constructs a connection manager and initilises it with a message reader attached to the given input stream, a message writer attached to the given output stream, and a message handler.

Method Index

 o getExceptionObservers()
Returns the exception observers.
 o getMessageHandler()
Returns the message handler.
 o getMessageReader()
Returns the message reader.
 o getMessageWriter()
Returns the message writer.
 o isMessagePrintingEnabled()
Determines if message printing is enabled.
 o notifyAllExceptionObservers(Exception)
Notifies all registered exception observers.
 o receiveMessage()
Blocks for receiving a new message, and once it arrives, asks the handler to handle it.
 o registerExceptionObserver(ExceptionObserver)
Registeres a new exception observer.
 o sendMessage(Message)
Sends the given message.
 o setMessageHandler(MessageHandler)
Sets the message handler.
 o setMessagePrintingEnabled(boolean)
Sets the flag that determines if message printing is enabled.
 o setMessageReader(MessageReader)
Sets the message reader.
 o setMessageWriter(MessageWriter)
Sets the message writer.

Variables

 o exceptionObservers
 private Vector exceptionObservers
The objetcs that are notified upon an exception during a read or a write.

 o messageReader
 private MessageReader messageReader
The message reader.

 o messageWriter
 private MessageWriter messageWriter
The message writer.

 o messageHandler
 private MessageHandler messageHandler
The handler for incoming messages.

 o messagePrintingEnabled
 private boolean messagePrintingEnabled
Determies whether to print debug info to System.out.

Constructors

 o ConnectionManager
 public ConnectionManager(InputStream inputStream,
                          OutputStream outputStream)
Constructs a connection manager and initilises it with a message reader attached to the given input stream and a message writer attached to the given output stream. No message handler is created.

Parameters:
inputStream - The input stream that is connected to this connection manager.
outputStream - The output stream that is connected to this connection manager.
 o ConnectionManager
 public ConnectionManager(InputStream inputStream,
                          OutputStream outputStream,
                          MessageHandler messageHandler)
Constructs a connection manager and initilises it with a message reader attached to the given input stream, a message writer attached to the given output stream, and a message handler.

Parameters:
inputStream - The input stream that is connected to this connection manager.
outputStream - The output stream that is connected to this connection manager.
messageHandler - The root handler for messages.

Methods

 o sendMessage
 public void sendMessage(Message m)
Sends the given message. If an exception occurs during the receive, notifies all exception observers.

Parameters:
m - The message that is sent.
 o receiveMessage
 public boolean receiveMessage()
Blocks for receiving a new message, and once it arrives, asks the handler to handle it. If an exception occurs during the receive, notifies all exception observers.

Returns:
boolean if the message was handled, otherwise.
 o getMessageHandler
 public MessageHandler getMessageHandler()
Returns the message handler.

 o getMessageReader
 public MessageReader getMessageReader()
Returns the message reader.

 o getMessageWriter
 public MessageWriter getMessageWriter()
Returns the message writer.

 o setMessageReader
 public void setMessageReader(MessageReader mr)
Sets the message reader.

 o setMessageWriter
 public void setMessageWriter(MessageWriter mw)
Sets the message writer.

 o setMessageHandler
 public void setMessageHandler(MessageHandler mh)
Sets the message handler.

 o registerExceptionObserver
 public void registerExceptionObserver(ExceptionObserver observer)
Registeres a new exception observer. Exception observers are notified if an exception occurs when sending or receiving messages.

 o notifyAllExceptionObservers
 protected void notifyAllExceptionObservers(Exception exception)
Notifies all registered exception observers.

 o getExceptionObservers
 public Vector getExceptionObservers()
Returns the exception observers.

 o isMessagePrintingEnabled
 public boolean isMessagePrintingEnabled()
Determines if message printing is enabled.

 o setMessagePrintingEnabled
 public void setMessagePrintingEnabled(boolean flag)
Sets the flag that determines if message printing is enabled.


All Packages  Class Hierarchy  This Package  Previous  Next  Index