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


Java SessionListener类代码示例

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


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

示例1: stop

import io.undertow.server.session.SessionListener; //导入依赖的package包/类
@Override
public void stop() {
    for (Map.Entry<String, SessionImpl> session : sessions.entrySet()) {
        session.getValue().destroy();
        sessionListeners.sessionDestroyed(session.getValue(), null, SessionListener.SessionDestroyedReason.UNDEPLOY);
    }
    sessions.clear();
    this.cacheManager.stop();
}
 
开发者ID:wildfly-security,项目名称:elytron-web,代码行数:10,代码来源:InfinispanSessionManager.java

示例2: run

import io.undertow.server.session.SessionListener; //导入依赖的package包/类
@Override
public void run() {
    worker.execute(new Runnable() {
        @Override
        public void run() {
            long currentTime = System.currentTimeMillis();
            if(currentTime >= expireTime) {
                invalidate(null, SessionListener.SessionDestroyedReason.TIMEOUT);
            } else {
                timerCancelKey = executor.executeAfter(cancelTask, expireTime - currentTime, TimeUnit.MILLISECONDS);
            }
        }
    });
}
 
开发者ID:wildfly-security,项目名称:elytron-web,代码行数:15,代码来源:InfinispanSessionManager.java

示例3: invalidate

import io.undertow.server.session.SessionListener; //导入依赖的package包/类
@Override
public void invalidate(final HttpServerExchange exchange) {
    invalidate(exchange, SessionListener.SessionDestroyedReason.INVALIDATED);
    if(exchange != null) {
        exchange.removeAttachment(sessionManager.NEW_SESSION);
    }
}
 
开发者ID:wildfly-security,项目名称:elytron-web,代码行数:8,代码来源:InfinispanSessionManager.java

示例4: configureSessionManager

import io.undertow.server.session.SessionListener; //导入依赖的package包/类
protected void configureSessionManager(SessionManager sessionManager , List<Class<?>> annotatedSessionListeners ){
  SessionListenerMounter mounter = new SessionListenerMounterImpl();
  for (Class<?> annotatedClass : annotatedSessionListeners) {
    SessionListener sl = mounter.mount(annotatedClass);
    if(sl != null){
      sessionManager.registerSessionListener( sl);
    }
  }
}
 
开发者ID:EsmerilProgramming,项目名称:overtown,代码行数:10,代码来源:StartupHandlerImpl.java

示例5: doesCreateSessionListenerAndInvokeOnCreateAnnotatedMethodsOnSessionCreation

import io.undertow.server.session.SessionListener; //导入依赖的package包/类
@Test
public void doesCreateSessionListenerAndInvokeOnCreateAnnotatedMethodsOnSessionCreation(){
  SessionListener sl = mounter.mount(TestSessionListener.class);

  sl.sessionCreated( mock(Session.class) , NULL_EXCHANGE );

  assertSame( 1 , TestSessionListener.onCreateCallCounter );
  assertSame( 0 , TestSessionListener.onDestroyCallCounter );
}
 
开发者ID:EsmerilProgramming,项目名称:overtown,代码行数:10,代码来源:SessionListenerMounterTest.java

示例6: doesCreateSessionListenerAndInvokeOnDestroyAnnotatedMethodsOnSessionDestruction

import io.undertow.server.session.SessionListener; //导入依赖的package包/类
@Test
public void doesCreateSessionListenerAndInvokeOnDestroyAnnotatedMethodsOnSessionDestruction(){
  SessionListener sl = mounter.mount(TestSessionListener.class);

  sl.sessionDestroyed( mock(Session.class) , NULL_EXCHANGE , SessionDestroyedReason.TIMEOUT );

  assertSame( 1 , TestSessionListener.onDestroyCallCounter );
  assertSame( 0 , TestSessionListener.onCreateCallCounter );
}
 
开发者ID:EsmerilProgramming,项目名称:overtown,代码行数:10,代码来源:SessionListenerMounterTest.java

示例7: addSessionListener

