本文整理汇总了Java中org.springframework.session.ExpiringSession类的典型用法代码示例。如果您正苦于以下问题:Java ExpiringSession类的具体用法?Java ExpiringSession怎么用?Java ExpiringSession使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExpiringSession类属于org.springframework.session包,在下文中一共展示了ExpiringSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSession
import org.springframework.session.ExpiringSession; //导入依赖的package包/类
@Override
public ExpiringSession getSession(final String id)
{
final ExpiringSession saved = sessions.get(id);
if (saved == null)
{
return null;
}
if (saved.isExpired())
{
final boolean expired = true;
deleteAndFireEvent(saved.getId(), expired);
return null;
}
return new MapSession(saved);
}
示例2: deleteAndFireEvent
import org.springframework.session.ExpiringSession; //导入依赖的package包/类
private void deleteAndFireEvent(final String id, boolean expired)
{
final ExpiringSession deletedSession = sessions.remove(id);
// Fire event
if (deletedSession != null)
{
if (expired)
{
applicationEventPublisher.publishEvent(new SessionExpiredEvent(this, id));
}
else
{
applicationEventPublisher.publishEvent(new SessionDeletedEvent(this, id));
}
}
}
示例3: purgeExpiredSessions
import org.springframework.session.ExpiringSession; //导入依赖的package包/类
public void purgeExpiredSessions()
{
final Stopwatch stopwatch = Stopwatch.createStarted();
int countExpiredSessions = 0;
final List<ExpiringSession> sessionsToCheck = new ArrayList<>(sessions.values());
for (final ExpiringSession session : sessionsToCheck)
{
if (session.isExpired())
{
deleteAndFireEvent(session.getId(), true /* expired */);
countExpiredSessions++;
}
}
logger.debug("Purged {}/{} expired sessions in {}", countExpiredSessions, sessionsToCheck.size(), stopwatch);
}
示例4: createHttpSessionEvent
import org.springframework.session.ExpiringSession; //导入依赖的package包/类
private HttpSessionEvent createHttpSessionEvent(AbstractSessionEvent event) {
ExpiringSession session = event.getSession();
HttpSession httpSession = new ExpiringSessionHttpSession<ExpiringSession>(session,
this.context);
HttpSessionEvent httpSessionEvent = new HttpSessionEvent(httpSession);
return httpSessionEvent;
}
示例5: entryExpired
import org.springframework.session.ExpiringSession; //导入依赖的package包/类
@CacheEntryExpired
public void entryExpired(CacheEntryExpiredEvent<String, ExpiringSession> event) {
if (logger.isDebugEnabled()) {
logger.debug("Session expired with id: " + event.getValue().getId());
}
eventPublisher.publishEvent(new SessionExpiredEvent(this, event.getValue()));
}
示例6: entryRemoved
import org.springframework.session.ExpiringSession; //导入依赖的package包/类
@CacheEntryRemoved
public void entryRemoved(CacheEntryRemovedEvent<String, ExpiringSession> event) {
if (logger.isDebugEnabled()) {
logger.debug("Session expired with id: " + event.getOldValue().getId());
}
eventPublisher.publishEvent(new SessionDeletedEvent(this, event.getOldValue()));
}
示例7: put
import org.springframework.session.ExpiringSession; //导入依赖的package包/类
@Override
public ExpiringSession put(String key, ExpiringSession value) {
if (value == null) {
return cache.put(key, value);
}
return cache.put(key, value, timeToLive, TimeUnit.MILLISECONDS, value.getMaxInactiveIntervalInSeconds(),
TimeUnit.SECONDS);
}
示例8: createSession
import org.springframework.session.ExpiringSession; //导入依赖的package包/类
@Override
public ExpiringSession createSession()
{
final ExpiringSession result = new MapSession();
if (defaultMaxInactiveInterval != null)
{
result.setMaxInactiveIntervalInSeconds(defaultMaxInactiveInterval);
}
// Fire event
applicationEventPublisher.publishEvent(new SessionCreatedEvent(this, result.getId()));
return result;
}
示例9: InvalidClassExceptionSafeRepository
import org.springframework.session.ExpiringSession; //导入依赖的package包/类
public InvalidClassExceptionSafeRepository(SessionRepository<S> repository,
RedisTemplate<String, ExpiringSession> sessionRedisTemplate,
CounterService counterService) {
this.repository = repository;
this.sessionRedisTemplate = sessionRedisTemplate;
this.counterService = counterService;
}
示例10: SpringSessionBackedSessionInformation
import org.springframework.session.ExpiringSession; //导入依赖的package包/类
public SpringSessionBackedSessionInformation(ExpiringSession session, SessionRepository<? extends ExpiringSession> sessionRepository) {
super(resolvePrincipal(session), session.getId(), new Date(session.getLastAccessedTime()));
this.sessionRepository = sessionRepository;
if (session.isExpired()) {
super.expireNow();
}
}
开发者ID:jkuipers,项目名称:spring-session-concurrent-session-control,代码行数:8,代码来源:SpringSessionBackedSessionInformation.java
示例11: getSessionInformation
import org.springframework.session.ExpiringSession; //导入依赖的package包/类
@Override
public SessionInformation getSessionInformation(String sessionId) {
ExpiringSession session = sessionRepository.getSession(sessionId);
if (session != null) {
return new SpringSessionBackedSessionInformation(session, sessionRepository);
}
return null;
}
开发者ID:jkuipers,项目名称:spring-session-concurrent-session-control,代码行数:9,代码来源:SpringSessionBackedSessionRegistry.java
示例12: listSessions
import org.springframework.session.ExpiringSession; //导入依赖的package包/类
@RequestMapping("/")
String listSessions(Principal principal, HttpSession session, Model model) {
Collection<? extends ExpiringSession> userSessions = sessions.findByIndexNameAndIndexValue(PRINCIPAL_NAME_INDEX_NAME, principal.getName()).values();
model.addAttribute("sessions", userSessions);
// this gives us the correct session ID, as the HttpSession is backed by Spring Session:
model.addAttribute("currSessionId", session.getId());
return "index";
}
示例13: sessionRepository
import org.springframework.session.ExpiringSession; //导入依赖的package包/类
@Bean
public SessionRepository<ExpiringSession> sessionRepository(
SessionProperties properties) {
MapSessionRepository repository = new MapSessionRepository();
Integer timeout = properties.getTimeout();
if (timeout != null) {
repository.setDefaultMaxInactiveInterval(timeout);
}
return repository;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:HashMapSessionConfiguration.java
示例14: redisTemplate
import org.springframework.session.ExpiringSession; //导入依赖的package包/类
/**
* SpringSession config
* @return
* @throws Exception
*/
@Bean
public RedisTemplate<String,ExpiringSession> redisTemplate() throws Exception {
RedisTemplate<String, ExpiringSession> template = new RedisTemplate<>();
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());
template.setConnectionFactory(redisConnectionFactory);
return template;
}
示例15: sessionRepository
import org.springframework.session.ExpiringSession; //导入依赖的package包/类
@Bean
public SessionRepository<ExpiringSession> sessionRepository() {
return new MapSessionRepository();
}