Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 31 32 package org.opencms.main; 33 34 import org.opencms.file.CmsRequestContext; 35 import org.opencms.file.CmsUser; 36 37 import org.apache.commons.collections.Buffer; 38 import org.apache.commons.collections.BufferUtils; 39 import org.apache.commons.collections.buffer.BoundedFifoBuffer; 40 41 59 public class CmsSessionInfo implements Comparable { 60 61 62 public static final int QUEUE_SIZE = 10; 63 64 65 private Buffer m_broadcastQueue; 66 67 68 private int m_maxInactiveInterval; 69 70 71 private int m_projectId; 72 73 74 private String m_sessionId; 75 76 77 private String m_siteRoot; 78 79 80 private long m_timeCreated; 81 82 83 private long m_timeUpdated; 84 85 86 private CmsUser m_user; 87 88 95 public CmsSessionInfo(CmsRequestContext context, String sessionId, int maxInactiveInterval) { 96 97 m_timeCreated = System.currentTimeMillis(); 98 m_sessionId = sessionId; 99 m_maxInactiveInterval = maxInactiveInterval; 100 m_user = context.currentUser(); 101 update(context); 102 m_broadcastQueue = BufferUtils.synchronizedBuffer(new BoundedFifoBuffer(QUEUE_SIZE)); 103 } 104 105 110 public int compareTo(Object obj) { 111 112 if (obj == this) { 113 return 0; 114 } 115 if (!(obj instanceof CmsSessionInfo)) { 116 return m_user.getName().compareTo(((CmsSessionInfo)obj).getUser().getName()); 117 } 118 return 0; 119 } 120 121 126 public Buffer getBroadcastQueue() { 127 128 return m_broadcastQueue; 129 } 130 131 142 public int getMaxInactiveInterval() { 143 144 return m_maxInactiveInterval; 145 } 146 147 152 public int getProject() { 153 154 return m_projectId; 155 } 156 157 164 public String getSessionId() { 165 166 return m_sessionId; 167 } 168 169 174 public String getSiteRoot() { 175 176 return m_siteRoot; 177 } 178 179 185 public long getTimeActive() { 186 187 return m_timeUpdated - m_timeCreated; 188 } 189 190 195 public long getTimeCreated() { 196 197 return m_timeCreated; 198 } 199 200 205 public long getTimeUpdated() { 206 207 return m_timeUpdated; 208 } 209 210 215 public CmsUser getUser() { 216 217 return m_user; 218 } 219 220 226 public boolean isExpired() { 227 228 return ((System.currentTimeMillis() - m_timeUpdated) / 1000) > m_maxInactiveInterval; 229 } 230 231 236 public void setProject(int projectId) { 237 238 m_projectId = projectId; 239 } 240 241 247 protected void update(CmsRequestContext context) { 248 249 m_timeUpdated = System.currentTimeMillis(); 250 m_siteRoot = context.getSiteRoot(); 251 setProject(context.currentProject().getId()); 252 } 253 }
| Popular Tags
|