Example usage for javax.servlet ServletContext removeAttribute

List of usage examples for javax.servlet ServletContext removeAttribute

Introduction

In this page you can find the example usage for javax.servlet ServletContext removeAttribute.

Prototype

public void removeAttribute(String name);

Source Link

Document

Removes the attribute with the given name from this ServletContext.

Usage

From source file:cn.vlabs.umt.ui.UMTStartupListener.java

public void contextDestroyed(ServletContextEvent event) {
    ServletContext context = event.getServletContext();
    FileSystemXmlApplicationContext factory = (FileSystemXmlApplicationContext) context
            .getAttribute(Attributes.APPLICATION_CONTEXT_KEY);
    if (factory != null) {
        context.removeAttribute(Attributes.APPLICATION_CONTEXT_KEY);
        factory.close();/*from  w  w w . j a  v a2 s. c om*/
        factory = null;
    }
}

From source file:org.acoustid.server.ApplicationContextListener.java

@Override
public void contextDestroyed(ServletContextEvent event) {
    ServletContext servletContext = event.getServletContext();
    Injector injector = (Injector) servletContext.getAttribute(INJECTOR_ATTRIBUTE_NAME);
    if (injector == null) {
        logger.warn("Injector not found");
        return;//ww w .  j a  v  a2s .co m
    }
    servletContext.removeAttribute(INJECTOR_ATTRIBUTE_NAME);

    ApplicationContext context = injector.getInstance(ApplicationContext.class);
    logger.debug("Closing application context " + context);
    context.close();
}

From source file:org.guzz.web.context.ContextLoader.java

public void shutdown(ServletContext sc) {
    if (guzzContext != null) {
        try {/*from w  w  w .  j a v  a2  s.  c o  m*/
            guzzContext.shutdown();
        } catch (Exception e) {
            log.error("error whiling shutting down guzzContext", e);
        }

        sc.removeAttribute(GuzzWebApplicationContextUtil.GUZZ_SERVLET_CONTEXT_KEY);
        guzzContext = null;
    }
}

From source file:com.sonicle.webtop.core.app.ContextLoader.java

protected void destroyApp(ServletContext servletContext) {
    final String appname = getWabappName(servletContext);
    try {//from w w  w.j  av a2  s .c  om
        WebTopApp.get(servletContext).shutdown();

    } catch (Throwable t) {
        logger.error("Error destroying WTA [{}]", appname, t);
    } finally {
        servletContext.removeAttribute(WEBTOPAPP_ATTRIBUTE_KEY);
    }
}

From source file:org.apache.pluto.driver.PortalStartupListener.java

/**
 * Destroyes the portal admin config and removes it from servlet context.
 *
 * @param servletContext the servlet context.
 *//*w w w . j av a2s  . co  m*/
private void destroyAdminConfiguration(ServletContext servletContext) {
    AdminConfiguration adminConfig = (AdminConfiguration) servletContext.getAttribute(ADMIN_CONFIG_KEY);
    if (adminConfig != null) {
        try {
            adminConfig.destroy();
            if (LOG.isInfoEnabled()) {
                LOG.info("Pluto Portal Admin Config destroyed.");
            }
        } catch (DriverConfigurationException ex) {
            LOG.error("Unable to destroy portal admin config: " + ex.getMessage(), ex);
        } finally {
            servletContext.removeAttribute(ADMIN_CONFIG_KEY);
        }
    }
}

From source file:org.apache.pluto.driver.PortalStartupListener.java

/**
 * Destroyes the portal driver config and removes it from servlet context.
 *
 * @param servletContext the servlet context.
 *///from   w  w w. j a v a2 s  .  co m
private void destroyDriverConfiguration(ServletContext servletContext) {
    DriverConfiguration driverConfig = (DriverConfiguration) servletContext.getAttribute(DRIVER_CONFIG_KEY);
    if (driverConfig != null) {
        try {
            driverConfig.destroy();
            if (LOG.isInfoEnabled()) {
                LOG.info("Pluto Portal Driver Config destroyed.");
            }
        } catch (DriverConfigurationException ex) {
            LOG.error("Unable to destroy portal driver config: " + ex.getMessage(), ex);
        } finally {
            servletContext.removeAttribute(DRIVER_CONFIG_KEY);
        }
    }
}

From source file:org.apache.pluto.driver.PortalStartupListener.java

/**
 * Destroyes the portlet container and removes it from servlet context.
 *
 * @param servletContext the servlet context.
 *///  w ww . j ava2 s .  c  om
private void destroyContainer(ServletContext servletContext) {
    if (LOG.isInfoEnabled()) {
        LOG.info("Shutting down Pluto Portal Driver...");
    }
    PortletContainer container = (PortletContainer) servletContext.getAttribute(CONTAINER_KEY);
    if (container != null) {
        try {
            container.destroy();
            if (LOG.isInfoEnabled()) {
                LOG.info("Pluto Portal Driver shut down.");
            }
        } catch (PortletContainerException ex) {
            LOG.error("Unable to shut down portlet container: " + ex.getMessage(), ex);
        } finally {
            servletContext.removeAttribute(CONTAINER_KEY);
        }
    }
}

From source file:org.apache.beehive.netui.pageflow.AutoRegisterActionServlet.java

/**
 * Clear the internal map of registered modules.
 * // w ww. ja v  a 2s.  c  om
 * @exclude
 */
public void clearRegisteredModules() {
    ServletContext servletContext = getServletContext();

    for (Iterator ii = _registeredModules.keySet().iterator(); ii.hasNext();) {
        String modulePrefix = (String) ii.next();
        servletContext.removeAttribute(Globals.MODULE_KEY + modulePrefix);
        servletContext.removeAttribute(Globals.REQUEST_PROCESSOR_KEY + modulePrefix);
    }

    _registeredModules.clear();
}

From source file:org.acmsl.commons.utils.http.HttpServletUtils.java

/**
 * Removes an object from the repository.
 * @param key the key./*  ww w  .j  av  a2  s.c o  m*/
 * @param request the request.
 * @param session the session.
 * @param context the context.
 * @return <code>true</code> if the object has been removed successfully.
 */
public boolean remove(@NotNull final String key, @Nullable final ServletRequest request,
        @Nullable final HttpSession session, @Nullable final ServletContext context) {
    boolean result = false;

    // Thanks Sun for had missed an interface for
    // all classes that export setAttribute().
    if (request != null) {
        request.removeAttribute(key);
        result = true;
    }

    if (session != null) {
        session.removeAttribute(key);
        result = true;
    }

    if (context != null) {
        context.removeAttribute(key);
        result = true;
    }

    return result;
}