當前位置: 首頁>>代碼示例>>Java>>正文


Java Session.getId方法代碼示例

本文整理匯總了Java中org.apache.shiro.session.Session.getId方法的典型用法代碼示例。如果您正苦於以下問題:Java Session.getId方法的具體用法?Java Session.getId怎麽用?Java Session.getId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.shiro.session.Session的用法示例。


在下文中一共展示了Session.getId方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: validateSessions

import org.apache.shiro.session.Session; //導入方法依賴的package包/類
@Override
public void validateSessions() {
	Collection<?> activeSessions = getActiveSessions();
	if (null != activeSessions && !activeSessions.isEmpty()) {
		for (Iterator<?> i$ = activeSessions.iterator(); i$.hasNext();) {
			Session session = (Session) i$.next();
			try {
				SessionKey key = new DefaultSessionKey(session.getId());
				validate(session, key);
			} catch (InvalidSessionException e) {
				if (null != cacheManager) {
					SimpleSession s = (SimpleSession) session;
					if (null != s.getAttribute(Constant.SESSION_ID))
						cacheManager.getCache(null).remove(s.getAttribute(Constant.SESSION_ID));
				}
			}
		}
	}
}
 
開發者ID:jiangzongyao,項目名稱:kettle_support_kettle8.0,代碼行數:20,代碼來源:DefaultSessionManager.java

示例2: doUpdate

import org.apache.shiro.session.Session; //導入方法依賴的package包/類
@Override
protected void doUpdate(Session session) {
	if (session == null || session.getId() == null) {
		return;
	}

	HttpServletRequest request = Servlets.getRequest();
	if (request != null) {
		String uri = request.getServletPath();
		// 如果是靜態文件,則不更新SESSION
		if (Servlets.isStaticFile(uri)) {
			return;
		}
		// 如果是視圖文件,則不更新SESSION
		if (StringUtils.startsWith(uri, Global.getConfig("web.view.prefix")) && StringUtils.endsWith(uri, Global.getConfig("web.view.suffix"))) {
			return;
		}
		// 手動控製不更新SESSION
		String updateSession = request.getParameter("updateSession");
		if (Global.FALSE.equals(updateSession) || Global.NO.equals(updateSession)) {
			return;
		}
	}
	super.doUpdate(session);
	logger.debug("update {} {}", session.getId(), request != null ? request.getRequestURI() : "");
}
 
開發者ID:funtl,項目名稱:framework,代碼行數:27,代碼來源:CacheSessionDAO.java

示例3: delete

import org.apache.shiro.session.Session; //導入方法依賴的package包/類
@Override
public void delete(Session session) {
	if (session == null || session.getId() == null) {
		return;
	}

	Jedis jedis = null;
	try {
		jedis = JedisUtils.getResource();

		jedis.hdel(JedisUtils.getBytesKey(sessionKeyPrefix), JedisUtils.getBytesKey(session.getId().toString()));
		jedis.del(JedisUtils.getBytesKey(sessionKeyPrefix + session.getId()));

		logger.debug("delete {} ", session.getId());
	} catch (Exception e) {
		logger.error("delete {} ", session.getId(), e);
	} finally {
		JedisUtils.returnResource(jedis);
	}
}
 
開發者ID:funtl,項目名稱:framework,代碼行數:21,代碼來源:JedisSessionDAO.java

示例4: saveSession

import org.apache.shiro.session.Session; //導入方法依賴的package包/類
/**
 * save session
 * @param session
 * @throws UnknownSessionException
 */
private void saveSession(Session session) throws UnknownSessionException{
    if(session == null || session.getId() == null){
        logger.error("session or session id is null");
        return;
    }
    
    byte[] key = getByteKey(session.getId());
    byte[] value = JavaSerializeUtil.serialize(session);
    session.setTimeout(expire*1000);
    try {
        this.jedisClient.set(key, value, expire);
    }catch (Exception e){
        e.printStackTrace();
    }
}
 
