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


Java SessionRepository类代码示例

本文整理汇总了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;
}
 
开发者ID:scionaltera,项目名称:emergentmud,代码行数:23,代码来源:WebSocketResource.java

示例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);
}
 
开发者ID:xienjiang,项目名称:session-cloud,代码行数:25,代码来源:SSOLoginService.java

示例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[]
}
 
开发者ID:spring-projects,项目名称:spring-session,代码行数:17,代码来源:IndexDocTests.java

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

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

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

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

示例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[]
}
 
开发者ID:spring-projects,项目名称:spring-session,代码行数:13,代码来源:IndexDocTests.java

示例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[]
}
 
开发者ID:spring-projects,项目名称:spring-session,代码行数:9,代码来源:IndexDocTests.java

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

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

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

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


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