View Javadoc

1   /*
2    * This software was designed and created by Jason Carroll.
3    * Copyright (c) 2002, 2003, 2004 Jason Carroll.
4    * The author can be reached at jcarroll@cowsultants.com
5    * ITracker website: http://www.cowsultants.com
6    * ITracker forums: http://www.cowsultants.com/phpBB/index.php
7    *
8    * This program is free software; you can redistribute it and/or modify
9    * it only under the terms of the GNU General Public License as published by
10   * the Free Software Foundation; either version 2 of the License, or
11   * (at your option) any later version.
12   *
13   * This program is distributed in the hope that it will be useful,
14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   * GNU General Public License for more details.
17   */
18  
19  package org.itracker.web.util;
20  
21  import java.io.Serializable;
22  import java.util.Date;
23  
24  /**
25   * What's this for? Please comment!
26   * 
27   * @author ready
28   */
29  public class SessionTracker implements Serializable {
30  
31  	/**
32  	 * 
33  	 */
34  	private static final long serialVersionUID = 1L;
35  //	private static transient final Logger logger = Logger
36  //			.getLogger(SessionTracker.class);
37  	private Date now;
38  	private String login;
39  	private String sessionId;
40  
41  	public SessionTracker() {
42  		now = new Date();
43  	}
44  
45  	public SessionTracker(String login, String sessionId) {
46  		this();
47  		this.login = login;
48  		this.sessionId = sessionId;
49  	}
50  
51  	protected void finalize() throws Throwable {
52  //		if (logger.isDebugEnabled()) {
53  //			logger.debug("finalize: Invalidating SessionManager info for " + this.login);
54  //		}
55  		SessionManager.invalidateSession(this.login);
56  	}
57  
58  	public String getSessionId() {
59  		return sessionId;
60  	}
61  
62  	public void setSessionId(String sessionId) {
63  		this.sessionId = sessionId;
64  	}
65  
66  	public Date getNow() {
67  		if (null == now)
68  			return null;
69  		return new Date(now.getTime());
70  	}
71  
72  	public void setNow(Date now) {
73  		if (null == now)
74  			this.now = null;
75  		else
76  			this.now = new Date(now.getTime());
77  	}
78  }