javax.servlet.ServletContextAttributeEvent Java Examples

The following examples show how to use javax.servlet.ServletContextAttributeEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ActionListener.java    From ALLGO with Apache License 2.0 7 votes vote down vote up
@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);
			}
		}
	}
}
 
Example #2
Source File: ServletContextAttributeListenerTest.java    From piranha with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Handle attribute added event.
 *
 * @param event the event.
 */
@Override
public void attributeAdded(ServletContextAttributeEvent event) {
    if (event.getName().equals("attributeAdded")) {
        event.getServletContext().setAttribute("attributeAdded2", true);
    }
}
 
Example #3
Source File: ContextListener.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * 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() + "')");

}
 
Example #4
Source File: ServletContextAttributeListenerTest.java    From piranha with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Handle attribute removed event.
 *
 * @param event the event.
 */
@Override
public void attributeRemoved(ServletContextAttributeEvent event) {
    if (event.getName().equals("attributeRemoved")) {
        event.getServletContext().setAttribute("attributeRemoved2", true);
    }
}
 
Example #5
Source File: ServletContextAttributeListenerTest.java    From piranha with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Handle attribute replaced event.
 *
 * @param event the event.
 */
@Override
public void attributeReplaced(ServletContextAttributeEvent event) {
    if (event.getName().equals("attributeReplaced")) {
        event.getServletContext().setAttribute("attributeReplaced2", true);
    }
}
 
Example #6
Source File: ApplicationListeners.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public void servletContextAttributeAdded(final String name, final Object value) {
    if(!started) {
        return;
    }
    final ServletContextAttributeEvent sre = new ServletContextAttributeEvent(servletContext, name, value);
    for (int i = 0; i < servletContextAttributeListeners.length; ++i) {
        this.<ServletContextAttributeListener>get(servletContextAttributeListeners[i]).attributeAdded(sre);
    }
}
 
Example #7
Source File: ApplicationListeners.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public void servletContextAttributeRemoved(final String name, final Object value) {
    if(!started) {
        return;
    }
    final ServletContextAttributeEvent sre = new ServletContextAttributeEvent(servletContext, name, value);
    for (int i = 0; i < servletContextAttributeListeners.length; ++i) {
        this.<ServletContextAttributeListener>get(servletContextAttributeListeners[i]).attributeRemoved(sre);
    }
}
 
Example #8
Source File: ApplicationListeners.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public void servletContextAttributeReplaced(final String name, final Object value) {
    if(!started) {
        return;
    }
    final ServletContextAttributeEvent sre = new ServletContextAttributeEvent(servletContext, name, value);
    for (int i = 0; i < servletContextAttributeListeners.length; ++i) {
        this.<ServletContextAttributeListener>get(servletContextAttributeListeners[i]).attributeReplaced(sre);
    }
}
 
Example #9
Source File: ContextListener.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * 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() + "')");

}
 
Example #10
Source File: ContextListener.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * 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() + "')");

}
 
Example #11
Source File: ContextListener.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * 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() + "')");

}
 
Example #12
Source File: ContextListener.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * 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() + "')");

}
 
Example #13
Source File: ContextListener.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * 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() + "')");

}
 
Example #14
Source File: ContextListener.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * 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() + "')");

}
 
Example #15
Source File: ContextListener.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * 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() + "')");

}
 
Example #16
Source File: ContextListener.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * 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() + "')");

}
 
Example #17
Source File: ContextListener.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * 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() + "')");

}
 
Example #18
Source File: ApplicationListeners.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
public void servletContextAttributeReplaced(final String name, final Object value) {
    if(!started) {
        return;
    }
    final ServletContextAttributeEvent sre = new ServletContextAttributeEvent(servletContext, name, value);
    for (int i = 0; i < servletContextAttributeListeners.length; ++i) {
        this.<ServletContextAttributeListener>get(servletContextAttributeListeners[i]).attributeReplaced(sre);
    }
}
 
Example #19
Source File: ApplicationListeners.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
public void servletContextAttributeRemoved(final String name, final Object value) {
    if(!started) {
        return;
    }
    final ServletContextAttributeEvent sre = new ServletContextAttributeEvent(servletContext, name, value);
    for (int i = 0; i < servletContextAttributeListeners.length; ++i) {
        this.<ServletContextAttributeListener>get(servletContextAttributeListeners[i]).attributeRemoved(sre);
    }
}
 
Example #20
Source File: ApplicationListeners.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
public void servletContextAttributeAdded(final String name, final Object value) {
    if(!started) {
        return;
    }
    final ServletContextAttributeEvent sre = new ServletContextAttributeEvent(servletContext, name, value);
    for (int i = 0; i < servletContextAttributeListeners.length; ++i) {
        this.<ServletContextAttributeListener>get(servletContextAttributeListeners[i]).attributeAdded(sre);
    }
}
 
Example #21
Source File: ContextListener.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * 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() + "')");

}
 
Example #22
Source File: ContextListener.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * 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() + "')");

}
 
Example #23
Source File: ContextListener.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * 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() + "')");

}
 
Example #24
Source File: ContextListener.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * 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() + "')");

}
 
Example #25
Source File: ApplicationContext.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@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 (Object obj : listeners) {
        if (!(obj instanceof ServletContextAttributeListener)) {
            continue;
        }
        ServletContextAttributeListener listener = (ServletContextAttributeListener) obj;
        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);
        }
    }
}
 
Example #26
Source File: ContextListener.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * 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() + "')");

}
 
Example #27
Source File: ServletContextTestListener.java    From quarkus-http with Apache License 2.0 4 votes vote down vote up
@Override
public void attributeAdded(final ServletContextAttributeEvent event) {
    servletContextAttributeEvent = event;
}
 
Example #28
Source File: ApplicationContext.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
        }
    }

}
 
Example #29
Source File: JaCoCoAgentController.java    From ldp4j with Apache License 2.0 4 votes vote down vote up
@Override
public void attributeAdded(final ServletContextAttributeEvent scab) {
	LOGGER.info(String.format("Added attribute '%s' with value '%s'",scab.getName(),scab.getValue()));
}
 
Example #30
Source File: JaCoCoAgentController.java    From ldp4j with Apache License 2.0 4 votes vote down vote up
@Override
public void attributeRemoved(final ServletContextAttributeEvent scab) {
	LOGGER.info(String.format("Deleted attribute '%s' with value '%s'",scab.getName(),scab.getValue()));
}