public class Reactor
extends java.lang.Object
java.nio.channels.Selector.| Constructor and Description |
|---|
Reactor()
Creates a new instance of reactor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
disableSelectionKey(java.nio.channels.SelectionKey key)
Disable selection key - sets its interest ops to 0 and stores its current interest ops (to be restored).
|
void |
enableSelectionKey(java.nio.channels.SelectionKey key)
Enable selection key - restore its interest ops.
|
boolean |
isShutdown()
Get shutdown status.
|
boolean |
process()
Process requests.
|
java.nio.channels.SelectionKey |
register(java.nio.channels.SelectableChannel selectableChannel,
int interestOps,
ReactorHandler handler)
Registers
SelectableChannel to the reactor. |
void |
setInterestOps(java.nio.channels.spi.AbstractSelectableChannel channel,
int interestOps)
Change
SelectionKey operations of interest. |
void |
shutdown()
Shutdown the reactor.
|
void |
unregisterAndClose(java.nio.channels.SelectableChannel selectableChannel)
Unregisters
SelectableChannel from the reactor. |
public Reactor()
throws java.io.IOException
java.io.IOException - IO Exceptionpublic boolean process()
false is returned.true if selector is still active, false when shutdown.public void unregisterAndClose(java.nio.channels.SelectableChannel selectableChannel)
SelectableChannel from the reactor.selectableChannel - channel to be unregistered.public java.nio.channels.SelectionKey register(java.nio.channels.SelectableChannel selectableChannel,
int interestOps,
ReactorHandler handler)
throws java.nio.channels.ClosedChannelException
SelectableChannel to the reactor.selectableChannel - channel to be registered.interestOps - operations supported by channel (i.e. operations of interest).handler - handle to process requests.java.nio.channels.ClosedChannelException - Channel closedpublic void disableSelectionKey(java.nio.channels.SelectionKey key)
key - selection key to be disabled.public void enableSelectionKey(java.nio.channels.SelectionKey key)
key - selection key to be enabled.public void setInterestOps(java.nio.channels.spi.AbstractSelectableChannel channel,
int interestOps)
SelectionKey operations of interest.channel - channelinterestOps - interest opspublic void shutdown()
public boolean isShutdown()