org.activeio.filter
Class SynchornizedAsyncChannel

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

public class SynchornizedAsyncChannel
extends FilterAsyncChannel

Used to synchronize concurrent access to an ASynchChannel. Uses a Sync object for write operations. All other operations such as stop(long) and stop(long) just do a normal java synchronization against the SynchornizedSynchChannel object instance. It is assumed that the Async message delivery is not concurrent and therefore does not require synchronization.


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
SynchornizedAsyncChannel(AsyncChannel next)
           
SynchornizedAsyncChannel(AsyncChannel next, Sync writeLock)
           
 
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.
 Sync getWriteLock()
           
 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 start()
          Starts the channel.
 void stop(long timeout)
          Stops the channel.
 void write(Packet packet)
          Sends a packet down the channel towards the media.
 
Methods inherited from class org.activeio.FilterAsyncChannel
getAsyncChannelListener, getNext, onPacket, onPacketError, setAsyncChannelListener, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SynchornizedAsyncChannel

public SynchornizedAsyncChannel(AsyncChannel next)

SynchornizedAsyncChannel

public SynchornizedAsyncChannel(AsyncChannel next,
                                Sync writeLock)
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

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
Overrides:
flush in class FilterAsyncChannel
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
Overrides:
dispose in class FilterAsyncChannel
See Also:
Disposable.dispose()

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
Overrides:
narrow in class FilterAsyncChannel

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
Overrides:
start in class FilterAsyncChannel
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
Overrides:
stop in class FilterAsyncChannel
Throws:
IOException
See Also:
Service.stop(long)

getWriteLock

public Sync getWriteLock()


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