001 /**
002 *
003 * Copyright 2003-2004 The Apache Software Foundation
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018 //
019 // This source code implements specifications defined by the Java
020 // Community Process. In order to remain compliant with the specification
021 // DO NOT add / change / or delete method signatures!
022 //
023
024 package javax.servlet.http;
025
026 /**
027 * Events of this type are either sent to an object that implements
028 * {@link HttpSessionBindingListener} when it is bound or
029 * unbound from a session, or to a {@link HttpSessionAttributeListener}
030 * that has been configured in the deployment descriptor when any attribute is
031 * bound, unbound or replaced in a session.
032 *
033 * <p>The session binds the object by a call to
034 * <code>HttpSession.setAttribute</code> and unbinds the object
035 * by a call to <code>HttpSession.removeAttribute</code>.
036 *
037 * @see HttpSession
038 * @see HttpSessionBindingListener
039 * @see HttpSessionAttributeListener
040 *
041 * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
042 */
043 public class HttpSessionBindingEvent extends HttpSessionEvent {
044 /**
045 * The name to which the object is being bound or unbound
046 */
047 private String name;
048
049 /**
050 * The object is being bound or unbound
051 */
052 private Object value;
053
054 /**
055 * Constructs an event that notifies an object that it
056 * has been bound to or unbound from a session.
057 * To receive the event, the object must implement
058 * {@link HttpSessionBindingListener}.
059 *
060 * @param session the session to which the object is bound or unbound
061 *
062 * @param name the name with which the object is bound or unbound
063 *
064 * @see #getName
065 * @see #getSession
066 */
067 public HttpSessionBindingEvent(HttpSession session, String name) {
068 super(session);
069 this.name = name;
070 }
071
072 /**
073 * Constructs an event that notifies an object that it
074 * has been bound to or unbound from a session.
075 * To receive the event, the object must implement
076 * {@link HttpSessionBindingListener}.
077 *
078 * @param session the session to which the object is bound or unbound
079 *
080 * @param name the name with which the object is bound or unbound
081 *
082 * @see #getName
083 * @see #getSession
084 */
085 public HttpSessionBindingEvent(HttpSession session, String name, Object value) {
086 super(session);
087 this.name = name;
088 this.value = value;
089 }
090
091 /**
092 * Return the session that changed.
093 */
094 public HttpSession getSession() {
095 return super.getSession();
096 }
097
098 /**
099 * 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