開發者ID:babymm,項目名稱:mumu,代碼行數:21,代碼來源:RedisSessionDAO.java

示例5: saveSession

import org.apache.shiro.session.Session; //導入方法依賴的package包/類
@Override
public void saveSession(Session session) {
    if (session == null || session.getId() == null)
        throw new NullPointerException("session is empty");
    try {
        byte[] key = generateRedisSessionKey(session.getId()).getBytes();
        
        //不存在才添加。
        if(null == session.getAttribute(UserSessionServiceImpl.SESSION_STATUS)){
        	//session狀態
        	SessionStatus sessionStatus = new SessionStatus();
        	session.setAttribute(UserSessionServiceImpl.SESSION_STATUS, sessionStatus);
        }
        
        byte[] value = SerializeUtil.serialize(session);
        long sessionTimeOut = session.getTimeout() / 1000;
        Long expireTime = sessionTimeOut + SESSION_VAL_TIME_SPAN + (5 * 60);
        getRedisManager().saveValueByKey(DB_INDEX, key, value, expireTime.intValue());
    } catch (Exception e) {
    	logger.error("save session error,id:"+session.getId(), e);
    }
}
 
開發者ID:wjggwm,項目名稱:webside,代碼行數:23,代碼來源:RedisShiroSessionRepository.java

示例6: delete

import org.apache.shiro.session.Session; //導入方法依賴的package包/類
@Override
public void delete(Session session) {
	if (session == null || session.getId() == null) {
		return;
	}
	
	Jedis jedis = null;
	try {
		jedis = JedisUtils.getResource();
		
		jedis.hdel(JedisUtils.getBytesKey(sessionKeyPrefix), JedisUtils.getBytesKey(session.getId().toString()));
		jedis.del(JedisUtils.getBytesKey(sessionKeyPrefix + session.getId()));

		logger.debug("delete {} ", session.getId());
	} catch (Exception e) {
		logger.error("delete {} ", session.getId(), e);
	} finally {
		JedisUtils.returnResource(jedis);
	}
}
 
開發者ID:egojit8,項目名稱:easyweb,代碼行數:21,代碼來源:JedisSessionDAO.java

示例7: doDelete

import org.apache.shiro.session.Session; //導入方法依賴的package包/類
@Override
protected void doDelete(Session session) {
	if (session == null || session.getId() == null) {
		return;
	}

	super.doDelete(session);
	logger.debug("delete {} ", session.getId());
}
 
開發者ID:funtl,項目名稱:framework,代碼行數:10,代碼來源:CacheSessionDAO.java

示例8: doCreate

import org.apache.shiro.session.Session; //導入方法依賴的package包/類
@Override
protected Serializable doCreate(Session session) {
	HttpServletRequest request = Servlets.getRequest();
	if (request != null) {
		String uri = request.getServletPath();
		// 如果是靜態文件,則不創建SESSION
		if (Servlets.isStaticFile(uri)) {
			return null;
		}
	}
	super.doCreate(session);
	logger.debug("doCreate {} {}", session, request != null ? request.getRequestURI() : "");
	return session.getId();
}
 
開發者ID:funtl,項目名稱:framework,代碼行數:15,代碼來源:CacheSessionDAO.java

示例9: delete

import org.apache.shiro.session.Session; //導入方法依賴的package包/類
public void delete(Session session) {
    if (session != null) {
        Serializable id = session.getId();
        if (id != null) {
            RedisConnection redisConnection = getRedisConnection();
            try {
                redisConnection.del(buildRedisSessionKey(id));
            } finally {
                redisConnection.close();
            }
        }
    }
}
 
開發者ID:iBase4J,項目名稱:iBase4J-Common,代碼行數:14,代碼來源:RedisSessionDAO.java

示例10: saveSession

