KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > appserver > server > sessionEnhydra > SessionThread


1
2 /*
3  * Enhydra Java Application Server Project
4  *
5  * The contents of this file are subject to the Enhydra Public License
6  * Version 1.1 (the "License"); you may not use this file except in
7  * compliance with the License. You may obtain a copy of the License on
8  * the Enhydra web site ( http://www.enhydra.org/ ).
9  *
10  * Software distributed under the License is distributed on an "AS IS"
11  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
12  * the License for the specific terms governing rights and limitations
13  * under the License.
14  *
15  * The Initial Developer of the Enhydra Application Server is Lutris
16  * Technologies, Inc. The Enhydra Application Server and portions created
17  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
18  * All Rights Reserved.
19  *
20  * Contributor(s):
21  *
22  * $Id: SessionThread.java,v 1.2 2005/03/24 10:51:20 slobodan Exp $
23  */

24
25 package com.lutris.appserver.server.sessionEnhydra;
26
27
28
29 /**
30  * Represents a combination of a thread and a session key.
31  * A session must be associated with a thread of execution
32  * before a reference to the session can be obtained by the
33  * application. This object represents the existing thread
34  * to session association.
35  *
36  * @version $Revision: 1.2 $
37  * @author Kyle Clark
38  */

39 public class SessionThread {
40
41     public Thread JavaDoc thread;
42     public String JavaDoc sessionKey;
43
44     /**
45      * Creates an instance of a session-thread association.
46      *
47      * @param thread the thread to associate with a session.
48      * @param sessionKey the session key.
49      */

50     public SessionThread(Thread JavaDoc thread, String JavaDoc sessionKey) {
51         this.thread = thread;
52         this.sessionKey = sessionKey;
53     }
54
55     /**
56      * Compares equality of two objects.
57      *
58      * @param sessionThread the reference object with which
59      * compare.
60      */

61     public boolean equals(Object JavaDoc sessionThread) {
62         if (!(sessionThread instanceof SessionThread)) {
63             return false;
64         }
65         SessionThread s = (SessionThread)sessionThread;
66         return (thread.equals(s.thread)
67                 && sessionKey.equals(s.sessionKey));
68     }
69
70     /**
71      * Returns string representation.
72      */

73     public String JavaDoc toString() {
74         return thread.toString() + "-" + sessionKey;
75     }
76
77     /**
78      * Returns the hashcode for this object.
79      */

80     public int hashCode() {
81         return sessionKey.hashCode();
82     }
83 }
84
85
Popular Tags