Class ExpiringSessionRecycler
java.lang.Object
org.apache.mina.core.session.ExpiringSessionRecycler
- All Implemented Interfaces:
IoSessionRecycler
An
IoSessionRecycler with sessions that time out on inactivity.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ExpiringMap<String, IoSession>.ExpirerA map used to keep a track of the expirationprivate ExpiringMap<String, IoSession> A map used to store the sessionFields inherited from interface IoSessionRecycler
NOOP -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new ExpiringSessionRecycler instanceExpiringSessionRecycler(int timeToLive) Create a new ExpiringSessionRecycler instanceExpiringSessionRecycler(int timeToLive, int expirationInterval) Create a new ExpiringSessionRecycler instance -
Method Summary
Modifier and TypeMethodDescriptionintintvoidCalled when the underlying transport creates or writes a newIoSession.recycle(SocketAddress remoteAddress, int port) Attempts to retrieve a recycledIoSession.voidCalled 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-livevoidStop the thread from monitoring the map
-
Field Details
-
sessionMap
A map used to store the session -
mapExpirer
A map used to keep a track of the expiration
-
-
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 recycledexpirationInterval- The delay after which the expiration occurs
-
-
Method Details
-
put
Called when the underlying transport creates or writes a newIoSession.- Specified by:
putin interfaceIoSessionRecycler- Parameters:
session- the newIoSession.
-
recycle
Attempts to retrieve a recycledIoSession.- Specified by:
recyclein interfaceIoSessionRecycler- Parameters:
remoteAddress- the remote socket address of theIoSessionthe 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
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)
-