Example usage for javax.servlet.http HttpServlet destroy

List of usage examples for javax.servlet.http HttpServlet destroy

Introduction

In this page you can find the example usage for javax.servlet.http HttpServlet destroy.

Prototype

public void destroy() 

Source Link

Document

Called by the servlet container to indicate to a servlet that the servlet is being taken out of service.

Usage

From source file:com.netscape.cmscore.apps.CMSEngine.java

public void terminateRequests() {
    Enumeration<ICMSRequest> e = CommandQueue.mCommandQueue.keys();

    while (e.hasMoreElements()) {
        Object thisRequest = e.nextElement();

        HttpServlet thisServlet = (HttpServlet) CommandQueue.mCommandQueue.get(thisRequest);

        if (thisServlet != null) {
            CommandQueue.mCommandQueue.remove(thisRequest);
            thisServlet.destroy();
        }/*from w w w .ja  v  a 2 s .c  om*/
    }
}

From source file:org.openmrs.module.web.WebModuleUtil.java

/**
 * Remove all of the servlets defined for this module
 *
 * @param mod the module that is being stopped that needs its servlets removed
 *///from   w w w  .  j  av  a  2 s .  c om
public static void unloadServlets(Module mod) {
    Element rootNode = mod.getConfig().getDocumentElement();
    NodeList servletTags = rootNode.getElementsByTagName("servlet");

    for (int i = 0; i < servletTags.getLength(); i++) {
        Node node = servletTags.item(i);
        NodeList childNodes = node.getChildNodes();
        String name = "";
        for (int j = 0; j < childNodes.getLength(); j++) {
            Node childNode = childNodes.item(j);
            if ("servlet-name".equals(childNode.getNodeName()) && childNode.getTextContent() != null) {
                name = childNode.getTextContent().trim();
                HttpServlet servlet = moduleServlets.get(name);
                if (servlet != null) {
                    servlet.destroy(); // shut down the servlet
                    moduleServlets.remove(name);
                }
            }
        }
    }
}