Class 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.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      protected void controlConnection​(Connection<?> conn)
      Deprecated.
      Controls a given connection for messages to read or write.
      protected void controlConnections()
      Deprecated.
      Controls all helper connections.
      protected java.nio.channels.Selector createSelector()
      Deprecated.
      Creates a new NIO selector.
      protected void doInit()
      Deprecated.
      Initializes the controller before entering the control loop.
      protected void doRelease()
      Deprecated.
      Method called-back with the controller stops running.
      protected void doRun​(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.Selector getSelector()
      Deprecated.
      Returns the NIO selector.
      protected java.util.Queue<SelectionRegistration> getUpdatedRegistrations()
      Deprecated.
      Returns the queue of updated selection registrations.
      protected void onSelected​(java.nio.channels.SelectionKey selectedKey)
      Deprecated.
      Called back when a ready key has been selected.
      void onWokeup​(SelectionRegistration selectionRegistration)
      Deprecated.
      Invoked when one of the connections needs to wake up the controller.
      SelectionRegistration register​(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 void registerKeys()
      Deprecated.
      Registers all the new selection registration requests.
      protected void selectKeys​(long sleepTime)
      Deprecated.
      Selects the keys ready for IO operations.
      void shutdown()
      Deprecated.
      Abort the controller.
      protected void updateKeys()
      Deprecated.
      Updates all the selection registrations for new interest or cancellation.
      void wakeup()
      Deprecated.
      Wakes up the controller thread if wait for an NIO selection.
      • 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
    • 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.IOException
        Deprecated.
        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: Controller
        Initializes the controller before entering the control loop.
        Overrides:
        doInit in class Controller
      • doRelease

        protected void doRelease()
        Deprecated.
        Description copied from class: Controller
        Method called-back with the controller stops running.
        Overrides:
        doRelease in class Controller
      • doRun

        protected void doRun​(long sleepTime)
                      throws java.io.IOException
        Deprecated.
        Description copied from class: Controller
        Do the actual controller work. Called by the Controller.run() to provide an easy method to overload.
        Overrides:
        doRun in class Controller
        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.IOException
        Deprecated.
        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:
        onWokeup in interface WakeupListener
        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.ClosedByInterruptException
        Deprecated.
        Selects the keys ready for IO operations.
        Parameters:
        sleepTime - The max sleep time.
        Throws:
        java.io.IOException
        java.nio.channels.ClosedByInterruptException
      • shutdown

        public void shutdown()
        Deprecated.
        Description copied from class: Controller
        Abort the controller.
        Overrides:
        shutdown in class Controller
      • updateKeys

        protected void updateKeys()
                           throws java.io.IOException
        Deprecated.
        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.