|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jcomponent.netserve.selector.impl.DefaultSelectorManager
The SelectorManager makes it easy to start a selector in a thread and receive events on selection.
Constructor Summary | |
DefaultSelectorManager()
|
Method Summary | |
protected SelectorMonitor |
getMonitor()
Return the monitor associated with manager. |
protected java.nio.channels.Selector |
getSelector()
Return the selector associated with reactor. |
protected Object |
getSelectorLock()
Return the lock used to synchronize access to selector. |
protected String |
getThreadName()
Return the name of thread that Selector will run in. |
boolean |
isRunning()
Return true if the selector is manager is running. |
java.nio.channels.SelectionKey |
registerChannel(java.nio.channels.SelectableChannel channel,
int ops,
SelectorEventHandler handler,
Object userData)
Register a channel with selector. |
void |
run()
This is the main connection accepting loop. |
void |
setInactive()
Set a flag to indicate reactor is inactive. |
void |
setMonitor(SelectorMonitor monitor)
Set the SelectorMonitor that receives events when changes occur. |
protected void |
setRunning(boolean running)
Set the flag to specify whether th Reactor is running. |
protected void |
setSelector(java.nio.channels.Selector selector)
Set the selector associated with reactor. |
void |
setTimeout(int timeout)
Set the timeout on the selector. |
void |
shutdown()
Method to shutdown the SelectorManager. |
protected void |
shutdownSelector()
Shutdown the selector and any associated acceptors. |
protected void |
startThread()
Start the thread to accept connections. |
void |
startup()
Initialize the selector to monitor accept attempts. |
protected void |
waitForThreadToComplete()
Wait for selector thread to complete. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DefaultSelectorManager()
Method Detail |
public void setMonitor(SelectorMonitor monitor)
monitor
- the SelectorMonitor.public void setTimeout(int timeout)
timeout
- the timeout.public void startup() throws IOException
IOException
- if unable to initialize selectorpublic void shutdown()
protected void startThread()
protected void shutdownSelector()
protected void waitForThreadToComplete()
public void setInactive()
public boolean isRunning()
public java.nio.channels.SelectionKey registerChannel(java.nio.channels.SelectableChannel channel, int ops, SelectorEventHandler handler, Object userData) throws IOException
SelectorManager
registerChannel
in interface SelectorManager
channel
- the channelops
- the operations to registerhandler
- the handler that will be notified on eventuserData
- the data passed back into the handler
IOException
- if channel can not be registeredSelectorManager.registerChannel(java.nio.channels.SelectableChannel, int, org.jcomponent.netserve.selector.SelectorEventHandler, java.lang.Object)
public void run()
run
in interface Runnable
protected Object getSelectorLock()
protected void setSelector(java.nio.channels.Selector selector)
selector
- the selector associated with reactor.protected java.nio.channels.Selector getSelector()
protected SelectorMonitor getMonitor()
protected void setRunning(boolean running)
running
- the flag to specify whether th Reactor is runningprotected String getThreadName()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |