|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.restlet.engine.connector.Controller
org.restlet.engine.connector.ConnectionController
public class ConnectionController
Controls the IO work of parent connector helper and manages its connections.
Field Summary |
---|
Fields inherited from class org.restlet.engine.connector.Controller |
---|
helper, overloaded, running |
Constructor Summary | |
---|---|
ConnectionController(ConnectionHelper<?> helper)
Constructor. |
Method Summary | |
---|---|
protected void |
controlConnection(Connection<?> conn)
Controls a given connection for messages to read or write. |
protected void |
controlConnections()
Controls all helper connections. |
protected java.nio.channels.Selector |
createSelector()
Creates a new NIO selector. |
protected void |
doInit()
Initializes the controller before entering the control loop. |
protected void |
doRelease()
Method called-back with the controller stops running. |
protected void |
doRun(long sleepTime)
Do the actual controller work. |
protected java.util.Queue<SelectionRegistration> |
getNewRegistrations()
Returns the queue of new selection registrations. |
protected java.nio.channels.Selector |
getSelector()
Returns the NIO selector. |
protected java.util.Queue<SelectionRegistration> |
getUpdatedRegistrations()
Returns the queue of updated selection registrations. |
protected void |
onSelected(java.nio.channels.SelectionKey selectedKey)
Called back when a ready key has been selected. |
void |
onWokeup(SelectionRegistration selectionRegistration)
Invoked when one of the connections needs to wake up the controller. |
SelectionRegistration |
register(java.nio.channels.SelectableChannel selectableChannel,
int interestOperations,
SelectionListener listener)
Registers a selection listener with the underlying selector for the given operations and returns the registration created. |
protected void |
registerKeys()
Registers all the new selection registration requests. |
protected void |
selectKeys(long sleepTime)
Selects the keys ready for IO operations. |
void |
shutdown()
Abort the controller. |
protected void |
updateKeys()
Updates all the selection registrations for new interest or cancellation. |
void |
wakeup()
Wakes up the controller thread if wait for an NIO selection. |
Methods inherited from class org.restlet.engine.connector.Controller |
---|
getHelper, getWorkerService, isOverloaded, isRunning, run, setOverloaded |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.lang.Runnable |
---|
run |
Constructor Detail |
---|
public ConnectionController(ConnectionHelper<?> helper)
helper
- The parent connector helper.Method Detail |
---|
protected void controlConnection(Connection<?> conn)
conn
- The connection to control.protected void controlConnections() throws java.io.IOException
java.io.IOException
protected java.nio.channels.Selector createSelector()
protected void doInit()
Controller
doInit
in class Controller
protected void doRelease()
Controller
doRelease
in class Controller
protected void doRun(long sleepTime) throws java.io.IOException
Controller
Controller.run()
to provide an
easy method to overload.
doRun
in class Controller
sleepTime
- The maximum amount of sleep time.
java.io.IOException
protected java.util.Queue<SelectionRegistration> getNewRegistrations()
protected java.nio.channels.Selector getSelector()
protected java.util.Queue<SelectionRegistration> getUpdatedRegistrations()
protected void onSelected(java.nio.channels.SelectionKey selectedKey) throws java.io.IOException
selectedKey
- The selected key selected.
java.io.IOException
public void onWokeup(SelectionRegistration selectionRegistration) throws java.io.IOException
onWokeup
in interface WakeupListener
selectionRegistration
- The selected registration.
java.io.IOException
public SelectionRegistration register(java.nio.channels.SelectableChannel selectableChannel, int interestOperations, SelectionListener listener) throws java.io.IOException
selectableChannel
- The NIO selectable channel.interestOperations
- The initial operations of interest.listener
- The listener to notify.
java.io.IOException
protected void registerKeys()
protected void selectKeys(long sleepTime) throws java.io.IOException, java.nio.channels.ClosedByInterruptException
sleepTime
- The max sleep time.
java.io.IOException
java.nio.channels.ClosedByInterruptException
public void shutdown()
Controller
shutdown
in class Controller
protected void updateKeys() throws java.io.IOException
java.io.IOException
public void wakeup()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |