01: /*
02: * Enhydra Java Application Server Project
03: *
04: * The contents of this file are subject to the Enhydra Public License
05: * Version 1.1 (the "License"); you may not use this file except in
06: * compliance with the License. You may obtain a copy of the License on
07: * the Enhydra web site ( http://www.enhydra.org/ ).
08: *
09: * Software distributed under the License is distributed on an "AS IS"
10: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11: * the License for the specific terms governing rights and limitations
12: * under the License.
13: *
14: * The Initial Developer of the Enhydra Application Server is Lutris
15: * Technologies, Inc. The Enhydra Application Server and portions created
16: * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17: * All Rights Reserved.
18: *
19: * Contributor(s):
20: *
21: * $Id: SessionThread.java,v 1.2 2006-06-15 13:44:07 sinisa Exp $
22: */
23:
24: package com.lutris.appserver.server.sessionEnhydra;
25:
26: /**
27: * Represents a combination of a thread and a session key.
28: * A session must be associated with a thread of execution
29: * before a reference to the session can be obtained by the
30: * application. This object represents the existing thread
31: * to session association.
32: *
33: * @version $Revision: 1.2 $
34: * @author Kyle Clark
35: */
36: public class SessionThread {
37:
38: public Thread thread;
39: public String sessionKey;
40:
41: /**
42: * Creates an instance of a session-thread association.
43: *
44: * @param thread the thread to associate with a session.
45: * @param sessionKey the session key.
46: */
47: public SessionThread(Thread thread, String sessionKey) {
48: this .thread = thread;
49: this .sessionKey = sessionKey;
50: }
51:
52: /**
53: * Compares equality of two objects.
54: *
55: * @param sessionThread the reference object with which
56: * compare.
57: */
58: public boolean equals(Object sessionThread) {
59: if (!(sessionThread instanceof SessionThread)) {
60: return false;
61: }
62: SessionThread s = (SessionThread) sessionThread;
63: return (thread.equals(s.thread) && sessionKey
64: .equals(s.sessionKey));
65: }
66:
67: /**
68: * Returns string representation.
69: */
70: public String toString() {
71: return thread.toString() + "-" + sessionKey;
72: }
73:
74: /**
75: * Returns the hashcode for this object.
76: */
77: public int hashCode() {
78: return sessionKey.hashCode();
79: }
80: }
|