Class
Tree
          
SUMMARY: INNER | FIELD | CONSTR | METHODDETAIL: FIELD | CONSTR | METHOD
 

com.newstep.solid.netio.packet
Class PacketChannel
com.newstep.solid.netio.AbstractCommChannel
  |
  +--com.newstep.solid.netio.packet.PacketChannel
All Implemented Interfaces:
       CommChannel, DataIoListener

public class PacketChannel      
Channel used to send and receive Packets. PacketChannel may be used in a
connection-less mode. PacketChannels created through the listen
function of the PacketChannelAccessPoint are not connected to a specific
remote endpoint. In connection-less mode the PacketChannel instance may
be used to send and receive packets from/to any remote endpoint by specifying
the remote endpoint in each packet's remoteEndpoint attribute.


Alternatively, the PacketChannel may implement a connection oriented scheme
when accessed via one of the PacketChannelAccessPoint.openChannel()
functions. In this mode the underlying DatagramChannel is connected to the
specified remoteEndpoint and may only send and receive packets from the
remote endpoint.

Implements:
DataIoListener
 
Links:
Kernel Association notifies closed
to Class PacketChannelAccessPoint
Associates type:
association
Client cardinality:
1
Client navigability:
NOT NAVIGABLE
Client visibility:
private
Directed.
Supplier cardinality:
1
Supplier navigability:
NAVIGABLE
Supplier visibility:
private
 
Kernel Association notifies
to Interface PacketChannelListener
Associates type:
association
Client cardinality:
1
Client navigability:
NOT NAVIGABLE
Client visibility:
private
Directed.
Supplier cardinality:
1
Supplier navigability:
NAVIGABLE
Supplier visibility:
private
 
Kernel Association Association Link
to Class SelectorThread
the selector thread that manages the non-blocking DatagramChannel
Associates type:
association
Client cardinality:
1
Client navigability:
NOT NAVIGABLE
Client visibility:
private
Supplier cardinality:
1
Supplier navigability:
NAVIGABLE
Supplier visibility:
private
 
Generalization Generalization Link
to Class AbstractCommChannel
Channel used to send and receive Packets. PacketChannel may be used in a
connection-less mode. PacketChannels created through the listen
function of the PacketChannelAccessPoint are not connected to a specific
remote endpoint. In connection-less mode the PacketChannel instance may
be used to send and receive packets from/to any remote endpoint by specifying
the remote endpoint in each packet's remoteEndpoint attribute.


Alternatively, the PacketChannel may implement a connection oriented scheme
when accessed via one of the PacketChannelAccessPoint.openChannel()
functions. In this mode the underlying DatagramChannel is connected to the
specified remoteEndpoint and may only send and receive packets from the
remote endpoint.

 
Implementation Implementation Link
to Interface DataIoListener
Channel used to send and receive Packets. PacketChannel may be used in a
connection-less mode. PacketChannels created through the listen
function of the PacketChannelAccessPoint are not connected to a specific
remote endpoint. In connection-less mode the PacketChannel instance may
be used to send and receive packets from/to any remote endpoint by specifying
the remote endpoint in each packet's remoteEndpoint attribute.


Alternatively, the PacketChannel may implement a connection oriented scheme
when accessed via one of the PacketChannelAccessPoint.openChannel()
functions. In this mode the underlying DatagramChannel is connected to the
specified remoteEndpoint and may only send and receive packets from the
remote endpoint.

 
 

Field Summary
private final static String
private DatagramChannel
private final static Logger
private ReentrantLock
private ConcurrentLinkedQueue
Constructor Summary
public void
PacketChannel(PacketChannelAccessPoint accessPoint, DatagramChannel datagramChannel, SelectorThread selectorThread)
Method Summary
public void
protected DatagramChannel
public void
public void
public void
send(Packet packet)
public void
Field Detail
accessPoint
private PacketChannelAccessPoint accessPoint
Multiplicity:
1
 

channelListener
private PacketChannelListener channelListener
Multiplicity:
1
 

channelListener
PacketChannelListener channelListener
 

CLASSNAME
private final static String CLASSNAME
Final.
Multiplicity:
1
Static.
 

datagramChannel
private DatagramChannel datagramChannel
non-blocking DatagramChannel over which messages are sent and received
Multiplicity:
1
 

logger
private final static Logger logger
Final.
Multiplicity:
1
Static.
 

selectorThread
private SelectorThread selectorThread
the selector thread that manages the non-blocking DatagramChannel
Multiplicity:
1
 

writeLock
private ReentrantLock writeLock
concurrency control for the packet write queue
Multiplicity:
1
 

writeQueue
private ConcurrentLinkedQueue writeQueue
packet write queue for controlling non-blocking write routines
Multiplicity:
1
 
Constructor Detail
PacketChannel
public void PacketChannel (PacketChannelAccessPoint accessPoint, DatagramChannel datagramChannel, SelectorThread selectorThread)
 
creates a PacketChannel with the specified accessPoint parent, internal
DatagramChannel and SelectorThread
Parameters:
accessPoint the parent PacketChannelAccessPoint that manages the
channel (needed for closing)
datagramChannel the channel over which packets are sent and received
selectorThread the non-blocking io-controller thread
Stereotype:
create
 
Method Detail
close
public void close ()
 
closes the channel by removing itself from its associated access point
and setting its state as CLOSED
 

getChannelListener
public PacketChannelListener getChannelListener ()
 
Return:
the listener associated with the PacketChannel
 

getDatagramChannel
protected DatagramChannel getDatagramChannel ()
 
Return:
the DatagramChannel instance over which Packets are sent and received
 

getLocalEndpoint
public ChannelEndpoint getLocalEndpoint ()
 
not relevant for a non-connection oriented packet channel
Return:
null not relevant for a non-connection oriented packet channel
 

getRemoteEndpoint
public ChannelEndpoint getRemoteEndpoint ()
 
not relevant for a non-connection oriented packet channel
Return:
null not relevant for a non-connection oriented packet channel
 

onRead
public void onRead ()
 
call-back invoked by the selector thread when the underlying
DatagramChannel is ready for reading. The PacketChannel attempts to read
a packet and deliver it to its associated PacketChannelListener.
 

onWrite
public void onWrite ()
 
call-back invoked by the selector thread when the underlying
DatagramChannel is ready for writing. The methods scans the packet write
queue and writes as many packets to the channel as possible
 

send
public void send (Packet packet)
 
Sends the specified packet to the address specified in the packet. NOTE
the packet will be written to the write queue until the selector indicates
that the underlying DatagramChannel is ready for writing
Parameters:
packet the packet to send
Throws:
IOException
 

setChannelListener
public void setChannelListener (PacketChannelListener channelListener)
 
assigns the specified PacketChannelListener to receive channel Packets
Parameters:
channelListener the PacketChannelListener to inform of new Packets
 

Class
Tree
          
SUMMARY: INNER | FIELD | CONSTR | METHODDETAIL: FIELD | CONSTR | METHOD