• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SessionCreatedEvent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.session.events.SessionCreatedEvent的典型用法代码示例。如果您正苦于以下问题:Java SessionCreatedEvent类的具体用法?Java SessionCreatedEvent怎么用?Java SessionCreatedEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SessionCreatedEvent类属于org.springframework.session.events包,在下文中一共展示了SessionCreatedEvent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onApplicationEvent

import org.springframework.session.events.SessionCreatedEvent; //导入依赖的package包/类
public void onApplicationEvent(AbstractSessionEvent event) {
	if (this.listeners.isEmpty()) {
		return;
	}

	HttpSessionEvent httpSessionEvent = createHttpSessionEvent(event);

	for (HttpSessionListener listener : this.listeners) {
		if (event instanceof SessionDestroyedEvent) {
			listener.sessionDestroyed(httpSessionEvent);
		}
		else if (event instanceof SessionCreatedEvent) {
			listener.sessionCreated(httpSessionEvent);
		}
	}
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:17,代码来源:SessionEventHttpSessionListenerAdapter.java


示例2: expiredSessionTest

import org.springframework.session.events.SessionCreatedEvent; //导入依赖的package包/类
@Test
public void expiredSessionTest() throws InterruptedException {
    S sessionToSave = repository.createSession();

    repository.save(sessionToSave);

    assertThat(registry.receivedEvent(sessionToSave.getId())).isTrue();
    assertThat((EventObject) registry.getEvent(sessionToSave.getId()))
            .isInstanceOf(SessionCreatedEvent.class);

    registry.clear();

    assertThat(sessionToSave.getMaxInactiveIntervalInSeconds())
            .isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS);

    assertThat(registry.receivedEvent(sessionToSave.getId())).isTrue();
    assertThat((EventObject) registry.getEvent(sessionToSave.getId()))
            .isInstanceOf(SessionExpiredEvent.class);

    assertThat(repository.getSession(sessionToSave.getId())).isNull();
}
 
开发者ID:kazuhira-r,项目名称:spring-session-infinispan,代码行数:22,代码来源:AbstractEnableInfinispanHttpSessionEventsITests.java


示例3: deletedSessionTest

import org.springframework.session.events.SessionCreatedEvent; //导入依赖的package包/类
@Test
public void deletedSessionTest() throws InterruptedException {
    S sessionToSave = repository.createSession();

    repository.save(sessionToSave);

    assertThat(registry.receivedEvent(sessionToSave.getId())).isTrue();
    assertThat((EventObject) registry.getEvent(sessionToSave.getId()))
            .isInstanceOf(SessionCreatedEvent.class);

    registry.clear();

    repository.delete(sessionToSave.getId());

    assertThat(registry.receivedEvent(sessionToSave.getId())).isTrue();
    assertThat((EventObject) registry.getEvent(sessionToSave.getId()))
            .isInstanceOf(SessionDeletedEvent.class);

    assertThat(repository.getSession(sessionToSave.getId())).isNull();
}
 
开发者ID:kazuhira-r,项目名称:spring-session-infinispan,代码行数:21,代码来源:AbstractEnableInfinispanHttpSessionEventsITests.java


示例4: onApplicationEvent

import org.springframework.session.events.SessionCreatedEvent; //导入依赖的package包/类
@Override
public void onApplicationEvent(AbstractSessionEvent event) {
	if (this.listeners.isEmpty()) {
		return;
	}

	HttpSessionEvent httpSessionEvent = createHttpSessionEvent(event);

	for (HttpSessionListener listener : this.listeners) {
		if (event instanceof SessionDestroyedEvent) {
			listener.sessionDestroyed(httpSessionEvent);
		}
		else if (event instanceof SessionCreatedEvent) {
			listener.sessionCreated(httpSessionEvent);
		}
	}
}
 
开发者ID:spring-projects,项目名称:spring-session,代码行数:18,代码来源:SessionEventHttpSessionListenerAdapter.java


示例5: expiredSessionTest

import org.springframework.session.events.SessionCreatedEvent; //导入依赖的package包/类
@Test
public void expiredSessionTest() throws InterruptedException {
	S sessionToSave = this.repository.createSession();

	this.repository.save(sessionToSave);

	assertThat(this.registry.receivedEvent(sessionToSave.getId())).isTrue();
	assertThat(this.registry.<SessionCreatedEvent>getEvent(sessionToSave.getId()))
			.isInstanceOf(SessionCreatedEvent.class);
	this.registry.clear();

	assertThat(sessionToSave.getMaxInactiveInterval())
			.isEqualTo(Duration.ofSeconds(MAX_INACTIVE_INTERVAL_IN_SECONDS));

	assertThat(this.registry.receivedEvent(sessionToSave.getId())).isTrue();
	assertThat(this.registry.<SessionExpiredEvent>getEvent(sessionToSave.getId()))
			.isInstanceOf(SessionExpiredEvent.class);

	assertThat(this.repository.<Session>findById(sessionToSave.getId())).isNull();
}
 