import io.undertow.server.session.SessionListener; //导入依赖的package包/类
public DeploymentInfo addSessionListener(SessionListener sessionListener) {
    this.sessionListeners.add(sessionListener);
    return this;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:DeploymentInfo.java

示例8: getSessionListeners

import io.undertow.server.session.SessionListener; //导入依赖的package包/类
public List<SessionListener> getSessionListeners() {
    return Collections.unmodifiableList(sessionListeners);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:DeploymentInfo.java

示例9: createSession

import io.undertow.server.session.SessionListener; //导入依赖的package包/类
@Override
public Session createSession(final HttpServerExchange serverExchange, final SessionConfig config) {
    if (evictionQueue != null) {
        if(expireOldestUnusedSessionOnMax) {
            while (sessions.size() >= maxSize && !evictionQueue.isEmpty()) {

                String key = evictionQueue.poll();
                UndertowLogger.REQUEST_LOGGER.debugf("Removing session %s as max size has been hit", key);
                SessionImpl toRemove = sessions.get(key);
                if (toRemove != null) {
                    toRemove.invalidate(null, SessionListener.SessionDestroyedReason.TIMEOUT); //todo: better reason
                }
            }
        } else if(sessions.size() >= maxSize) {
            if(statisticsEnabled) {
                rejectedSessionCount.incrementAndGet();
            }
            throw UndertowMessages.MESSAGES.tooManySessions(maxSize);
        }
    }
    if (config == null) {
        throw UndertowMessages.MESSAGES.couldNotFindSessionCookieConfig();
    }
    String sessionID = config.findSessionId(serverExchange);
    int count = 0;
    while (sessionID == null) {
        sessionID = sessionIdGenerator.createSessionId();
        if(sessions.containsKey(sessionID)) {
            sessionID = null;
        }
        if(count++ == 100) {
            //this should never happen
            //but we guard against pathalogical session id generators to prevent an infinite loop
            throw UndertowMessages.MESSAGES.couldNotGenerateUniqueSessionId();
        }
    }
    Object evictionToken;
    if (evictionQueue != null) {
        evictionToken = evictionQueue.offerLastAndReturnToken(sessionID);
    } else {
        evictionToken = null;
    }
    if(statisticsEnabled) {
        createdSessionCount.incrementAndGet();
    }
    final SessionImpl session;
    if (sessions.containsKey(sessionID)) {
        SessionImpl session1 = sessions.get(sessionID);
        session = new SessionImpl(this, session1.sessionId, config, serverExchange.getIoThread(), serverExchange.getConnection().getWorker(), session1.evictionToken, defaultSessionTimeout, session1.attributes);
    } else {
        session = new SessionImpl(this, sessionID, config, serverExchange.getIoThread(), serverExchange.getConnection().getWorker(), evictionToken, defaultSessionTimeout);
    }
    sessions.put(sessionID, session);
    config.setSessionId(serverExchange, session.getId());
    session.lastAccessed = System.currentTimeMillis();
    session.bumpTimeout();
    sessionListeners.sessionCreated(session, serverExchange);
    serverExchange.putAttachment(NEW_SESSION, session);
    return session;
}
 
开发者ID:wildfly-security,项目名称:elytron-web,代码行数:61,代码来源:InfinispanSessionManager.java

示例10: registerSessionListener

import io.undertow.server.session.SessionListener; //导入依赖的package包/类
@Override
public synchronized void registerSessionListener(final SessionListener listener) {
    sessionListeners.addSessionListener(listener);
}
 
开发者ID:wildfly-security,项目名称:elytron-web,代码行数:5,代码来源:InfinispanSessionManager.java

示例11: removeSessionListener

import io.undertow.server.session.SessionListener; //导入依赖的package包/类
@Override
public synchronized void removeSessionListener(final SessionListener listener) {
    sessionListeners.removeSessionListener(listener);
}
 
开发者ID:wildfly-security,项目名称:elytron-web,代码行数:5,代码来源:InfinispanSessionManager.java

示例12: doesCreateASessionListenerFromAGenericClass

import io.undertow.server.session.SessionListener; //导入依赖的package包/类
@Test
public void doesCreateASessionListenerFromAGenericClass(){
   SessionListener sl = mounter.mount(TestSessionListener.class);

   assertNotNull(sl);
}
 
开发者ID:EsmerilProgramming,项目名称:overtown,代码行数:7,代码来源:SessionListenerMounterTest.java

示例13: mount

import io.undertow.server.session.SessionListener; //导入依赖的package包/类
SessionListener mount(Class<?> annotatedClass); 
开发者ID:EsmerilProgramming,项目名称:overtown,代码行数:2,代码来源:SessionListenerMounter.java


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