相关阅读
简介
用于搜索任何特定的Session
实例;
核心方法
/**
* 返回待搜索Session的ID
*/
Serializable getSessionId();
实现子类
public interface SessionKey
public class DefaultSessionKey implements SessionKey, Serializable
public class WebSessionKey extends DefaultSessionKey implements RequestPairSource
DefaultSessionKey
简介
SessionKey
接口的默认实现,维护可以由SessionManager
实现搜索Session
实例的Session ID
;
核心方法
// Session ID
private Serializable sessionId;
/**
* 构造方法
*/
public DefaultSessionKey() {
}
/**
* 构造方法
*/
public DefaultSessionKey(Serializable sessionId) {
this.sessionId = sessionId;
}
/**
* 设置SessionId
*/
public void setSessionId(Serializable sessionId) {
this.sessionId = sessionId;
}
/**
* 获取SessionId
*/
public Serializable getSessionId() {
return this.sessionId;
}
WebSessionKey
简介
保留搜索Session
的Web请求相关的ServletRequest
/ServletResponse
的SessionKey
的实现;
核心方法
// 和Web请求关联的ServletRequest实例
private final ServletRequest servletRequest;
// 和Web请求关联的ServletResponse实例
private final ServletResponse servletResponse;
/**
* 构造方法
*/
public WebSessionKey(ServletRequest request, ServletResponse response) {
if (request == null) {
throw new NullPointerException("request argument cannot be null.");
}
if (response == null) {
throw new NullPointerException("response argument cannot be null.");
}
this.servletRequest = request;
this.servletResponse = response;
}
/**
* 构造方法
*/
public WebSessionKey(Serializable sessionId, ServletRequest request, ServletResponse response) {
this(request, response);
setSessionId(sessionId);
}
/**
* 获取ServletRequest
*/
public ServletRequest getServletRequest() {
return servletRequest;
}
/**
* 获取ServletResponse
*/
public ServletResponse getServletResponse() {
return servletResponse;
}