00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 package org.openmobileis.common.context;
00030
00031 import java.util.Calendar;
00032 import java.util.Enumeration;
00033 import java.util.Hashtable;
00034
00035 import javax.servlet.ServletContext;
00036 import javax.servlet.http.HttpSession;
00037 import javax.servlet.http.HttpSessionContext;
00038
00039 public class SessionContext implements HttpSession {
00040
00041 private String sessionId;
00042 private Hashtable attributMap = null;
00043 private Hashtable namesMap = null;
00044 private long lastAccessTime;
00045 private int MaxInactiveInterval;
00046 private boolean isNew = false;
00047 private long creationTime;
00048 private UserTerminal terminal;
00049 private String userId;
00050 private String userGroup;
00051
00052
00053 public String getUserGroup() {
00054 return userGroup;
00055 }
00056
00057 public void setUserGroup(String userGroup) {
00058 this.userGroup = userGroup;
00059 }
00060
00061 public String getUserId() {
00062 return userId;
00063 }
00064
00065 public void setUserId(String userId) {
00066 this.userId = userId;
00067 }
00068
00069 public SessionContext(String id) {
00070 sessionId = id;
00071 attributMap = new Hashtable(10);
00072 namesMap = new Hashtable(10);
00073 this.creationTime = Calendar.getInstance().getTime().getTime();
00074 }
00075
00076 public long getCreationTime() {
00077 return creationTime;
00078 }
00079
00080
00081 public String getId() {
00082 return sessionId;
00083 }
00084
00085
00086 public long getLastAccessedTime() {
00087 return lastAccessTime;
00088 }
00089
00090
00091 public ServletContext getServletContext() {
00092
00093 return null;
00094 }
00095
00096
00097 public void setMaxInactiveInterval(int arg0) {
00098 MaxInactiveInterval = arg0;
00099 }
00100
00101
00102 public int getMaxInactiveInterval() {
00103 return MaxInactiveInterval;
00104 }
00105
00106
00107 public HttpSessionContext getSessionContext() {
00108
00109 return null;
00110 }
00111
00112 public Object getAttribute(String attributName) {
00113 if (attributName != null) {
00114 return attributMap.get(attributName);
00115 }
00116 return null;
00117 }
00118
00119
00120
00121 public Object getValue(String name) {
00122 if (name != null) {
00123 return namesMap.get(name);
00124 }
00125 return null;
00126 }
00127
00128
00129 public Enumeration getAttributeNames() {
00130 return namesMap.keys();
00131 }
00132
00133
00134 public String[] getValueNames() {
00135
00136 Enumeration enum = namesMap.keys();
00137 String[] names = new String[10];
00138 int i = 0;
00139 while(enum.hasMoreElements()){
00140 names[i] = enum.toString();
00141 enum.nextElement();
00142 i++;
00143 }
00144 return names;
00145 }
00146
00147
00148 public void setAttribute(String attributName, Object attribut) {
00149 if ((attributName != null) && (attribut != null)) {
00150 attributMap.put(attributName, attribut);
00151 }
00152 }
00153
00154
00155 public void putValue(String name, Object obj) {
00156 if ((name != null) && (obj != null)) {
00157 namesMap.put(name, obj);
00158 }
00159 }
00160
00161
00162 public void removeAttribute(String attributName) {
00163 if (attributName != null) {
00164 attributMap.remove(attributName);
00165 }
00166 }
00167
00168
00169 public void removeValue(String name) {
00170 if (name != null) {
00171 namesMap.remove(name);
00172 }
00173 }
00178 public void clearAttribute() {
00179
00180 }
00181
00182
00183 public void invalidate() {
00184 SessionContextManager.getManager().invalidateSession(sessionId);
00185 }
00186
00187 public void SetIsNew(boolean bool){
00188 isNew = bool;
00189 }
00190
00191 public boolean isNew() {
00192 return isNew;
00193 }
00194
00195 public UserTerminal getTerminal() {
00196 return terminal;
00197 }
00198
00199 public void setTerminal(UserTerminal terminal) {
00200 this.terminal = terminal;
00201 }
00202
00203 }