您的位置:首页 > 编程语言 > Java开发

Java-ServletContextEvent-ServletContextAttributeEvent

2015-10-23 19:45 483 查看
//这是一个事件类用来通知一个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;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: