1 /**
2 *
3 * Copyright 2003-2004 The Apache Software Foundation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * 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
19
20
21
22
23
24 package javax.servlet.http;
25
26 /**
27 * Events of this type are either sent to an object that implements
28 * {@link HttpSessionBindingListener} when it is bound or
29 * unbound from a session, or to a {@link HttpSessionAttributeListener}
30 * that has been configured in the deployment descriptor when any attribute is
31 * bound, unbound or replaced in a session.
32 *
33 * <p>The session binds the object by a call to
34 * <code>HttpSession.setAttribute</code> and unbinds the object
35 * by a call to <code>HttpSession.removeAttribute</code>.
36 *
37 * @see HttpSession
38 * @see HttpSessionBindingListener
39 * @see HttpSessionAttributeListener
40 *
41 * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
42 */
43 public class HttpSessionBindingEvent extends HttpSessionEvent {
44 /**
45 * The name to which the object is being bound or unbound
46 */
47 private String name;
48
49 /**
50 * The object is being bound or unbound
51 */
52 private Object value;
53
54 /**
55 * Constructs an event that notifies an object that it
56 * has been bound to or unbound from a session.
57 * To receive the event, the object must implement
58 * {@link HttpSessionBindingListener}.
59 *
60 * @param session the session to which the object is bound or unbound
61 *
62 * @param name the name with which the object is bound or unbound
63 *
64 * @see #getName
65 * @see #getSession
66 */
67 public HttpSessionBindingEvent(HttpSession session, String name) {
68 super(session);
69 this.name = name;
70 }
71
72 /**
73 * Constructs an event that notifies an object that it
74 * has been bound to or unbound from a session.
75 * To receive the event, the object must implement
76 * {@link HttpSessionBindingListener}.
77 *
78 * @param session the session to which the object is bound or unbound
79 *
80 * @param name the name with which the object is bound or unbound
81 *
82 * @see #getName
83 * @see #getSession
84 */
85 public HttpSessionBindingEvent(HttpSession session, String name, Object value) {
86 super(session);
87 this.name = name;
88 this.value = value;
89 }
90
91 /**
92 * Return the session that changed.
93 */
94 public HttpSession getSession() {
95 return super.getSession();
96 }
97
98 /**
99 * Returns the name with which the attribute is bound to or unbound from
100 * the session.
101 *
102 * @return a string specifying the name with which the object is bound to
103 * or unbound from the session
104 */
105 public String getName() {
106 return name;
107 }
108
109 /**
110 * Returns the value of the attribute that has been added, removed or
111 * replaced. If the attribute was added (or bound), this is the value of
112 * the attribute. If the attrubute was removed (or unbound), this is the
113 * value of the removed attribute. If the attribute was replaced, this
114 * is the old value of the attribute.
115 *
116 * @since Servlet 2.3
117 */
118 public Object getValue() {
119 return this.value;
120 }
121 }
122
123
124
125
126
127
128