org.activeio.adapter
Class AsynchChannelToConcurrentRequestChannel

java.lang.Object
  extended byorg.activeio.FilterAsynchChannel
      extended byorg.activeio.adapter.AsynchChannelToConcurrentRequestChannel
All Implemented Interfaces:
AsynchChannel, AsynchChannelListener, Channel, Disposable, InputAsynchChannel, OutputChannel, RequestChannel, Service

public final class AsynchChannelToConcurrentRequestChannel
extends FilterAsynchChannel
implements RequestChannel

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

Version:
$Revision$

Field Summary
 
Fields inherited from class org.activeio.FilterAsynchChannel
channelListener, next
 
Fields inherited from interface org.activeio.Service
NO_WAIT_TIMEOUT, WAIT_FOREVER_TIMEOUT
 
Constructor Summary
AsynchChannelToConcurrentRequestChannel(AsynchChannel next)
           
AsynchChannelToConcurrentRequestChannel(AsynchChannel next, EDU.oswego.cs.dl.util.concurrent.Executor requestExecutor)
           
 
Method Summary
(package private)  short getNextRequestId()
           
 RequestListener getRequestListener()
           
 void onPacket(Packet packet)
          A AsynchChannel 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.FilterAsynchChannel
dispose, flush, getAsynchChannelListener, getNext, narrow, onPacketError, setAsynchChannelListener, 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

AsynchChannelToConcurrentRequestChannel

public AsynchChannelToConcurrentRequestChannel(AsynchChannel next)

AsynchChannelToConcurrentRequestChannel

public AsynchChannelToConcurrentRequestChannel(AsynchChannel next,
                                               EDU.oswego.cs.dl.util.concurrent.Executor requestExecutor)
Method Detail

getNextRequestId

short getNextRequestId()

write

public void write(Packet packet)
           throws java.io.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 FilterAsynchChannel
Throws:
java.io.IOException
See Also:
org.activeio.FilterAsynchChannel#write(org.activeio.channel.Packet)

onPacket

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

Specified by:
onPacket in interface AsynchChannelListener
Overrides:
onPacket in class FilterAsynchChannel
See Also:
org.activeio.FilterAsynchChannel#onPacket(org.activeio.channel.Packet)

request

public Packet request(Packet request,
                      long timeout)
               throws java.io.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:
java.io.IOException

setRequestListener

public void setRequestListener(RequestListener requestListener)
                        throws java.io.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:
java.io.IOException

getRequestListener

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


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