org.activeio.adapter
Class AsyncChannelToConcurrentRequestChannel

java.lang.Object
  extended byorg.activeio.FilterAsyncChannel
      extended byorg.activeio.adapter.AsyncChannelToConcurrentRequestChannel
All Implemented Interfaces:
AsyncChannel, AsyncChannelListener, Channel, Disposable, InputAsyncChannel, OutputChannel, RequestChannel, Service

public final class AsyncChannelToConcurrentRequestChannel
extends FilterAsyncChannel
implements RequestChannel

Creates a RequestChannel out of a AsyncChannel. This RequestChannel is thread safe and mutiplexes concurrent requests and responses over the underlying AsyncChannel.

Version:
$Revision$

Field Summary
 
Fields inherited from class org.activeio.FilterAsyncChannel
channelListener, next
 
Fields inherited from interface org.activeio.Service
NO_WAIT_TIMEOUT, WAIT_FOREVER_TIMEOUT
 
Constructor Summary
AsyncChannelToConcurrentRequestChannel(AsyncChannel next)
           
AsyncChannelToConcurrentRequestChannel(AsyncChannel next, Executor requestExecutor)
           
 
Method Summary
 RequestListener getRequestListener()
           
 void onPacket(Packet packet)
          A AsyncChannel will call this method to deliver an 'up' packet to a consumer.
 Packet request(Packet request, long timeout)
          Used to send a packet of information going 'down' the channel and wait for it's reponse 'up' packet.
 void setRequestListener(RequestListener requestListener)
          Registers the RequestListener that the protcol will use to deliver request packets comming 'up' the channel.
 void write(Packet packet)
          Sends a packet down the channel towards the media.
 
Methods inherited from class org.activeio.FilterAsyncChannel
dispose, flush, getAsyncChannelListener, getNext, narrow, onPacketError, setAsyncChannelListener, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.activeio.Channel
narrow
 
Methods inherited from interface org.activeio.Disposable
dispose
 
Methods inherited from interface org.activeio.Service
start, stop
 

Constructor Detail

AsyncChannelToConcurrentRequestChannel

public AsyncChannelToConcurrentRequestChannel(AsyncChannel next)

AsyncChannelToConcurrentRequestChannel

public AsyncChannelToConcurrentRequestChannel(AsyncChannel next,
                                              Executor requestExecutor)
Method Detail

write

public void write(Packet packet)
           throws IOException
Description copied from interface: OutputChannel
Sends a packet down the channel towards the media.

Specified by:
write in interface OutputChannel
Overrides:
write in class FilterAsyncChannel
Throws:
IOException
See Also:
FilterAsyncChannel.write(org.activeio.Packet)

onPacket

public void onPacket(Packet packet)
Description copied from interface: AsyncChannelListener
A AsyncChannel will call this method to deliver an 'up' packet to a consumer.

Specified by:
onPacket in interface AsyncChannelListener
Overrides:
onPacket in class FilterAsyncChannel
See Also:
FilterAsyncChannel.onPacket(org.activeio.Packet)

request

public Packet request(Packet request,
                      long timeout)
               throws IOException
Description copied from interface: RequestChannel
Used to send a packet of information going 'down' the channel and wait for it's reponse 'up' packet. This method blocks until the response packet is received or the operation experiences a timeout.

Specified by:
request in interface RequestChannel
Parameters:
request -
timeout -
Returns:
the respnse packet or null if the timeout occured.
Throws:
IOException

setRequestListener

public void setRequestListener(RequestListener requestListener)
                        throws IOException
Description copied from interface: RequestChannel
Registers the RequestListener that the protcol will use to deliver request packets comming 'up' the channel.

Specified by:
setRequestListener in interface RequestChannel
Throws:
IOException

getRequestListener

public RequestListener getRequestListener()
Specified by:
getRequestListener in interface RequestChannel
Returns:
the registered RequestListener


Copyright © -2007 The ActiveIO Project. All Rights Reserved.