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
AnIoSessionRecycler
with 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 int
getExpirationInterval()
int
getTimeToLive()
void
put(IoSession session)
Called when the underlying transport creates or writes a newIoSession
.IoSession
recycle(SocketAddress remoteAddress)
Attempts to retrieve a recycledIoSession
.void
remove(IoSession session)
Called when anIoSession
is explicitly closed.void
setExpirationInterval(int expirationInterval)
Set the interval in which a session will live in the map before it is removed.void
setTimeToLive(int timeToLive)
Update the value for the time-to-livevoid
stopExpiring()
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:
put
in interfaceIoSessionRecycler
- Parameters:
session
- the newIoSession
.
-
recycle
public IoSession recycle(SocketAddress remoteAddress)
Attempts to retrieve a recycledIoSession
.- Specified by:
recycle
in interfaceIoSessionRecycler
- Parameters:
remoteAddress
- the remote socket address of theIoSession
the transport wants to recycle.- Returns:
- a recycled
IoSession
, or null if one cannot be found.
-
remove
public void remove(IoSession session)
Called when anIoSession
is explicitly closed.- Specified by:
remove
in 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)
-
-