本文整理汇总了Java中javax.servlet.ServletContextAttributeEvent类的典型用法代码示例。如果您正苦于以下问题:Java ServletContextAttributeEvent类的具体用法?Java ServletContextAttributeEvent怎么用?Java ServletContextAttributeEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ServletContextAttributeEvent类属于javax.servlet包,在下文中一共展示了ServletContextAttributeEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: attributeAdded
import javax.servlet.ServletContextAttributeEvent; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void attributeAdded(ServletContextAttributeEvent arg0) {
if(userMap == null){
userMap = (Map<Integer, WsOutbound>) arg0.getServletContext().getAttribute("OnLineList");
}
//System.out.println("listener==>attributeAdded");
Enumeration<String> att = arg0.getServletContext().getAttributeNames();
while(att.hasMoreElements()){
String next = att.nextElement();
if(next.startsWith("action")){
ServerMsg message = (ServerMsg) arg0.getServletContext().getAttribute(next);
if(message != null){
arg0.getServletContext().removeAttribute(next);
doAction(message);
}
}
}
}
示例2: attributeAdded
import javax.servlet.ServletContextAttributeEvent; //导入依赖的package包/类
@Override
public void attributeAdded(ServletContextAttributeEvent servletContextAttributeEvent){
if (LOGGER.isInfoEnabled()){
String name = servletContextAttributeEvent.getName();
if (isNotNullOrEmpty(name) && ArrayUtils.contains(ServletContextUtil.EXCLUDE_KEYS, name)){
return;
}
//---------------------------------------------------------------
LOGGER.info(
"name:[{}],value:[{}] added to [servletContext],now servletContext attribute:[{}] ",
name,
servletContextAttributeEvent.getValue(),
buildAttributesLogMessage(servletContextAttributeEvent.getServletContext()));
}
}
示例3: removeAttribute
import javax.servlet.ServletContextAttributeEvent; //导入依赖的package包/类
@Override
public void removeAttribute(String name)
{
Object oldValue;
if (this.attributes != null)
{
oldValue = this.attributes.remove(name);
}
else
{
oldValue = this.context.getAttribute(name);
this.context.removeAttribute(name);
}
if (oldValue != null)
{
attributeListener.attributeRemoved(new ServletContextAttributeEvent(this, name, oldValue));
}
}
示例4: attributeRemoved
import javax.servlet.ServletContextAttributeEvent; //导入依赖的package包/类
public void attributeRemoved(ServletContextAttributeEvent ev)
{
if (ev.getName().equals(ContainerUtil.ATTRIBUTE_CONTAINER_LIST))
{
List containers = (List) ev.getValue();
ContainerUtil.shutdownServerLoadMonitorsInContainerList(containers, "EfficientShutdownServletContextAttributeListener");
}
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:9,代码来源:EfficientShutdownServletContextAttributeListener.java
示例5: attributeAdded
import javax.servlet.ServletContextAttributeEvent; //导入依赖的package包/类
/**
* Record the fact that a servlet context attribute was added.
*
* @param event The servlet context attribute event
*/
@Override
public void attributeAdded(ServletContextAttributeEvent event) {
log("attributeAdded('" + event.getName() + "', '" +
event.getValue() + "')");
}
示例6: attributeRemoved
import javax.servlet.ServletContextAttributeEvent; //导入依赖的package包/类
/**
* Record the fact that a servlet context attribute was removed.
*
* @param event The servlet context attribute event
*/
@Override
public void attributeRemoved(ServletContextAttributeEvent event) {
log("attributeRemoved('" + event.getName() + "', '" +
event.getValue() + "')");
}
示例7: attributeReplaced
import javax.servlet.ServletContextAttributeEvent; //导入依赖的package包/类
/**
* Record the fact that a servlet context attribute was replaced.
*
* @param event The servlet context attribute event
*/
@Override
public void attributeReplaced(ServletContextAttributeEvent event) {
log("attributeReplaced('" + event.getName() + "', '" +
event.getValue() + "')");
}
示例8: removeAttribute
import javax.servlet.ServletContextAttributeEvent; //导入依赖的package包/类
/**
* Remove the context attribute with the specified name, if any.
*
* @param name
* Name of the context attribute to be removed
*/
@Override
public void removeAttribute(String name) {
Object value = null;
// Remove the specified attribute
// Check for read only attribute
if (readOnlyAttributes.containsKey(name)) {
return;
}
value = attributes.remove(name);
if (value == null) {
return;
}
// Notify interested application event listeners
Object listeners[] = context.getApplicationEventListeners();
if ((listeners == null) || (listeners.length == 0))
return;
ServletContextAttributeEvent event = new ServletContextAttributeEvent(context.getServletContext(), name, value);
for (int i = 0; i < listeners.length; i++) {
if (!(listeners[i] instanceof ServletContextAttributeListener))
continue;
ServletContextAttributeListener listener = (ServletContextAttributeListener) listeners[i];
try {
context.fireContainerEvent("beforeContextAttributeRemoved", listener);
listener.attributeRemoved(event);
context.fireContainerEvent("afterContextAttributeRemoved", listener);
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
context.fireContainerEvent("afterContextAttributeRemoved", listener);
// FIXME - should we do anything besides log these?
log(sm.getString("applicationContext.attributeEvent"), t);
}
}
}
示例9: attributeAdded
import javax.servlet.ServletContextAttributeEvent; //导入依赖的package包/类
public void attributeAdded(ServletContextAttributeEvent scab)
{
if (scab.getName().equals(Bayeux.DOJOX_COMETD_BAYEUX))
{
Bayeux bayeux=(Bayeux)scab.getValue();
initialize(bayeux);
}
}
示例10: setAttribute
import javax.servlet.ServletContextAttributeEvent; //导入依赖的package包/类
public void setAttribute(String name, Object object) {
Object previousValue = attributes.put(name, object);
ServletContextAttributeEvent event;
if (previousValue != null) {
event = createEvent(name, previousValue);
webapp.getGlobalServletContextAttributeListener()
.attributeReplaced(event);
} else {
event = createEvent(name, object);
webapp.getGlobalServletContextAttributeListener()
.attributeAdded(event);
}
}
示例11: removeAttribute
import javax.servlet.ServletContextAttributeEvent; //导入依赖的package包/类
public void removeAttribute(String name) {
Object oldValue = attributes.remove(name);
if (oldValue != null) {
ServletContextAttributeEvent event = createEvent(name, oldValue);
webapp.getGlobalServletContextAttributeListener().attributeRemoved(event);
}
}
示例12: attributeAdded
import javax.servlet.ServletContextAttributeEvent; //导入依赖的package包/类
public void attributeAdded( ServletContextAttributeEvent event ) {
if ( event.getName().indexOf( SC_ATTRIBUTE ) > -1 ) {
sl.writeToLog( "In AttributeAdded() method of SCAttributeEventListener<BR>" );
sl.writeToLog( "Attribute added for Event Name=" + event.getName() + "<BR>" );
sl.writeToLog( "Attribute added for Event value=" + event.getValue() + "<BR>" );
}
}
示例13: attributeRemoved
import javax.servlet.ServletContextAttributeEvent; //导入依赖的package包/类
public void attributeRemoved( ServletContextAttributeEvent event ) {
if ( event.getName().indexOf( SC_ATTRIBUTE ) > -1 ) {
sl.writeToLog( "In AttributeRemoved() method of SCAttributeEventListener<BR>" );
sl.writeToLog( "Attribute removed for Event Name=" + event.getName() + "<BR>" );
sl.writeToLog( "Attribute removed for Event value=" + event.getValue() + "<BR>" );
}
}
示例14: attributeReplaced
import javax.servlet.ServletContextAttributeEvent; //导入依赖的package包/类
public void attributeReplaced( ServletContextAttributeEvent event ) {
if ( event.getName().indexOf( SC_ATTRIBUTE ) > -1 ) {
sl.writeToLog( "In AttributeReplaced() method of SCAttributeEventListener<BR>" );
sl.writeToLog( "Attribute replaced for Event Name=" + event.getName() + "<BR>" );
sl.writeToLog( "Attribute replaced for Event value=" + event.getValue() + "<BR>" );
}
}
示例15: attributeReplaced
import javax.servlet.ServletContextAttributeEvent; //导入依赖的package包/类
@Override
public void attributeReplaced(ServletContextAttributeEvent event) {
if (event.getName().equals("numNamesSoln")) {
long curTime = System.nanoTime();
long lastTime = ((Long)event.getServletContext().getAttribute("timeLastChange")).longValue();
long timeSinceChange = curTime - lastTime;
event.getServletContext().log("Time since numNamesSoln changed: "+timeSinceChange);
event.getServletContext().setAttribute("timeLastChange", new Long(curTime));
}
}