import org.apache.shiro.session.Session; //導入方法依賴的package包/類
private void saveSession(Session session) {
    if (session == null || session.getId() == null) throw new UnknownSessionException("session is empty");
    byte[] sessionKey = buildRedisSessionKey(session.getId());
    int sessionTimeOut = PropertiesUtil.getInt("session.maxInactiveInterval", EXPIRE_TIME);
    byte[] value = SerializeUtil.serialize(session);
    RedisConnection redisConnection = getRedisConnection();
    try {
        redisConnection.set(sessionKey, value, Expiration.seconds(sessionTimeOut), SetOption.UPSERT);
    } finally {
        redisConnection.close();
    }
}
 
開發者ID:iBase4J,項目名稱:iBase4J-Common,代碼行數:13,代碼來源:RedisSessionDAO.java

示例11: delete

import org.apache.shiro.session.Session; //導入方法依賴的package包/類
@Override
public void delete(Session session) {
	logger.info("delete session "+session.toString());
    if(session == null || session.getId() == null){
        logger.error("session or session id is null");
        return;
    }
    jedisClient.del(this.getByteKey(session.getId()));

}
 
開發者ID:babymm,項目名稱:mumu,代碼行數:11,代碼來源:RedisSessionDAO.java

示例12: delete

import org.apache.shiro.session.Session; //導入方法依賴的package包/類
@Override  
public void delete(Session session) {  
    if (session == null) {  
    	logger.error("Session 不能為null");
        return;  
    }  
    Serializable id = session.getId();  
    if (id != null)  
    	shiroSessionRepository.deleteSession(id);  
}
 
開發者ID:wjggwm,項目名稱:webside,代碼行數:11,代碼來源:ShiroSessionDAO.java

示例13: saveSession

import org.apache.shiro.session.Session; //導入方法依賴的package包/類
@Override
public void saveSession(Session session) {
    if (session == null || session.getId() == null)
        throw new NullPointerException("session is empty");
    try {
    	cacheManager.getCache(this.activeSessionsCacheName).put(session.getId(), SerializeUtil.serialize(session));
    } catch (Exception e) {
    	logger.error("save session error,id:"+session.getId(), e);
    }
}
 
開發者ID:wjggwm,項目名稱:webside,代碼行數:11,代碼來源:EhCacheShiroSessionRepository.java

示例14: doUpdate

import org.apache.shiro.session.Session; //導入方法依賴的package包/類
@Override
  protected void doUpdate(Session session) {
  	if (session == null || session.getId() == null) {  
          return;
      }
  	
  	HttpServletRequest request = Servlets.getRequest();
if (request != null){
	String uri = request.getServletPath();
	// 如果是靜態文件,則不更新SESSION
	if (Servlets.isStaticFile(uri)){
		return;
	}
	// 如果是視圖文件,則不更新SESSION
	if (StringUtils.startsWith(uri, Global.getInstance().getConfig("app.view.prefix"))
			&& StringUtils.endsWith(uri, Global.getInstance().getConfig("app.view.suffix"))){
		return;
	}
	// 手動控製不更新SESSION
	String updateSession = request.getParameter("updateSession");
	if (Global.FALSE.equals(updateSession) || Global.NO.equals(updateSession)){
		return;
	}
}
  	super.doUpdate(session);
  	logger.debug("update {} {}", session.getId(), request != null ? request.getRequestURI() : "");
  }
 
開發者ID:egojit8,項目名稱:easyweb,代碼行數:28,代碼來源:CacheSessionDAO.java

示例15: doDelete

import org.apache.shiro.session.Session; //導入方法依賴的package包/類
@Override
protected void doDelete(Session session) {
	if (session == null || session.getId() == null) {  
        return;
    }
	
	super.doDelete(session);
	logger.debug("delete {} ", session.getId());
}
 
開發者ID:egojit8,項目名稱:easyweb,代碼行數:10,代碼來源:CacheSessionDAO.java


注:本文中的org.apache.shiro.session.Session.getId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。