本文整理汇总了Java中org.springframework.session.SessionRepository类的典型用法代码示例。如果您正苦于以下问题:Java SessionRepository类的具体用法?Java SessionRepository怎么用?Java SessionRepository使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SessionRepository类属于org.springframework.session包,在下文中一共展示了SessionRepository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: WebSocketResource
import org.springframework.session.SessionRepository; //导入依赖的package包/类
@Inject
public WebSocketResource(String applicationVersion,
Long applicationBootDate,
ApplicationContext applicationContext,
SessionRepository sessionRepository,
EntityRepository entityRepository,
CommandMetadataRepository commandMetadataRepository,
EmoteMetadataRepository emoteMetadataRepository,
CapabilityRepository capabilityRepository,
PromptBuilder promptBuilder,
Emote emote) {
this.applicationVersion = applicationVersion;
this.applicationBootDate = applicationBootDate;
this.applicationContext = applicationContext;
this.sessionRepository = sessionRepository;
this.entityRepository = entityRepository;
this.commandMetadataRepository = commandMetadataRepository;
this.emoteMetadataRepository = emoteMetadataRepository;
this.capabilityRepository = capabilityRepository;
this.promptBuilder = promptBuilder;
this.emote = emote;
}
示例2: doSSOLogin
import org.springframework.session.SessionRepository; //导入依赖的package包/类
public static void doSSOLogin(HttpServletRequest httpRequest) {
HttpSessionManager sessionManager =(HttpSessionManager) httpRequest.getAttribute(HttpSessionManager.class.getName());
String alias = httpRequest.getParameter("_s");
SessionRepository<Session> sessionRepository =
(SessionRepository<Session>) httpRequest.getAttribute(SessionRepository.class.getName());
for(Map.Entry<String, String> entry : sessionManager.getSessionIds(httpRequest).entrySet()) {
String aliasId = entry.getKey();
String sessionValue = entry.getValue();
Session session = sessionRepository.getSession(sessionValue);
HttpSession httpSession = httpRequest.getSession();
if(session != null && session.getAttribute("username") != null && httpSession.getAttribute("username") == null ) {
httpSession.setAttribute("username", session.getAttribute("username"));
}
log.info("[SSOLoginService] doSSOLogin aliasId {} : session value{}",aliasId,sessionValue);
}
if(StringUtils.isEmpty(alias)) {
alias = sessionManager.getNewSessionAlias(httpRequest);
}
httpRequest.setAttribute("alias",alias);
}
示例3: newJdbcOperationsSessionRepository
import org.springframework.session.SessionRepository; //导入依赖的package包/类
@Test
@SuppressWarnings("unused")
public void newJdbcOperationsSessionRepository() {
// tag::new-jdbcoperationssessionrepository[]
JdbcTemplate jdbcTemplate = new JdbcTemplate();
// ... configure JdbcTemplate ...
PlatformTransactionManager transactionManager = new DataSourceTransactionManager();
// ... configure transactionManager ...
SessionRepository<? extends Session> repository =
new JdbcOperationsSessionRepository(jdbcTemplate, transactionManager);
// end::new-jdbcoperationssessionrepository[]
}
示例4: doFilterAdapterGetRequestedSessionId
import org.springframework.session.SessionRepository; //导入依赖的package包/类
@Test
public void doFilterAdapterGetRequestedSessionId() throws Exception {
SessionRepository<MapSession> sessionRepository = spy(
new MapSessionRepository(new ConcurrentHashMap<>()));
this.filter = new SessionRepositoryFilter<>(sessionRepository);
this.filter.setHttpSessionIdResolver(this.strategy);
final String expectedId = "HttpSessionIdResolver-requested-id";
given(this.strategy.resolveSessionIds(any(HttpServletRequest.class)))
.willReturn(Collections.singletonList(expectedId));
given(sessionRepository.findById(anyString()))
.willReturn(new MapSession(expectedId));
doFilter(new DoInFilter() {
@Override
public void doFilter(HttpServletRequest wrappedRequest,
HttpServletResponse wrappedResponse) throws IOException {
String actualId = wrappedRequest.getRequestedSessionId();
assertThat(actualId).isEqualTo(expectedId);
}
});
}
示例5: doFilterLazySessionCreation
import org.springframework.session.SessionRepository; //导入依赖的package包/类
@Test
public void doFilterLazySessionCreation() throws Exception {
SessionRepository<MapSession> sessionRepository = spy(
new MapSessionRepository(new ConcurrentHashMap<>()));
this.filter = new SessionRepositoryFilter<>(sessionRepository);
doFilter(new DoInFilter() {
@Override
public void doFilter(HttpServletRequest wrappedRequest,
HttpServletResponse wrappedResponse) throws IOException {
}
});
verifyZeroInteractions(sessionRepository);
}
示例6: SessionRepositoryFilter
import org.springframework.session.SessionRepository; //导入依赖的package包/类
/**
* Creates a new instance.
*
* @param sessionRepository the <code>SessionRepository</code> to use. Cannot be null.
*/
public SessionRepositoryFilter(SessionRepository<S> sessionRepository) {
if (sessionRepository == null) {
throw new IllegalArgumentException("sessionRepository cannot be null");
}
this.sessionRepository = sessionRepository;
}
示例7: InvalidClassExceptionSafeRepository
import org.springframework.session.SessionRepository; //导入依赖的package包/类
public InvalidClassExceptionSafeRepository(SessionRepository<S> repository,
RedisTemplate<String, ExpiringSession> sessionRedisTemplate,
CounterService counterService) {
this.repository = repository;
this.sessionRedisTemplate = sessionRedisTemplate;
this.counterService = counterService;
}
示例8: SpringSessionBackedSessionInformation
import org.springframework.session.SessionRepository; //导入依赖的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
示例9: sessionRepository
import org.springframework.session.SessionRepository; //导入依赖的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
示例10: newRedisOperationsSessionRepository
import org.springframework.session.SessionRepository; //导入依赖的package包/类
@Test
@SuppressWarnings("unused")
public void newRedisOperationsSessionRepository() {
// tag::new-redisoperationssessionrepository[]
RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
// ... configure redisTemplate ...
SessionRepository<? extends Session> repository =
new RedisOperationsSessionRepository(redisTemplate);
// end::new-redisoperationssessionrepository[]
}
示例11: mapRepository
import org.springframework.session.SessionRepository; //导入依赖的package包/类
@Test
@SuppressWarnings("unused")
public void mapRepository() {
// tag::new-mapsessionrepository[]
SessionRepository<? extends Session> repository = new MapSessionRepository(
new ConcurrentHashMap<>());
// end::new-mapsessionrepository[]
}
示例12: SessionRepositoryMessageInterceptor
import org.springframework.session.SessionRepository; //导入依赖的package包/类
/**
* Creates a new instance.
*
* @param sessionRepository the {@link SessionRepository} to use. Cannot be null.
*/
public SessionRepositoryMessageInterceptor(SessionRepository<S> sessionRepository) {
Assert.notNull(sessionRepository, "sessionRepository cannot be null");
this.sessionRepository = sessionRepository;
this.matchingMessageTypes = EnumSet.of(SimpMessageType.CONNECT,
SimpMessageType.MESSAGE, SimpMessageType.SUBSCRIBE,
SimpMessageType.UNSUBSCRIBE);
}
示例13: SpringSessionBackedSessionInformation
import org.springframework.session.SessionRepository; //导入依赖的package包/类
SpringSessionBackedSessionInformation(S session,
SessionRepository<S> sessionRepository) {
super(resolvePrincipal(session), session.getId(),
Date.from(session.getLastAccessedTime()));
this.sessionRepository = sessionRepository;
Boolean expired = session.getAttribute(EXPIRED_ATTR);
if (Boolean.TRUE.equals(expired)) {
super.expireNow();
}
}
示例14: springSessionRepositoryFilter
import org.springframework.session.SessionRepository; //导入依赖的package包/类
@Bean
public <S extends Session> SessionRepositoryFilter<? extends Session> springSessionRepositoryFilter(
SessionRepository<S> sessionRepository) {
SessionRepositoryFilter<S> sessionRepositoryFilter = new SessionRepositoryFilter<>(
sessionRepository);
sessionRepositoryFilter.setServletContext(this.servletContext);
sessionRepositoryFilter.setHttpSessionIdResolver(this.httpSessionIdResolver);
return sessionRepositoryFilter;
}
示例15: defaultConfiguration
import org.springframework.session.SessionRepository; //导入依赖的package包/类
@Test
public void defaultConfiguration() {
registerAndRefresh(DefaultConfiguration.class);
assertThat(this.context.getBean(SessionEventHttpSessionListenerAdapter.class))
.isNotNull();
assertThat(this.context.getBean(SessionRepositoryFilter.class)).isNotNull();
assertThat(this.context.getBean(SessionRepository.class)).isNotNull();
}