org.activeio
Class FilterAsyncChannel

java.lang.Object
  extended byorg.activeio.FilterAsyncChannel
All Implemented Interfaces:
AsyncChannel, AsyncChannelListener, Channel, Disposable, InputAsyncChannel, OutputChannel, Service
Direct Known Subclasses:
AsyncChannelToConcurrentRequestChannel, AsyncWriteAsyncChannel, CounterAsyncChannel, PacketAggregatingAsyncChannel, SynchornizedAsyncChannel, WriteBufferedAsyncChannel

public class FilterAsyncChannel
extends Object
implements AsyncChannel, AsyncChannelListener

A AsyncChannelFilter can be used as a filter between a AsyncChannel and it's org.activeio.ChannelConsumer. Most AsyncChannel that are not directly accessing the network will extends the AsyncChannelFilter since they act as a filter between the client and the network. O

Version:
$Revision$

Field Summary
protected  AsyncChannelListener channelListener
           
protected  AsyncChannel next
           
 
Fields inherited from interface org.activeio.Service
NO_WAIT_TIMEOUT, WAIT_FOREVER_TIMEOUT
 
Constructor Summary
FilterAsyncChannel(AsyncChannel next)
           
 
Method Summary
 void dispose()
          This method should not throw any exceptions.
 void flush()
          Some channels may buffer data which may be sent down if flush() is called.
 AsyncChannelListener getAsyncChannelListener()
           
 AsyncChannel getNext()
           
 Object narrow(Class target)
          Since a Channel may be composed from a chain of other Channel obejcts, this method allows you to query the chain for the specified interface.
 void onPacket(Packet packet)
          A AsyncChannel will call this method to deliver an 'up' packet to a consumer.
 void onPacketError(IOException error)
          A AsyncChannel will call this method when a async failure occurs in the channel.
 void setAsyncChannelListener(AsyncChannelListener channelListener)
          Registers the ChannelConsumer that the protcol will use to deliver packets coming 'up' the channel.
 void start()
          Starts the channel.
 void stop(long timeout)
          Stops the channel.
 String toString()
           
 void write(Packet packet)
          Sends a packet down the channel towards the media.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

next

protected final AsyncChannel next

channelListener

protected AsyncChannelListener channelListener
Constructor Detail

FilterAsyncChannel

public FilterAsyncChannel(AsyncChannel next)
Method Detail

setAsyncChannelListener

public void setAsyncChannelListener(AsyncChannelListener channelListener)
Description copied from interface: InputAsyncChannel
Registers the ChannelConsumer that the protcol will use to deliver packets coming 'up' the channel.

Specified by:
setAsyncChannelListener in interface InputAsyncChannel

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
Parameters:
packet -
Throws:
IOException

flush

public void flush()
           throws IOException
Description copied from interface: OutputChannel
Some channels may buffer data which may be sent down if flush() is called.

Specified by:
flush in interface OutputChannel
Throws:
IOException

dispose

public void dispose()
Description copied from interface: Disposable
This method should not throw any exceptions. Cleaning up a Disposable object should be easy of an end user therefore do not make him have to handle an Exception.

Specified by:
dispose in interface Disposable
See Also:
Disposable.dispose()

start

public void start()
           throws IOException
Description copied from interface: Service
Starts the channel. Once started, the channel is in the running state.

Specified by:
start in interface Service
Throws:
IOException - if the next channel has not been set.
See Also:
Service.start()

stop

public void stop(long timeout)
          throws IOException
Description copied from interface: Service
Stops the channel. Once stopped, the channel is in the stopped state.

Specified by:
stop in interface Service
Parameters:
timeout - The amount of time the channel is allowed to take to gracefully stop. If the timeout is exceeded, the channel should do a forcefull stop.
Throws:
IOException
See Also:
Service.stop(long)

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
Parameters:
packet -
See Also:
AsyncChannelListener.onPacket(org.activeio.Packet)

onPacketError

public void onPacketError(IOException error)
Description copied from interface: AsyncChannelListener
A AsyncChannel will call this method when a async failure occurs in the channel.

Specified by:
onPacketError in interface AsyncChannelListener
Parameters:
error - the exception that describes the failure.
See Also:
org.activeio.AsyncChannelListener#onPacketError(org.activeio.ChannelException)

getNext

public AsyncChannel getNext()
Returns:
Returns the next.

getAsyncChannelListener

public AsyncChannelListener getAsyncChannelListener()
Specified by:
getAsyncChannelListener in interface InputAsyncChannel
Returns:
Returns the packetListener.

narrow

public Object narrow(Class target)
Description copied from interface: Channel
Since a Channel may be composed from a chain of other Channel obejcts, this method allows you to query the chain for the specified interface. The first Channel in the chain the implments the requested interface will be return an implementing object. If no Channel in the chain implements the requested class, then null is returned.

Specified by:
narrow in interface Channel

toString

public String toString()


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