org.tinygroup.weblayer.webcontext.session.impl
类 SessionImpl

java.lang.Object
  继承者 org.tinygroup.weblayer.webcontext.session.impl.SessionImpl
所有已实现的接口:
javax.servlet.http.HttpSession

public class SessionImpl
extends Object
implements javax.servlet.http.HttpSession

实现了HttpSession接口。

注意,每个request均会创建独立的session对象,此对象本身不是线程安全的,不能被多线程同时访问。但其后备的session store是线程安全的。


构造方法摘要
SessionImpl(String sessionID, SessionWebContext webContext, boolean isNew, boolean create)
          创建一个session对象。
 
方法摘要
protected  void assertAttributeNameForModification(String methodName, String attrName)
          检查将要更改的attr name是否合法。
protected  void assertModel(String methodName)
          确保model已经被取得,即session已被初始化。
protected  void assertValid(String methodName)
          确保session处于valid状态。
 void clear()
          清除一个session。
 void commit(boolean commitHeaders)
          提交session的内容,删除的、新增的、修改的内容被保存。
 Object getAttribute(String name)
          取得指定名称的attribute值。
 Enumeration<String> getAttributeNames()
          取得所有attributes的名称。
 long getCreationTime()
          取得session的创建时间。
 String getId()
          取得session ID。
 long getLastAccessedTime()
          取得最近访问时间。
 int getMaxInactiveInterval()
          取得session的最大不活动期限,超过此时间,session就会失效。
 javax.servlet.ServletContext getServletContext()
          取得当前session所属的servlet context。
 javax.servlet.http.HttpSessionContext getSessionContext()
          已过时。 no replacement
 SessionModel getSessionModel()
          取得当前的model。
 SessionWebContext getSessionWebContext()
          取得创建该session的request context。
 Object getValue(String name)
          已过时。 use getAttribute instead
 String[] getValueNames()
          已过时。 use getAttributeNames instead
 void invalidate()
          使一个session作废。
 boolean isInvalidated()
          判断当前session是否非法。
 boolean isNew()
          当前session是否为新的?
 void putValue(String name, Object value)
          已过时。 use setAttribute instead
 void removeAttribute(String name)
          删除一个attribute。
 void removeValue(String name)
          已过时。 use removeAttribute instead
 void setAttribute(String name, Object value)
          设置指定名称的attribute值。
 void setMaxInactiveInterval(int maxInactiveInterval)
          设置session的最大不活动期限,超过此时间,session就会失效。
 String toString()
           
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

构造方法详细信息

SessionImpl

public SessionImpl(String sessionID,
                   SessionWebContext webContext,
                   boolean isNew,
                   boolean create)
创建一个session对象。

方法详细信息

getSessionWebContext

public SessionWebContext getSessionWebContext()
取得创建该session的request context。

返回:
request context

getSessionModel

public SessionModel getSessionModel()
取得当前的model。

返回:
model对象

getId

public String getId()
取得session ID。

指定者:
接口 javax.servlet.http.HttpSession 中的 getId
返回:
session ID

getCreationTime

public long getCreationTime()
取得session的创建时间。

指定者:
接口 javax.servlet.http.HttpSession 中的 getCreationTime
返回:
创建时间戮
抛出:
IllegalStateException - 如果session已经invalidated

getLastAccessedTime

public long getLastAccessedTime()
取得最近访问时间。

指定者:
接口 javax.servlet.http.HttpSession 中的 getLastAccessedTime
返回:
最近访问时间戮
抛出:
IllegalStateException - 如果session已经invalidated

getMaxInactiveInterval

public int getMaxInactiveInterval()
取得session的最大不活动期限,超过此时间,session就会失效。

指定者:
接口 javax.servlet.http.HttpSession 中的 getMaxInactiveInterval
返回:
不活动期限的秒数

setMaxInactiveInterval

public void setMaxInactiveInterval(int maxInactiveInterval)
设置session的最大不活动期限,超过此时间,session就会失效。

指定者:
接口 javax.servlet.http.HttpSession 中的 setMaxInactiveInterval
参数:
maxInactiveInterval - 不活动期限的秒数

getServletContext

public javax.servlet.ServletContext getServletContext()
取得当前session所属的servlet context。

指定者:
接口 javax.servlet.http.HttpSession 中的 getServletContext
返回:
ServletContext对象

getAttribute

public Object getAttribute(String name)
取得指定名称的attribute值。

指定者:
接口 javax.servlet.http.HttpSession 中的 getAttribute
参数:
name - attribute名称
返回:
attribute的值
抛出:
IllegalStateException - 如果session已经invalidated

getAttributeNames

public Enumeration<String> getAttributeNames()
取得所有attributes的名称。

指定者:
接口 javax.servlet.http.HttpSession 中的 getAttributeNames
返回:
attribute名称列表
抛出:
IllegalStateException - 如果session已经invalidated

setAttribute

public void setAttribute(String name,
                         Object value)
设置指定名称的attribute值。

指定者:
接口 javax.servlet.http.HttpSession 中的 setAttribute
参数:
name - attribute名称
value - attribute的值
抛出:
IllegalStateException - 如果session已经invalidated
IllegalArgumentException - 如果指定的attribute名称不被支持

removeAttribute

public void removeAttribute(String name)
删除一个attribute。

指定者:
接口 javax.servlet.http.HttpSession 中的 removeAttribute
参数:
name - 要删除的attribute名称
抛出:
IllegalStateException - 如果session已经invalidated

invalidate

public void invalidate()
使一个session作废。

指定者:
接口 javax.servlet.http.HttpSession 中的 invalidate
抛出:
IllegalStateException - 如果session已经invalidated

clear

public void clear()
清除一个session。

抛出:
IllegalStateException - 如果session已经invalidated

isInvalidated

public boolean isInvalidated()
判断当前session是否非法。


isNew

public boolean isNew()
当前session是否为新的?

指定者:
接口 javax.servlet.http.HttpSession 中的 isNew
返回:
如果是新的,则返回true
抛出:
IllegalStateException - 如果session已经invalidated

assertModel

protected void assertModel(String methodName)
确保model已经被取得,即session已被初始化。

参数:
methodName - 当前正要执行的方法

assertValid

protected void assertValid(String methodName)
确保session处于valid状态。

参数:
methodName - 当前正要执行的方法

assertAttributeNameForModification

protected void assertAttributeNameForModification(String methodName,
                                                  String attrName)
检查将要更改的attr name是否合法。


commit

public void commit(boolean commitHeaders)
提交session的内容,删除的、新增的、修改的内容被保存。


getSessionContext

@Deprecated
public javax.servlet.http.HttpSessionContext getSessionContext()
已过时。 no replacement

指定者:
接口 javax.servlet.http.HttpSession 中的 getSessionContext

getValue

@Deprecated
public Object getValue(String name)
已过时。 use getAttribute instead

指定者:
接口 javax.servlet.http.HttpSession 中的 getValue

getValueNames

@Deprecated
public String[] getValueNames()
已过时。 use getAttributeNames instead

指定者:
接口 javax.servlet.http.HttpSession 中的 getValueNames

putValue

@Deprecated
public void putValue(String name,
                                Object value)
已过时。 use setAttribute instead

指定者:
接口 javax.servlet.http.HttpSession 中的 putValue

removeValue

@Deprecated
public void removeValue(String name)
已过时。 use removeAttribute instead

指定者:
接口 javax.servlet.http.HttpSession 中的 removeValue

toString

public String toString()
覆盖:
Object 中的 toString


Copyright © 2006–2014 开源组织. All rights reserved.