当前位置: 首页>>代码示例>>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;未经允许,请勿转载。