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

com.newstep.solid.comm
Class Multiplexor
All Implemented Interfaces:
       Runnable

public class Multiplexor      
The Multiplexor acts as IO processor and manages all IO operations requested
by the Channel. The IO operations are proccessed asynchronously. Usually
client applications does not require direct access to mutiplexor class, only
when multiple protocols would like to reuse the same multiplexor instance.
Each multiplexor instance instantiates one java.nio.channels.Selector
instance. Multiplexor represents a communications utility for providing
select functionality across multiple Channels and multiple
ChannelAccessPoints. Component implementations may configured to leverage the
Multiplexor construct in a manner most appropriate to the component's
communications requirements.
Implements:
Runnable
 
 

Field Summary
private LinkedList
private ReentrantLock
private ConcurrentHashMap
private final static String
private int
private List
private boolean
private boolean
private boolean
private boolean
private static Logger
private int
private int
private int
private int
private int
private Selector
private Thread
private long
private ReentrantLock
private int
Constructor Summary
public void
Method Summary
private void
public void
cancelHandler(SelectableChannel channel)
private void
public synchronized boolean
private void
private void
public synchronized void
registerHandler(SelectableChannel selectableChannel, IOHandler callback)
public void
run()
public void
setLogLevel(Level logLevel)
public synchronized void
public synchronized void
public synchronized void
stop(IOHandler handler)
public String
Field Detail
cancelledChannels
private LinkedList cancelledChannels
Multiplicity:
1
 

cancelledLock
private ReentrantLock cancelledLock
Multiplicity:
1
 

channels
private ConcurrentHashMap channels
Multiplicity:
1
 

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

closed
private int closed
Multiplicity:
1
 

execCallbacks
private List execCallbacks
Multiplicity:
1
 

hasCancelled
private boolean hasCancelled
Multiplicity:
1
 

hasRegistred
private boolean hasRegistred
Multiplicity:
1
 

isShutDown
private boolean isShutDown
Multiplicity:
1
 

isStopped
private boolean isStopped
Multiplicity:
1
 

logger
private static Logger logger
Multiplicity:
1
Static.
 

onAccept
private int onAccept
Multiplicity:
1
 

onConnect
private int onConnect
Multiplicity:
1
 

onRead
private int onRead
Multiplicity:
1
 

onWrite
private int onWrite
Multiplicity:
1
 

registered
private int registered
Multiplicity:
1
 

selector
private Selector selector
Multiplicity:
1
 

selectorThread
private Thread selectorThread
Multiplicity:
1
 

selectTimeOut
private long selectTimeOut
Multiplicity:
1
 

shutDownLock
private ReentrantLock shutDownLock
Multiplicity:
1
 

updates
private int updates
Multiplicity:
1
 
Constructor Detail
Multiplexor
public void Multiplexor ()
 
Stereotype:
create
 
Method Detail
attemptShutdown
private void attemptShutdown ()
 
 

cancelHandler
public void cancelHandler (SelectableChannel channel)
 
Cancel the key if exists and close the channel
Parameters:
channel
SelectableChannel
Throws:
ChannelException
 

doShutDown
private void doShutDown ()
 
Shuts down the selector after it closes down all the channels.
 

isRunning
public synchronized boolean isRunning ()
 
Synchronized.
 

processCancelations
private void processCancelations ()
 
 

processRegistrations
private void processRegistrations ()
 
 

registerHandler
public synchronized void registerHandler (SelectableChannel selectableChannel, IOHandler callback)
 
Registers an IOHandler with the selector for the provided channel. The
interest operations are provided by the IOHandler. If the channel is
already it updates the interest operations.
Synchronized.
Throws:
ChannelException
 

run
public void run ()
 
The main work is done here. First we iterate through the list and
registers the new channels or just updates the interest operations. This
has to be done on the same thread as the select(). Then block on the
select. When there are ready keys available, call the appropiate IO
handler that processes them.
 

setLogLevel
public void setLogLevel (Level logLevel)
 
 

shutDown
public synchronized void shutDown (IOHandler handler)
 
Gracefully shuts down the selector
Parameters:
handler
Synchronized.
Throws:
ExecutableException
 

start
public synchronized void start ()
 
Synchronized.
Throws:
ChannelException
 

stop
public synchronized void stop (IOHandler handler)
 
Stops the selector and cleans up
Parameters:
handler
Synchronized.
 

toString
public String toString ()
 
 

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