001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019
020 package javax.servlet;
021
022 /**
023 * This is the event class for notifications about changes to the attributes of the
024 * servlet context of a web application.
025 *
026 * @version $Rev: 788194 $ $Date: 2009-06-24 18:05:48 -0400 (Wed, 24 Jun 2009) $
027 * @see ServletContextAttributeListener
028 * @since v 2.3
029 */
030
031 public class ServletContextAttributeEvent extends ServletContextEvent {
032 private final String name;
033 private final Object value;
034
035 /**
036 * Construct a ServletContextAttributeEvent from the given context for the
037 * given attribute name and attribute value.
038 */
039 public ServletContextAttributeEvent(ServletContext source, String name, Object value) {
040 super(source);
041 this.name = name;
042 this.value = value;
043 }
044
045 /**
046 * Return the name of the attribute that changed on the ServletContext.
047 * @return name of the changed attribute
048 */
049 public String getName() {
050 return name;
051 }
052
053 /**
054 * Returns the value of the attribute that has been added, removed, or replaced.
055 * If the attribute was added, this is the value of the attribute. If the attribute was
056 * removed, this is the value of the removed attribute. If the attribute was replaced, this
057 * is the old value of the attribute.
058 * @return value of the changed attribute
059 */
060 public Object getValue() {
061 return value;
062 }
063 }
064