开发者ID:spring-projects,项目名称:spring-session,代码行数:21,代码来源:EnableHazelcastHttpSessionEventsTests.java


示例6: deletedSessionTest

import org.springframework.session.events.SessionCreatedEvent; //导入依赖的package包/类
@Test
public void deletedSessionTest() throws InterruptedException {
	S sessionToSave = this.repository.createSession();

	this.repository.save(sessionToSave);

	assertThat(this.registry.receivedEvent(sessionToSave.getId())).isTrue();
	assertThat(this.registry.<SessionCreatedEvent>getEvent(sessionToSave.getId()))
			.isInstanceOf(SessionCreatedEvent.class);
	this.registry.clear();

	this.repository.deleteById(sessionToSave.getId());

	assertThat(this.registry.receivedEvent(sessionToSave.getId())).isTrue();
	assertThat(this.registry.<SessionDeletedEvent>getEvent(sessionToSave.getId()))
			.isInstanceOf(SessionDeletedEvent.class);

	assertThat(this.repository.findById(sessionToSave.getId())).isNull();
}
 
开发者ID:spring-projects,项目名称:spring-session,代码行数:20,代码来源:EnableHazelcastHttpSessionEventsTests.java


示例7: onApplicationEvent

import org.springframework.session.events.SessionCreatedEvent; //导入依赖的package包/类
@Override
public void onApplicationEvent(AbstractSessionEvent event) {
    if (event instanceof SessionCreatedEvent) {
        sessionCreatedEvents++;
    }
    if (event instanceof SessionDeletedEvent) {
        sessionDeletedEvents++;
    }
    if (event instanceof SessionExpiredEvent) {
        sessionExpiredEvents++;
    }
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:13,代码来源:SessionEventsListener.java


示例8: entryCreated

import org.springframework.session.events.SessionCreatedEvent; //导入依赖的package包/类
@ClientCacheEntryCreated
public void entryCreated(ClientCacheEntryCreatedEvent<String> event) {
    if (logger.isDebugEnabled()) {
        logger.debug("Session created with id: " + event.getKey());
    }
    eventPublisher.publishEvent(new SessionCreatedEvent(this, event.getKey()));
}
 
开发者ID:kazuhira-r,项目名称:spring-session-infinispan,代码行数:8,代码来源:RemoteSessionEntryListener.java


示例9: saveSessionTest

import org.springframework.session.events.SessionCreatedEvent; //导入依赖的package包/类
@Test
public void saveSessionTest() throws InterruptedException {
    String username = "saves-" + System.currentTimeMillis();

    S sessionToSave = repository.createSession();

    String expectedAttributeName = "a";
    String expectedAttributeValue = "b";
    sessionToSave.setAttribute(expectedAttributeName, expectedAttributeValue);
    Authentication toSaveToken = new UsernamePasswordAuthenticationToken(username,
            "password", AuthorityUtils.createAuthorityList("ROLE_USER"));
    SecurityContext toSaveContext = SecurityContextHolder.createEmptyContext();
    toSaveContext.setAuthentication(toSaveToken);
    sessionToSave.setAttribute("SPRING_SECURITY_CONTEXT", toSaveContext);
    sessionToSave.setAttribute(
            FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, username);

    repository.save(sessionToSave);

    assertThat(registry.receivedEvent(sessionToSave.getId())).isTrue();
    assertThat((EventObject) registry.getEvent(sessionToSave.getId()))
            .isInstanceOf(SessionCreatedEvent.class);

    Session session = repository.getSession(sessionToSave.getId());

    assertThat(session.getId()).isEqualTo(sessionToSave.getId());
    assertThat(session.getAttributeNames())
            .isEqualTo(sessionToSave.getAttributeNames());
    assertThat((String) session.getAttribute(expectedAttributeName))
            .isEqualTo(sessionToSave.getAttribute(expectedAttributeName));
}
 
开发者ID:kazuhira-r,项目名称:spring-session-infinispan,代码行数:32,代码来源:AbstractEnableInfinispanHttpSessionEventsITests.java


示例10: createSession

import org.springframework.session.events.SessionCreatedEvent; //导入依赖的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


示例11: createSession

import org.springframework.session.events.SessionCreatedEvent; //导入依赖的package包/类
@Override
public CouchbaseSession createSession() {
    CouchbaseSession session = new CouchbaseSession(sessionTimeout);
    Map<String, Map<String, Object>> sessionData = new HashMap<>(2);
    sessionData.put(GLOBAL_NAMESPACE, session.getGlobalAttributes());
    sessionData.put(namespace, session.getNamespaceAttributes());
    SessionDocument sessionDocument = new SessionDocument(session.getId(), sessionData);
    dao.save(sessionDocument);
    dao.updateExpirationTime(session.getId(), getSessionDocumentExpiration());
    eventPublisher.publishEvent(new SessionCreatedEvent(this, session));

    log.debug("HTTP session with ID {} has been created", session.getId());

    return session;
}
 
开发者ID:mkopylec,项目名称:session-couchbase-spring-boot-starter,代码行数:16,代码来源:CouchbaseSessionRepository.java


示例12: setup

import org.springframework.session.events.SessionCreatedEvent; //导入依赖的package包/类
@Before
public void setup() {
	this.listener = new SessionEventHttpSessionListenerAdapter(
			Arrays.asList(this.listener1, this.listener2));
	this.listener.setServletContext(new MockServletContext());

	Session session = new MapSession();
	this.destroyed = new SessionDestroyedEvent(this, session);
	this.created = new SessionCreatedEvent(this, session);
}
 
开发者ID:spring-projects,项目名称:spring-session,代码行数:11,代码来源:SessionEventHttpSessionListenerAdapterTests.java


示例13: entryAdded

import org.springframework.session.events.SessionCreatedEvent; //导入依赖的package包/类
@Override
public void entryAdded(EntryEvent<String, MapSession> event) {
	if (logger.isDebugEnabled()) {
		logger.debug("Session created with id: " + event.getValue().getId());
	}
	this.eventPublisher.publishEvent(new SessionCreatedEvent(this, event.getValue()));
}
 
开发者ID:spring-projects,项目名称:spring-session,代码行数:8,代码来源:HazelcastSessionRepository.java


示例14: saveSessionTest

import org.springframework.session.events.SessionCreatedEvent; //导入依赖的package包/类
@Test
public void saveSessionTest() throws InterruptedException {
	String username = "saves-" + System.currentTimeMillis();

	S sessionToSave = this.repository.createSession();

	String expectedAttributeName = "a";
	String expectedAttributeValue = "b";
	sessionToSave.setAttribute(expectedAttributeName, expectedAttributeValue);
	Authentication toSaveToken = new UsernamePasswordAuthenticationToken(username,
			"password", AuthorityUtils.createAuthorityList("ROLE_USER"));
	SecurityContext toSaveContext = SecurityContextHolder.createEmptyContext();
	toSaveContext.setAuthentication(toSaveToken);
	sessionToSave.setAttribute("SPRING_SECURITY_CONTEXT", toSaveContext);
	sessionToSave.setAttribute(
			FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, username);

	this.repository.save(sessionToSave);

	assertThat(this.registry.receivedEvent(sessionToSave.getId())).isTrue();
	assertThat(this.registry.<SessionCreatedEvent>getEvent(sessionToSave.getId()))
			.isInstanceOf(SessionCreatedEvent.class);

	Session session = this.repository.findById(sessionToSave.getId());

	assertThat(session.getId()).isEqualTo(sessionToSave.getId());
	assertThat(session.getAttributeNames())
			.isEqualTo(sessionToSave.getAttributeNames());
	assertThat(session.<String>getAttribute(expectedAttributeName))
			.isEqualTo(sessionToSave.getAttribute(expectedAttributeName));
}
 
开发者ID:spring-projects,项目名称:spring-session,代码行数:32,代码来源:EnableHazelcastHttpSessionEventsTests.java


示例15: entryCreated

import org.springframework.session.events.SessionCreatedEvent; //导入依赖的package包/类
@CacheEntryCreated
public void entryCreated(CacheEntryCreatedEvent<String, ExpiringSession> event) {
    if (logger.isDebugEnabled()) {
        logger.debug("Session created with id: " + event.getValue().getId());
    }
    eventPublisher.publishEvent(new SessionCreatedEvent(this, event.getValue()));
}
 
开发者ID:kazuhira-r,项目名称:spring-session-infinispan,代码行数:8,代码来源:EmbeddedSessionEntryListener.java


示例16: onSessionCreated

import org.springframework.session.events.SessionCreatedEvent; //导入依赖的package包/类
@EventListener
public void onSessionCreated(SessionCreatedEvent createdEvent) {
    sessionCreated = true;
}
 
开发者ID:mkopylec,项目名称:session-couchbase-spring-boot-starter,代码行数:5,代码来源:SessionEventConsumer.java


示例17: handleCreated

import org.springframework.session.events.SessionCreatedEvent; //导入依赖的package包/类
private void handleCreated(Map<Object, Object> loaded, String channel) {
	String id = channel.substring(channel.lastIndexOf(":") + 1);
	Session session = loadSession(id, loaded);
	publishEvent(new SessionCreatedEvent(this, session));
}
 
开发者ID:spring-projects,项目名称:spring-session,代码行数:6,代码来源:RedisOperationsSessionRepository.java


示例18: saves

import org.springframework.session.events.SessionCreatedEvent; //导入依赖的package包/类
@Test
public void saves() throws InterruptedException {
	String username = "saves-" + System.currentTimeMillis();

	String usernameSessionKey = "RedisOperationsSessionRepositoryITests:index:"
			+ INDEX_NAME + ":" + username;

	RedisSession toSave = this.repository.createSession();
	String expectedAttributeName = "a";
	String expectedAttributeValue = "b";
	toSave.setAttribute(expectedAttributeName, expectedAttributeValue);
	Authentication toSaveToken = new UsernamePasswordAuthenticationToken(username,
			"password", AuthorityUtils.createAuthorityList("ROLE_USER"));
	SecurityContext toSaveContext = SecurityContextHolder.createEmptyContext();
	toSaveContext.setAuthentication(toSaveToken);
	toSave.setAttribute(SPRING_SECURITY_CONTEXT, toSaveContext);
	toSave.setAttribute(INDEX_NAME, username);
	this.registry.clear();

	this.repository.save(toSave);

	assertThat(this.registry.receivedEvent(toSave.getId())).isTrue();
	assertThat(this.registry.<SessionCreatedEvent>getEvent(toSave.getId()))
			.isInstanceOf(SessionCreatedEvent.class);
	assertThat(this.redis.boundSetOps(usernameSessionKey).members())
			.contains(toSave.getId());

	Session session = this.repository.findById(toSave.getId());

	assertThat(session.getId()).isEqualTo(toSave.getId());
	assertThat(session.getAttributeNames()).isEqualTo(toSave.getAttributeNames());
	assertThat(session.<String>getAttribute(expectedAttributeName))
			.isEqualTo(toSave.getAttribute(expectedAttributeName));

	this.registry.clear();

	this.repository.deleteById(toSave.getId());

	assertThat(this.repository.findById(toSave.getId())).isNull();
	assertThat(this.registry.<SessionDestroyedEvent>getEvent(toSave.getId()))
			.isInstanceOf(SessionDestroyedEvent.class);
	assertThat(this.redis.boundSetOps(usernameSessionKey).members())
			.doesNotContain(toSave.getId());

	assertThat(this.registry.getEvent(toSave.getId()).getSession()
			.<String>getAttribute(expectedAttributeName))
			.isEqualTo(expectedAttributeValue);
}
 
开发者ID:spring-projects,项目名称:spring-session,代码行数:49,代码来源:RedisOperationsSessionRepositoryITests.java


示例19: createSession

import org.springframework.session.events.SessionCreatedEvent; //导入依赖的package包/类
/**
 * Creates a new {@link MongoSession} that is capable of being persisted by this
 * {@link ReactiveSessionRepository}.
 * <p>
 * This allows optimizations and customizations in how the {@link MongoSession} is
 * persisted. For example, the implementation returned might keep track of the changes
 * ensuring that only the delta needs to be persisted on a save.
 * </p>
 *
 * @return a new {@link MongoSession} that is capable of being persisted by this
 * {@link ReactiveSessionRepository}
 */
@Override
public Mono<MongoSession> createSession() {

	return Mono.justOrEmpty(this.maxInactiveIntervalInSeconds)
		.map(MongoSession::new)
		.map(mongoSession -> {
			publishEvent(new SessionCreatedEvent(this, mongoSession));
			return mongoSession;
		})
		.switchIfEmpty(Mono.just(new MongoSession()));
}
 
开发者ID:spring-projects,项目名称:spring-session-data-mongodb,代码行数:24,代码来源:ReactiveMongoOperationsSessionRepository.java


示例20: createSession

import org.springframework.session.events.SessionCreatedEvent; //导入依赖的package包/类
@Override
public MongoSession createSession() {

	MongoSession session = new MongoSession();

	if (this.maxInactiveIntervalInSeconds != null) {
		session.setMaxInactiveInterval(Duration.ofSeconds(this.maxInactiveIntervalInSeconds));
	}

	publishEvent(new SessionCreatedEvent(this, session));
	
	return session;
}
 
开发者ID:spring-projects,项目名称:spring-session-data-mongodb,代码行数:14,代码来源:MongoOperationsSessionRepository.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ColorInput类代码示例发布时间:2022-05-22
下一篇:
Java BoxParser类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap