Class ExpiringSessionRecycler

java.lang.Object
org.apache.mina.core.session.ExpiringSessionRecycler
All Implemented Interfaces:
IoSessionRecycler

public class ExpiringSessionRecycler extends Object implements IoSessionRecycler
An IoSessionRecycler with sessions that time out on inactivity.
  • Field Details

  • Constructor Details

    • ExpiringSessionRecycler

      public ExpiringSessionRecycler()
      Create a new ExpiringSessionRecycler instance
    • ExpiringSessionRecycler

      public ExpiringSessionRecycler(int timeToLive)
      Create a new ExpiringSessionRecycler instance
      Parameters:
      timeToLive - The delay after which the session is going to be recycled
    • ExpiringSessionRecycler

      public ExpiringSessionRecycler(int timeToLive, int expirationInterval)
      Create a new ExpiringSessionRecycler instance
      Parameters:
      timeToLive - The delay after which the session is going to be recycled
      expirationInterval - The delay after which the expiration occurs
  • Method Details

    • put

      public void put(IoSession session)
      Called when the underlying transport creates or writes a new IoSession.
      Specified by:
      put in interface IoSessionRecycler
      Parameters:
      session - the new IoSession.
    • recycle

      public IoSession recycle(SocketAddress remoteAddress, int port)
      Attempts to retrieve a recycled IoSession.
      Specified by:
      recycle in interface IoSessionRecycler
      Parameters:
      remoteAddress - the remote socket address of the IoSession the transport wants to recycle.
      port - The port the Acceptor is listening on* @param port The port the Acceptor is listening on
      Returns:
      a recycled IoSession, or null if one cannot be found.
    • remove

      public void remove(IoSession session)
      Called when an IoSession is explicitly closed.
      Specified by:
      remove in interface IoSessionRecycler
      Parameters:
      session - the new IoSession.
    • stopExpiring

      public void stopExpiring()
      Stop the thread from monitoring the map
    • getExpirationInterval

      public int getExpirationInterval()
      Returns:
      The session expiration time in second
    • getTimeToLive

      public int getTimeToLive()
      Returns:
      The session time-to-live in second
    • setExpirationInterval

      public void setExpirationInterval(int expirationInterval)
      Set the interval in which a session will live in the map before it is removed.
      Parameters:
      expirationInterval - The session expiration time in seconds
    • setTimeToLive

      public void setTimeToLive(int timeToLive)
      Update the value for the time-to-live
      Parameters:
      timeToLive - The time-to-live (seconds)