@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())); } }
@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); } } } }
@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)); } }
public void attributeRemoved(ServletContextAttributeEvent ev) { if (ev.getName().equals(ContainerUtil.ATTRIBUTE_CONTAINER_LIST)) { List containers = (List) ev.getValue(); ContainerUtil.shutdownServerLoadMonitorsInContainerList(containers, "EfficientShutdownServletContextAttributeListener"); } }
/** * 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() + "')"); }
/** * 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() + "')"); }
/** * 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() + "')"); }
/** * 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); } } }
public void attributeAdded(ServletContextAttributeEvent scab) { if (scab.getName().equals(Bayeux.DOJOX_COMETD_BAYEUX)) { Bayeux bayeux=(Bayeux)scab.getValue(); initialize(bayeux); } }
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); } }
public void removeAttribute(String name) { Object oldValue = attributes.remove(name); if (oldValue != null) { ServletContextAttributeEvent event = createEvent(name, oldValue); webapp.getGlobalServletContextAttributeListener().attributeRemoved(event); } }
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>" ); } }
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>" ); } }
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>" ); } }
@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)); } }
@Override public void removeAttribute(final String name) { final Object me = attributes.get(name); attributes.remove(name); if (me != null) { for (int n = 0; n < contextAttributeListeners.length; n++) { final ClassLoader cl = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(getLoader()); contextAttributeListeners[n].attributeRemoved(new ServletContextAttributeEvent(this, name, me)); Thread.currentThread().setContextClassLoader(cl); } } }
@Override public void attributeRemoved(ServletContextAttributeEvent servletContextAttributeEvent){ if (LOGGER.isInfoEnabled()){ LOGGER.info( "name:[{}],value:[{}] removed from [servletContext],now servletContext attribute:[{}] ", servletContextAttributeEvent.getName(), servletContextAttributeEvent.getValue(), buildAttributesLogMessage(servletContextAttributeEvent.getServletContext())); } }
@Override public void attributeReplaced(ServletContextAttributeEvent servletContextAttributeEvent){ if (LOGGER.isInfoEnabled()){ LOGGER.info( "name:[{}],value:[{}] replaced to [servletContext],now servletContext attribute:[{}] ", servletContextAttributeEvent.getName(), servletContextAttributeEvent.getValue(), buildAttributesLogMessage(servletContextAttributeEvent.getServletContext())); } }
@Override public void setAttribute(String attr, Object value) { Object original = attributes.get(attr); attributes.put(attr, value); ServletContextAttributeEvent event = new ServletContextAttributeEvent(this, attr, value); if (original != null) { call(ServletContextAttributeListener.class, (l) -> l.attributeReplaced(event)); } else { call(ServletContextAttributeListener.class, (l) -> l.attributeAdded(event)); } }
@Override public void attributeAdded(final ServletContextAttributeEvent scab) { final Iterator<ServletContextAttributeListener> listeners = getContextListeners(); while (listeners.hasNext()) { listeners.next().attributeAdded(scab); } }
@Override public void attributeRemoved(final ServletContextAttributeEvent scab) { final Iterator<ServletContextAttributeListener> listeners = getContextListeners(); while (listeners.hasNext()) { listeners.next().attributeRemoved(scab); } }
@Override public void attributeReplaced(final ServletContextAttributeEvent scab) { final Iterator<ServletContextAttributeListener> listeners = getContextListeners(); while (listeners.hasNext()) { listeners.next().attributeReplaced(scab); } }
@Override public void setAttribute(String name, Object value) { if (value == null) { this.removeAttribute(name); } else if (name != null) { Object oldValue; if (this.attributes != null) { oldValue = this.attributes.put(name, value); } else { oldValue = this.context.getAttribute(name); this.context.setAttribute(name, value); } if (oldValue == null) { attributeListener.attributeAdded(new ServletContextAttributeEvent(this, name, value)); } else { attributeListener.attributeReplaced(new ServletContextAttributeEvent(this, name, oldValue)); } } }