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:com.nec.harvest.servlet.listener.HarvestSessionListener.java

@Override
public void sessionDestroyed(HttpSessionEvent event) {
    activeSessions--;/*from   www .j  a  v  a 2  s .  co m*/

    // ?
    HttpSession session = event.getSession();
    Assert.notNull(session, "No HttpSession Specified");

    ServletContext ctx = session.getServletContext();
    ctx.removeAttribute(Constants.USER_LOGGED_IN_LASTTIME);
    ctx.removeAttribute(Constants.SESS_ORGANIZATION_CODE);
    ctx.removeAttribute(Constants.SESS_BUSINESS_DAY);

    if (SecurityContextHolder.getContext().getAuthentication() != null) {
        // Remove from LRU Cache
        AuthenticatedUserDetails.removeUserPrincipal();

        // Empty authentication
        SecurityContextHolder.getContext().setAuthentication(null);
    }

    // ??????
    logger.info("A HttpSession [{}] is going to be destroyed", session.getId());
}

From source file:net.sourceforge.vulcan.web.VulcanContextListener.java

public void contextDestroyed(ServletContextEvent event) {
    final ServletContext context = event.getServletContext();
    context.removeAttribute(Keys.STATE_MANAGER);
    context.removeAttribute(Keys.EVENT_POOL);

    if (stateManager == null) {
        // startup probably failed.
        return;// www . j ava 2  s  .  co  m
    }

    try {
        stateManager.shutdown();
    } catch (Exception e) {
        context.log("Error during shutdown of stateManager", e);
    }
}

From source file:org.apache.shindig.common.servlet.GuiceServletContextListener.java

public void contextDestroyed(ServletContextEvent event) {
    ServletContext context = event.getServletContext();
    context.removeAttribute(INJECTOR_ATTRIBUTE);
}

From source file:com.jsquant.listener.JsquantContextListener.java

public void contextDestroyed(ServletContextEvent sce) {
    ServletContext context = sce.getServletContext();
    context.removeAttribute(ATTR_FILE_CACHE);

    HttpClient httpClient = getHttpClient(context);
    if (httpClient != null) {
        httpClient.getConnectionManager().shutdown();
    }/*from   www  .j a va  2  s . c  om*/
    context.removeAttribute(ATTR_HTTP_CLIENT);
}

From source file:org.apache.hadoop.hdfsproxy.TestLdapIpDirFilter.java

public void testDoFilter() throws ServletException, IOException, NamingException {
    LdapIpDirFilter filter = new LdapIpDirFilter();
    String baseName = "ou=proxyroles,dc=mycompany,dc=com";
    DummyLdapContext dlc = new DummyLdapContext();
    filter.initialize(baseName, dlc);/*www . j a  v  a  2 s  .  com*/
    request.setRemoteIPAddress("127.0.0.1");

    ServletContext context = config.getServletContext();
    context.removeAttribute("name.node.address");
    context.removeAttribute("name.conf");
    assertNull(context.getAttribute("name.node.address"));
    assertNull(context.getAttribute("name.conf"));
    filter.init(config);
    assertNotNull(context.getAttribute("name.node.address"));
    assertNotNull(context.getAttribute("name.conf"));

    request.removeAttribute("org.apache.hadoop.hdfsproxy.authorized.userID");
    FilterChain mockFilterChain = new DummyFilterChain();
    filter.doFilter(request, response, mockFilterChain);
    assertEquals(request.getAttribute("org.apache.hadoop.hdfsproxy.authorized.userID"), "testuser");

}

From source file:org.apache.hadoop.hdfsproxy.TestProxyFilter.java

public void testDoFilterHttp() throws ServletException, IOException {
    ProxyFilter filter = new ProxyFilter();

    ServletContext context = config.getServletContext();
    context.removeAttribute("name.node.address");
    context.removeAttribute("name.conf");
    assertNull(context.getAttribute("name.node.address"));
    assertNull(context.getAttribute("name.conf"));

    filter.init(config);/*  w w w  .j a  v  a  2s  .  c o  m*/

    assertNotNull(context.getAttribute("name.node.address"));
    assertNotNull(context.getAttribute("name.conf"));

    request.removeAttribute("authorized.ugi");
    assertNull(request.getAttribute("authorized.ugi"));

    FilterChain mockFilterChain = new DummyFilterChain();
    filter.doFilter(request, response, mockFilterChain);
    assertEquals(request.getAttribute("authorized.ugi").toString(), "nobody,test");

}

From source file:org.jasig.springframework.web.portlet.context.PortletContextLoaderListener.java

@Override
public void contextDestroyed(ServletContextEvent sce) {
    //destroy the root portlet app context
    final ServletContext servletContext = sce.getServletContext();
    contextLoader.closeWebApplicationContext(servletContext);

    servletContext
            .removeAttribute(PortletApplicationContextUtils2.ROOT_PORTLET_APPLICATION_CONTEXT_LOADER_ATTRIBUTE);
    contextLoader = null;//from  w  ww. java 2  s.  co  m
}

From source file:com.github.glue.mvc.guice.GuiceConfigListener.java

@Override
public void contextDestroyed(ServletContextEvent servletContextEvent) {
    ServletContext servletContext = servletContextEvent.getServletContext();
    GuiceContainer guiceContainer = (GuiceContainer) servletContext.getAttribute(IOCCONTAINER);
    servletContext.removeAttribute(IOCCONTAINER);

    super.contextDestroyed(servletContextEvent);
}

From source file:org.iterx.miru.support.servlet.dispatcher.context.BootstrapServletContextListener.java

public void contextDestroyed(ServletContextEvent servletContextEvent) {
    ServletContext servletContext;

    servletContext = servletContextEvent.getServletContext();
    servletContext.removeAttribute((DispatcherApplicationContext.class).getName());

    synchronized (contexts) {
        contexts.remove(resolveContextPath(servletContext));
    }//from w w  w . j av a2  s. c  o m
}

From source file:org.springframework.cloud.netflix.eureka.server.EurekaServerBootstrap.java

public void contextDestroyed(ServletContext context) {
    try {//w  ww .j ava 2 s .c o m
        log.info("Shutting down Eureka Server..");
        context.removeAttribute(EurekaServerContext.class.getName());

        destroyEurekaServerContext();
        destroyEurekaEnvironment();

    } catch (Throwable e) {
        log.error("Error shutting down eureka", e);
    }
    log.info("Eureka Service is now shutdown...");
}