当前位置: 首页>>代码示例>>Java>>正文


Java ExpiringSession类代码示例

本文整理汇总了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);
}
 
开发者ID:metasfresh,项目名称:metasfresh-webui-api,代码行数:18,代码来源:FixedMapSessionRepository.java

示例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));
		}
	}
}
 
开发者ID:metasfresh,项目名称:metasfresh-webui-api,代码行数:18,代码来源:FixedMapSessionRepository.java

示例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);
}
 
开发者ID:metasfresh,项目名称:metasfresh-webui-api,代码行数:18,代码来源:FixedMapSessionRepository.java

示例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;
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:8,代码来源:SessionEventHttpSessionListenerAdapter.java

示例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()));
}
 
开发者ID:kazuhira-r,项目名称:spring-session-infinispan,代码行数:9,代码来源:EmbeddedSessionEntryListener.java

示例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()));
}
 
开发者ID:kazuhira-r,项目名称:spring-session-infinispan,代码行数:8,代码来源:EmbeddedSessionEntryListener.java

示例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);
}
 
开发者ID:kazuhira-r,项目名称:spring-session-infinispan,代码行数:10,代码来源:ExpiringSessionMap.java

示例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;
}
 
开发者ID:metasfresh,项目名称:metasfresh-webui-api,代码行数:15,代码来源:FixedMapSessionRepository.java

示例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;
}
 
开发者ID:Catalysts,项目名称:cat-boot,代码行数:8,代码来源:InvalidClassExceptionSafeRepository.java

示例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";
}
 
开发者ID:jkuipers,项目名称:spring-session-concurrent-session-control,代码行数:9,代码来源:App.java

示例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;
}
 
开发者ID:bjornharvold,项目名称:bearchoke,代码行数:14,代码来源:RedisConfig.java

示例15: sessionRepository

import org.springframework.session.ExpiringSession; //导入依赖的package包/类
@Bean
public SessionRepository<ExpiringSession> sessionRepository() {
	return new MapSessionRepository();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:5,代码来源:BasicAuthSecurityConfiguration.java


注:本文中的org.springframework.session.ExpiringSession类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。