Class ConnectionController
- java.lang.Object
-
- org.restlet.ext.nio.internal.controller.Controller
-
- org.restlet.ext.nio.internal.controller.ConnectionController
-
- All Implemented Interfaces:
java.lang.Runnable,WakeupListener
- Direct Known Subclasses:
ServerConnectionController
@Deprecated public class ConnectionController extends Controller implements java.lang.Runnable, WakeupListener
Deprecated.Will be removed to favor lower-level network extensions allowing more control at the Restlet API level.Controls the IO work of parent connector helper and manages its connections.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Queue<SelectionRegistration>newRegistrationsDeprecated.The list of new selection registrations.private java.nio.channels.SelectorselectorDeprecated.The NIO selector.private java.util.Queue<SelectionRegistration>updatedRegistrationsDeprecated.The list of updated selection registrations.-
Fields inherited from class org.restlet.ext.nio.internal.controller.Controller
helper, overloaded, running
-
-
Constructor Summary
Constructors Constructor Description ConnectionController(ConnectionHelper<?> helper)Deprecated.Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidcontrolConnection(Connection<?> conn)Deprecated.Controls a given connection for messages to read or write.protected voidcontrolConnections()Deprecated.Controls all helper connections.protected java.nio.channels.SelectorcreateSelector()Deprecated.Creates a new NIO selector.protected voiddoInit()Deprecated.Initializes the controller before entering the control loop.protected voiddoRelease()Deprecated.Method called-back with the controller stops running.protected voiddoRun(long sleepTime)Deprecated.Do the actual controller work.protected java.util.Queue<SelectionRegistration>getNewRegistrations()Deprecated.Returns the queue of new selection registrations.protected java.nio.channels.SelectorgetSelector()Deprecated.Returns the NIO selector.protected java.util.Queue<SelectionRegistration>getUpdatedRegistrations()Deprecated.Returns the queue of updated selection registrations.protected voidonSelected(java.nio.channels.SelectionKey selectedKey)Deprecated.Called back when a ready key has been selected.voidonWokeup(SelectionRegistration selectionRegistration)Deprecated.Invoked when one of the connections needs to wake up the controller.SelectionRegistrationregister(java.nio.channels.SelectableChannel selectableChannel, int interestOperations, SelectionListener listener)Deprecated.Registers a selection listener with the underlying selector for the given operations and returns the registration created.protected voidregisterKeys()Deprecated.Registers all the new selection registration requests.protected voidselectKeys(long sleepTime)Deprecated.Selects the keys ready for IO operations.voidshutdown()Deprecated.Abort the controller.protected voidupdateKeys()Deprecated.Updates all the selection registrations for new interest or cancellation.voidwakeup()Deprecated.Wakes up the controller thread if wait for an NIO selection.-
Methods inherited from class org.restlet.ext.nio.internal.controller.Controller
getHelper, getWorkerService, isOverloaded, isRunning, run, setOverloaded
-
-
-
-
Field Detail
-
newRegistrations
private final java.util.Queue<SelectionRegistration> newRegistrations
Deprecated.The list of new selection registrations.
-
selector
private volatile java.nio.channels.Selector selector
Deprecated.The NIO selector.
-
updatedRegistrations
private final java.util.Queue<SelectionRegistration> updatedRegistrations
Deprecated.The list of updated selection registrations.
-
-
Constructor Detail
-
ConnectionController
public ConnectionController(ConnectionHelper<?> helper)
Deprecated.Constructor.- Parameters:
helper- The parent connector helper.
-
-
Method Detail
-
controlConnection
protected void controlConnection(Connection<?> conn) throws java.io.IOException
Deprecated.Controls a given connection for messages to read or write. Close inactive connections, select ready connections or register interest in NIO operations.- Parameters:
conn- The connection to control.- Throws:
java.io.IOException
-
controlConnections
protected void controlConnections() throws java.io.IOExceptionDeprecated.Controls all helper connections.- Throws:
java.io.IOException
-
createSelector
protected java.nio.channels.Selector createSelector()
Deprecated.Creates a new NIO selector.- Returns:
- A new NIO selector.
-
doInit
protected void doInit()
Deprecated.Description copied from class:ControllerInitializes the controller before entering the control loop.- Overrides:
doInitin classController
-
doRelease
protected void doRelease()
Deprecated.Description copied from class:ControllerMethod called-back with the controller stops running.- Overrides:
doReleasein classController
-
doRun
protected void doRun(long sleepTime) throws java.io.IOExceptionDeprecated.Description copied from class:ControllerDo the actual controller work. Called by theController.run()to provide an easy method to overload.- Overrides:
doRunin classController- Parameters:
sleepTime- The maximum amount of sleep time.- Throws:
java.io.IOException
-
getNewRegistrations
protected java.util.Queue<SelectionRegistration> getNewRegistrations()
Deprecated.Returns the queue of new selection registrations.- Returns:
- The queue of new selection registrations.
-
getSelector
protected java.nio.channels.Selector getSelector()
Deprecated.Returns the NIO selector.- Returns:
- The NIO selector.
-
getUpdatedRegistrations
protected java.util.Queue<SelectionRegistration> getUpdatedRegistrations()
Deprecated.Returns the queue of updated selection registrations.- Returns:
- The queue of updated selection registrations.
-
onSelected
protected void onSelected(java.nio.channels.SelectionKey selectedKey) throws java.io.IOExceptionDeprecated.Called back when a ready key has been selected.- Parameters:
selectedKey- The selected key selected.- Throws:
java.io.IOException
-
onWokeup
public void onWokeup(SelectionRegistration selectionRegistration) throws java.io.IOException
Deprecated.Invoked when one of the connections needs to wake up the controller.- Specified by:
onWokeupin interfaceWakeupListener- Parameters:
selectionRegistration- The selected registration.- Throws:
java.io.IOException
-
register
public SelectionRegistration register(java.nio.channels.SelectableChannel selectableChannel, int interestOperations, SelectionListener listener) throws java.io.IOException
Deprecated.Registers a selection listener with the underlying selector for the given operations and returns the registration created.- Parameters:
selectableChannel- The NIO selectable channel.interestOperations- The initial operations of interest.listener- The listener to notify.- Returns:
- The created registration.
- Throws:
java.io.IOException
-
registerKeys
protected void registerKeys()
Deprecated.Registers all the new selection registration requests.
-
selectKeys
protected void selectKeys(long sleepTime) throws java.io.IOException, java.nio.channels.ClosedByInterruptExceptionDeprecated.Selects the keys ready for IO operations.- Parameters:
sleepTime- The max sleep time.- Throws:
java.io.IOExceptionjava.nio.channels.ClosedByInterruptException
-
shutdown
public void shutdown()
Deprecated.Description copied from class:ControllerAbort the controller.- Overrides:
shutdownin classController
-
updateKeys
protected void updateKeys() throws java.io.IOExceptionDeprecated.Updates all the selection registrations for new interest or cancellation.- Throws:
java.io.IOException
-
wakeup
public void wakeup()
Deprecated.Wakes up the controller thread if wait for an NIO selection.
-
-