de.knipp.rritoolkit.test
Class DebugChannelFactory.DebugChannel

java.lang.Object
  extended by de.knipp.rritoolkit.test.DebugChannelFactory.DebugChannel
All Implemented Interfaces:
RegistryChannel
Enclosing class:
DebugChannelFactory

private static class DebugChannelFactory.DebugChannel
extends java.lang.Object
implements RegistryChannel

wrapper class for a connection. Prints messages sent and received to the console.

Version:
$Revision: 14936 $
Author:
Klaus Malorny

Field Summary
private  RegistryChannel channel
          the actual channel
private  int id
          the ID of the channel
 
Constructor Summary
DebugChannelFactory.DebugChannel(RegistryChannel theChannel, int theID)
          constructor
 
Method Summary
 void close()
          close the channel.
 boolean isClosed()
          return whether the channel has been closed
 byte[] receive()
          wait for a response from the registry.
 void send(byte[] data, boolean isXml)
          send the given message to the registry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

channel

private RegistryChannel channel
the actual channel


id

private int id
the ID of the channel

Constructor Detail

DebugChannelFactory.DebugChannel

public DebugChannelFactory.DebugChannel(RegistryChannel theChannel,
                                        int theID)
constructor

Parameters:
theChannel - the actual channel
theID - the assigned ID
Method Detail

send

public void send(byte[] data,
                 boolean isXml)
          throws java.io.IOException
send the given message to the registry. As the transport mechanism may need to know whether the data represents the XML or key-value form of the request, it must be specified. If the channel is already closed, an exception is thrown.

Specified by:
send in interface RegistryChannel
Parameters:
data - the data representing the message
isXml - true if the message uses the XML encoding, false if the message uses key-value pairs.
Throws:
java.io.IOException - if the transmission failed

receive

public byte[] receive()
               throws java.io.IOException
wait for a response from the registry.

Specified by:
receive in interface RegistryChannel
Returns:
the message that has been received
Throws:
java.io.IOException - if the connection has been closed either before or during the call.

isClosed

public boolean isClosed()
return whether the channel has been closed

Specified by:
isClosed in interface RegistryChannel
Returns:
true if closed

close

public void close()
close the channel. Closing an already closed channel should be ignored

Specified by:
close in interface RegistryChannel


Copyright © 2005-2011 Knipp Medien und Kommunikation GmbH