-
-
Save seyedsahil/43503ffea73f327479d2a9a4fa69fe78 to your computer and use it in GitHub Desktop.
get set and remove demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package demo; | |
import java.util.Date; | |
public class SessionContextHolder { | |
public Session retrieve() { | |
Session session = sessionContext.get(); | |
if (session == null) { | |
return create(); | |
} | |
Date currentTimeStamp = new Date(); | |
if (new Date().getTime() - session.getTimestamp().getTime() > 3000) { | |
sessionContext.remove(); | |
return create(); | |
} | |
return session; | |
} | |
private Session create() { | |
Session session = new Session(); | |
sessionContext.set(session); | |
return session; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment