@Override public void removeAttribute( String s ) { proxy.removeAttribute( s ); }
@Override @Nullable public Object remove(String name) { Object scopedObject = this.servletContext.getAttribute(name); if (scopedObject != null) { this.servletContext.removeAttribute(name); this.destructionCallbacks.remove(name); return scopedObject; } else { return null; } }
@Override public void removeAttribute(String name, int scope) { Assert.notNull(name, "Attribute name must not be null"); switch (scope) { case PAGE_SCOPE: this.attributes.remove(name); break; case REQUEST_SCOPE: this.request.removeAttribute(name); break; case SESSION_SCOPE: this.request.getSession().removeAttribute(name); break; case APPLICATION_SCOPE: this.servletContext.removeAttribute(name); break; default: throw new IllegalArgumentException("Invalid scope: " + scope); } }
/** * Load {@link org.glassfish.jersey.server.ResourceConfig resource config} from given * {@link javax.servlet.ServletContext servlet context}. If found then the resource config is also removed from servlet * context. The {@code configName} is used as an attribute name suffix. * * @param context servlet context to load resource config from. * @param configName name or id of the resource config. * @return previously stored resource config or {@code null} if no resource config has been stored. */ public static ResourceConfig retrieve(final ServletContext context, final String configName) { final String attributeName = RESOURCE_CONFIG + "_" + configName; final ResourceConfig config = (ResourceConfig) context.getAttribute(attributeName); context.removeAttribute(attributeName); return config; }
/** * Load {@link org.glassfish.jersey.server.ResourceConfig resource config} from given * {@link javax.servlet.ServletContext servlet context}. If found then the resource config is also removed from servlet * context. The {@code configName} is used as an attribute name suffix. * * @param context servlet context to load resource config from. * @param configName name or id of the resource config. * @return previously stored resource config or {@code null} if no resource config has been stored. */ public static ResourceConfig retrieve(final ServletContext context, final String configName) { final String attributeName = RESOURCE_CONFIG + "_" + configName; final ResourceConfig config = (ResourceConfig) context.getAttribute(attributeName); context.removeAttribute(attributeName); return config; }
@Override @Nullable public Object remove(String name) { Object scopedObject = this.servletContext.getAttribute(name); if (scopedObject != null) { this.servletContext.removeAttribute(name); this.destructionCallbacks.remove(name); return scopedObject; } else { return null; } }
/** * Close Spring's web application context for the given servlet context. * <p>If overriding {@link #loadParentContext(ServletContext)}, you may have * to override this method as well. * @param servletContext the ServletContext that the WebApplicationContext runs in */ public void closeWebApplicationContext(ServletContext servletContext) { servletContext.log("Closing Spring root WebApplicationContext"); try { if (this.context instanceof ConfigurableWebApplicationContext) { ((ConfigurableWebApplicationContext) this.context).close(); } } finally { ClassLoader ccl = Thread.currentThread().getContextClassLoader(); if (ccl == ContextLoader.class.getClassLoader()) { currentContext = null; } else if (ccl != null) { currentContextPerThread.remove(ccl); } servletContext.removeAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); } }
public void contextDestroyed(ServletContextEvent event) { logger.info("Calling application shutdown..."); VoldemortServer server = (VoldemortServer) event.getServletContext() .getAttribute(SERVER_KEY); if(server != null) server.stop(); logger.info("Destroying application..."); event.getServletContext().removeAttribute(SERVER_KEY); event.getServletContext().removeAttribute(SERVER_CONFIG_KEY); event.getServletContext().removeAttribute(VELOCITY_ENGINE_KEY); }
/** * Handles Eureka cleanup, including shutting down all monitors and yielding all EIPs. * * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent) */ @Override public void contextDestroyed(ServletContextEvent event) { try { logger.info("{} Shutting down Eureka Server..", new Date()); ServletContext sc = event.getServletContext(); sc.removeAttribute(EurekaServerContext.class.getName()); destroyEurekaServerContext(); destroyEurekaEnvironment(); } catch (Throwable e) { logger.error("Error shutting down eureka", e); } logger.info("{} Eureka Service is now shutdown...", new Date()); }
protected void removeContextAttribute(String key) { getRequiredServletContext().removeAttribute(key); }
@Override public void contextDestroyed(ServletContextEvent sce) { log.info("ModelManagerListener destroying"); // Slightly paranoid; remove objects from app scope manually ServletContext context = sce.getServletContext(); for (Enumeration<String> names = context.getAttributeNames(); names.hasMoreElements();) { context.removeAttribute(names.nextElement()); } close(); // Hacky, but prevents Tomcat from complaining that ZK's cleanup thread 'leaked' since // it has a short sleep at its end try { Thread.sleep(1000); } catch (InterruptedException ie) { // continue } }
@Override public void doTag() throws JspException { PageContext pageContext = (PageContext) getJspContext(); HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); String scopeValue = scope != null ? scope.toLowerCase() : SCOPE_PAGE; if (scopeValue.equals(SCOPE_APPLICATION)) { request.getServletContext().removeAttribute(name); } else if (scopeValue.equals(SCOPE_SESSION)) { request.getSession().removeAttribute(name); } else if (scopeValue.equals(SCOPE_REQUEST)) { request.removeAttribute(name); } else if (scopeValue.equals(SCOPE_PAGE)) { pageContext.removeAttribute(name); } else { throw new JspException("Invalid scope: " + scope); } } }
/** * Removes scope attribute. */ public static void removeScopeAttribute(final String name, final String scope, final PageContext pageContext) { HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); String scopeValue = scope != null ? scope.toLowerCase() : SCOPE_PAGE; if (scopeValue.equals(SCOPE_PAGE)) { pageContext.removeAttribute(name); } else if (scopeValue.equals(SCOPE_REQUEST)) { request.removeAttribute(name); } else if (scopeValue.equals(SCOPE_SESSION)) { request.getSession().removeAttribute(name); } else if (scopeValue.equals(SCOPE_APPLICATION)) { request.getServletContext().removeAttribute(name); } else { throw new IllegalArgumentException("Invalid scope: " + scope); } }
/** * Close Spring's web application context for the given servlet context. * <p>If overriding {@link #loadParentContext(ServletContext)}, you may have * to override this method as well. * @param servletContext the ServletContext that the WebApplicationContext runs in */ public void closeWebApplicationContext(ServletContext servletContext) { servletContext.log("Closing Spring root WebApplicationContext"); try { if (this.context instanceof ConfigurableWebApplicationContext) { ((ConfigurableWebApplicationContext) this.context).close(); } } finally { ClassLoader ccl = Thread.currentThread().getContextClassLoader(); if (ccl == ContextLoader.class.getClassLoader()) { currentContext = null; } else if (ccl != null) { currentContextPerThread.remove(ccl); } servletContext.removeAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); } }
@Override public void removeAttribute(String name, int scope) { Assert.notNull(name, "Attribute name must not be null"); switch (scope) { case PAGE_SCOPE: this.attributes.remove(name); break; case REQUEST_SCOPE: this.request.removeAttribute(name); break; case SESSION_SCOPE: this.request.getSession().removeAttribute(name); break; case APPLICATION_SCOPE: this.servletContext.removeAttribute(name); break; default: throw new IllegalArgumentException("Invalid scope: " + scope); } }
/** * Stops <em>Madvoc</em> web application. */ public void stopWebApplication() { log.info("Madvoc shutting down..."); if (servletContext != null) { servletContext.removeAttribute(MADVOC_ATTR); } webapp.shutdown(); webapp = null; }
/** * Destroys the {@link WebEnvironment} for the given servlet context. * * @param servletContext the ServletContext attributed to the WebSecurityManager */ public void destroyEnvironment(ServletContext servletContext) { servletContext.log("Cleaning up Shiro Environment"); try { Object environment = servletContext.getAttribute(ENVIRONMENT_ATTRIBUTE_KEY); if (environment instanceof WebEnvironment) { finalizeEnvironment((WebEnvironment) environment); } LifecycleUtils.destroy(environment); } finally { servletContext.removeAttribute(ENVIRONMENT_ATTRIBUTE_KEY); } }
@Override public void removeAttribute(String name, int scope) { switch(scope) { case PAGE_SCOPE: { environment.getGlobalNamespace().remove(name); break; } case REQUEST_SCOPE: { getRequest().removeAttribute(name); break; } case SESSION_SCOPE: { HttpSession session = getSession(false); if (session != null) { session.removeAttribute(name); } break; } case APPLICATION_SCOPE: { getServletContext().removeAttribute(name); break; } default: { throw new IllegalArgumentException("Invalid scope: " + scope); } } }
@Override public void configure(final AtmosphereConfig config) { ServletContext sc = config.framework().getServletContext(); Map<Class<? extends Annotation>, Set<Class<?>>> annotations= (Map<Class<? extends Annotation>, Set<Class<?>>>) sc.getAttribute(ANNOTATION_ATTRIBUTE); sc.removeAttribute(ANNOTATION_ATTRIBUTE); boolean useByteCodeProcessor = config.getInitParameter(ApplicationConfig.BYTECODE_PROCESSOR, false); boolean scanForAtmosphereAnnotation = false; if (useByteCodeProcessor || annotations == null || annotations.isEmpty()) { delegate = new BytecodeBasedAnnotationProcessor(handler); scanForAtmosphereAnnotation = true; } else { Map<Class<? extends Annotation>, Set<Class<?>>> clone = new HashMap<Class<? extends Annotation>, Set<Class<?>>>(); clone.putAll(annotations); delegate = new ServletContainerInitializerAnnotationProcessor(handler, clone, config.framework()); } logger.info("AnnotationProcessor {} being used", delegate.getClass()); if (scanForAtmosphereAnnotation) { scanForAnnotation(config.framework()); } delegate.configure(config.framework().getAtmosphereConfig()); }
@Test public void addServerEndpointConfigBeanWithExplicitServerContainer() throws Exception { ServerEndpointRegistration endpointRegistration = new ServerEndpointRegistration("/dummy", new DummyEndpoint()); this.webAppContext.getBeanFactory().registerSingleton("dummyEndpoint", endpointRegistration); this.servletContext.removeAttribute("javax.websocket.server.ServerContainer"); this.exporter.setServerContainer(this.serverContainer); this.exporter.setApplicationContext(this.webAppContext); this.exporter.afterPropertiesSet(); this.exporter.afterSingletonsInstantiated(); verify(this.serverContainer).addEndpoint(endpointRegistration); }