KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > servlet > http > HttpSessionBindingEvent


1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */

17
18 package javax.servlet.http;
19
20
21
22 /**
23  *
24  * Events of this type are either sent to an object that implements
25  * {@link HttpSessionBindingListener} when it is bound or
26  * unbound from a session, or to a {@link HttpSessionAttributeListener}
27  * that has been configured in the deployment descriptor when any attribute is
28  * bound, unbound or replaced in a session.
29  *
30  * <p>The session binds the object by a call to
31  * <code>HttpSession.setAttribute</code> and unbinds the object
32  * by a call to <code>HttpSession.removeAttribute</code>.
33  *
34  *
35  *
36  * @author Various
37  * @version $Version$
38  *
39  * @see HttpSession
40  * @see HttpSessionBindingListener
41  * @see HttpSessionAttributeListener
42  */

43
44 public class HttpSessionBindingEvent extends HttpSessionEvent JavaDoc {
45
46
47
48
49     /* The name to which the object is being bound or unbound */
50
51     private String JavaDoc name;
52     
53     /* The object is being bound or unbound */
54
55     private Object JavaDoc value;
56     
57   
58
59     /**
60      *
61      * Constructs an event that notifies an object that it
62      * has been bound to or unbound from a session.
63      * To receive the event, the object must implement
64      * {@link HttpSessionBindingListener}.
65      *
66      *
67      *
68      * @param session the session to which the object is bound or unbound
69      *
70      * @param name the name with which the object is bound or unbound
71      *
72      * @see #getName
73      * @see #getSession
74      *
75      */

76
77     public HttpSessionBindingEvent(HttpSession JavaDoc session, String JavaDoc name) {
78     super(session);
79     this.name = name;
80     }
81     
82     /**
83      *
84      * Constructs an event that notifies an object that it
85      * has been bound to or unbound from a session.
86      * To receive the event, the object must implement
87      * {@link HttpSessionBindingListener}.
88      *
89      *
90      *
91      * @param session the session to which the object is bound or unbound
92      *
93      * @param name the name with which the object is bound or unbound
94      *
95      * @see #getName
96      * @see #getSession
97      *
98      */

99     
100     public HttpSessionBindingEvent(HttpSession JavaDoc session, String JavaDoc name, Object JavaDoc value) {
101     super(session);
102     this.name = name;
103     this.value = value;
104     }
105     
106     
107     /** Return the session that changed. */
108     public HttpSession JavaDoc getSession () {
109     return super.getSession();
110     }
111  
112    
113   
114     
115     /**
116      *
117      * Returns the name with which the attribute is bound to or
118      * unbound from the session.
119      *
120      *
121      * @return a string specifying the name with which
122      * the object is bound to or unbound from
123      * the session
124      *
125      *
126      */

127
128     public String JavaDoc getName() {
129     return name;
130     }
131     
132     /**
133     * Returns the value of the attribute that has been added, removed or replaced.
134     * If the attribute was added (or bound), this is the value of the attribute. If the attribute was
135     * removed (or unbound), this is the value of the removed attribute. If the attribute was replaced, this
136     * is the old value of the attribute.
137     *
138         * @since 2.3
139     */

140     
141     public Object JavaDoc getValue() {
142         return this.value;
143     }
144     
145 }
146
147
148
149
150
151
152
153
Popular Tags