Package org.apache.mina.core.session
Class ExpiringSessionRecycler
- java.lang.Object
-
- org.apache.mina.core.session.ExpiringSessionRecycler
-
- All Implemented Interfaces:
IoSessionRecycler
public class ExpiringSessionRecycler extends Object implements IoSessionRecycler
AnIoSessionRecyclerwith sessions that time out on inactivity.- Author:
- Apache MINA Project
-
-
Field Summary
-
Fields inherited from interface org.apache.mina.core.session.IoSessionRecycler
NOOP
-
-
Constructor Summary
Constructors Constructor Description ExpiringSessionRecycler()Create a new ExpiringSessionRecycler instanceExpiringSessionRecycler(int timeToLive)Create a new ExpiringSessionRecycler instanceExpiringSessionRecycler(int timeToLive, int expirationInterval)Create a new ExpiringSessionRecycler instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetExpirationInterval()intgetTimeToLive()voidput(IoSession session)Called when the underlying transport creates or writes a newIoSession.IoSessionrecycle(SocketAddress remoteAddress)Attempts to retrieve a recycledIoSession.voidremove(IoSession session)Called when anIoSessionis explicitly closed.voidsetExpirationInterval(int expirationInterval)Set the interval in which a session will live in the map before it is removed.voidsetTimeToLive(int timeToLive)Update the value for the time-to-livevoidstopExpiring()Stop the thread from monitoring the map
-
-
-
Constructor Detail
-
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 recycledexpirationInterval- The delay after which the expiration occurs
-
-
Method Detail
-
put
public void put(IoSession session)
Called when the underlying transport creates or writes a newIoSession.- Specified by:
putin interfaceIoSessionRecycler- Parameters:
session- the newIoSession.
-
recycle
public IoSession recycle(SocketAddress remoteAddress)
Attempts to retrieve a recycledIoSession.- Specified by:
recyclein interfaceIoSessionRecycler- Parameters:
remoteAddress- the remote socket address of theIoSessionthe transport wants to recycle.- Returns:
- a recycled
IoSession, or null if one cannot be found.
-
remove
public void remove(IoSession session)
Called when anIoSessionis explicitly closed.- Specified by:
removein interfaceIoSessionRecycler- Parameters:
session- the newIoSession.
-
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)
-
-