Java-ServletContextEvent-ServletContextAttributeEvent

来源:互联网 发布:淘宝固定背代码 编辑:程序博客网 时间:2024/06/06 04:25
//这是一个事件类用来通知一个web 应用的servlet 上下文的改变public class ServletContextEvent extends java.util.EventObject { /** Construct a ServletContextEvent from the given context. * * @param source - the ServletContext that is sending the event. */    public ServletContextEvent(ServletContext source) {super(source);    }    /** * Return the ServletContext that changed. * * @return the ServletContext that sent the event. */    public ServletContext getServletContext () { return (ServletContext) super.getSource();    }    }

public class ServletContextAttributeEvent extends ServletContextEvent { private String name;private Object value;/** Construct a ServletContextAttributeEvent from the given context for the** given attribute name and attribute value. *///构造一个servlet上下文属性事件public ServletContextAttributeEvent(ServletContext source, String name, Object value) {    super(source);    this.name = name;    this.value = value;}/*** Return the name of the attribute that changed on the ServletContext.**/public String getName() {return this.name;}/*** Returns the value of the attribute that has been added, removed, or replaced.* If the attribute was added, this is the value of the attribute. If the attribute was* removed, this is the value of the removed attribute. If the attribute was replaced, this* is the old value of the attribute.**/public Object getValue() {    return this.value;   }}

0 0
原创粉丝点击