Michael E. Rodriguez | d8af66f | 2005-12-08 20:55:55 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 1999,2005 The Apache Software Foundation. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | |
| 18 | package javax.servlet.http; |
| 19 | |
| 20 | import java.util.EventObject; |
| 21 | |
| 22 | |
| 23 | /** |
| 24 | * |
| 25 | * Sent to an object that implements |
| 26 | * {@link HttpSessionBindingListener} when the object is |
| 27 | * bound to or unbound from the session. |
| 28 | * |
| 29 | * <p>The session binds the object by a call to |
| 30 | * <code>HttpSession.putValue</code> and unbinds the object |
| 31 | * by a call to <code>HttpSession.removeValue</code>. |
| 32 | * |
| 33 | * |
| 34 | * |
| 35 | * @author Various |
| 36 | * @version $Version$ |
| 37 | * |
| 38 | * @see HttpSession |
| 39 | * @see HttpSessionBindingListener |
| 40 | * |
| 41 | */ |
| 42 | |
| 43 | public class HttpSessionBindingEvent extends EventObject { |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | /* The name to which the object is being bound or unbound */ |
| 49 | |
| 50 | private String name; |
| 51 | |
| 52 | |
| 53 | |
| 54 | /** |
| 55 | * |
| 56 | * Constructs an event that notifies an object that it |
| 57 | * has been bound to or unbound from a session. |
| 58 | * To receive the event, the object must implement |
| 59 | * {@link HttpSessionBindingListener}. |
| 60 | * |
| 61 | * |
| 62 | * |
| 63 | * @param session the session to which the object is bound or unbound |
| 64 | * |
| 65 | * @param name the name with which the object is bound or unbound |
| 66 | * |
| 67 | * @see #getName |
| 68 | * @see #getSession |
| 69 | * |
| 70 | */ |
| 71 | |
| 72 | public HttpSessionBindingEvent(HttpSession session, String name) { |
| 73 | super(session); |
| 74 | this.name = name; |
| 75 | } |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | /** |
| 83 | * |
| 84 | * Returns the name with which the object is bound to or |
| 85 | * unbound from the session. |
| 86 | * |
| 87 | * |
| 88 | * @return a string specifying the name with which |
| 89 | * the object is bound to or unbound from |
| 90 | * the session |
| 91 | * |
| 92 | * |
| 93 | */ |
| 94 | |
| 95 | public String getName() { |
| 96 | return name; |
| 97 | } |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | /** |
| 105 | * |
| 106 | * Returns the session to or from which the object is |
| 107 | * bound or unbound. |
| 108 | * |
| 109 | * @return the session to which the object is |
| 110 | * bound or from which the object is |
| 111 | * unbound |
| 112 | * |
| 113 | * |
| 114 | * |
| 115 | */ |
| 116 | |
| 117 | public HttpSession getSession() { |
| 118 | return (HttpSession) getSource(); |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |