@Override public Enumeration<String> getAttributeNames() { return proxy.getAttributeNames(); }
@Override protected Set<ConfigurableApplicationContext> findApplicationContexts() { Set<ConfigurableApplicationContext> contexts = new LinkedHashSet<>(); Enumeration<String> attrNames = this.servletContext.getAttributeNames(); while (attrNames.hasMoreElements()) { String attrName = attrNames.nextElement(); Object attrValue = this.servletContext.getAttribute(attrName); if (attrValue instanceof ConfigurableApplicationContext) { contexts.add((ConfigurableApplicationContext) attrValue); } } return contexts; }
@Override public boolean isEmpty() { final Enumeration<String> attributeNames = this.servletContext.getAttributeNames(); return !attributeNames.hasMoreElements(); }
public boolean isEmpty() { return !servletctx.getAttributeNames().hasMoreElements(); }
@Override public int size() { int size = 0; final Enumeration<String> attributeNames = this.servletContext.getAttributeNames(); while (attributeNames.hasMoreElements()) { attributeNames.nextElement(); size++; } return size; }
@Override public Enumeration<String> getAttributeNamesInScope(int scope) { switch (scope) { case PAGE_SCOPE: return getAttributeNames(); case REQUEST_SCOPE: return this.request.getAttributeNames(); case SESSION_SCOPE: HttpSession session = this.request.getSession(false); return (session != null ? session.getAttributeNames() : Collections.emptyEnumeration()); case APPLICATION_SCOPE: return this.servletContext.getAttributeNames(); default: throw new IllegalArgumentException("Invalid scope: " + scope); } }
/** * Find all ServletContext attributes which implement {@link DisposableBean} * and destroy them, removing all affected ServletContext attributes eventually. * @param sc the ServletContext to check */ static void cleanupAttributes(ServletContext sc) { Enumeration<String> attrNames = sc.getAttributeNames(); while (attrNames.hasMoreElements()) { String attrName = attrNames.nextElement(); if (attrName.startsWith("org.springframework.")) { Object attrValue = sc.getAttribute(attrName); if (attrValue instanceof DisposableBean) { try { ((DisposableBean) attrValue).destroy(); } catch (Throwable ex) { logger.error("Couldn't invoke destroy method of attribute with name '" + attrName + "'", ex); } } } } }
WebApplicationContext wac = getWebApplicationContext(sc); if (wac == null) { Enumeration<String> attrNames = sc.getAttributeNames(); while (attrNames.hasMoreElements()) { String attrName = attrNames.nextElement();
@Override protected Set<ConfigurableApplicationContext> findApplicationContexts() { Set<ConfigurableApplicationContext> contexts = new LinkedHashSet<>(); Enumeration<String> attrNames = this.servletContext.getAttributeNames(); while (attrNames.hasMoreElements()) { String attrName = attrNames.nextElement(); Object attrValue = this.servletContext.getAttribute(attrName); if (attrValue instanceof ConfigurableApplicationContext) { contexts.add((ConfigurableApplicationContext) attrValue); } } return contexts; }
@Override public Set<String> keySet() { final Set<String> keySet = new LinkedHashSet<String>(5); final Enumeration<String> attributeNames = this.servletContext.getAttributeNames(); while (attributeNames.hasMoreElements()) { keySet.add(attributeNames.nextElement()); } return keySet; }
/** * Extract context params from {@link ServletContext}. * * @param servletContext actual servlet context. * @return map representing current context parameters. */ public static Map<String, Object> getContextParams(final ServletContext servletContext) { final Map<String, Object> props = new HashMap<>(); final Enumeration names = servletContext.getAttributeNames(); while (names.hasMoreElements()) { final String name = (String) names.nextElement(); props.put(name, servletContext.getAttribute(name)); } return props; }
public static String dumpContextAttributes(ServletContext context) { StringBuilder sb = new StringBuilder(); Enumeration<?> en = context.getAttributeNames(); while (en.hasMoreElements()) { String name = (String) en.nextElement(); sb.append("[" + name + "]: " + context.getAttribute(name) + '\n'); } return sb.toString(); }
/** * Extract context params from {@link ServletContext}. * * @param servletContext actual servlet context. * @return map representing current context parameters. */ public static Map<String, Object> getContextParams(final ServletContext servletContext) { final Map<String, Object> props = new HashMap<>(); final Enumeration names = servletContext.getAttributeNames(); while (names.hasMoreElements()) { final String name = (String) names.nextElement(); props.put(name, servletContext.getAttribute(name)); } return props; }
@Override public Collection<Object> values() { final List<Object> values = new ArrayList<Object>(5); final Enumeration<String> attributeNames = this.servletContext.getAttributeNames(); while (attributeNames.hasMoreElements()) { values.add(this.servletContext.getAttribute(attributeNames.nextElement())); } return values; }
@Override public Set<Map.Entry<String,Object>> entrySet() { final Set<Map.Entry<String,Object>> entrySet = new LinkedHashSet<Map.Entry<String, Object>>(5); final Enumeration<String> attributeNames = this.servletContext.getAttributeNames(); while (attributeNames.hasMoreElements()) { final String key = attributeNames.nextElement(); final Object value = this.servletContext.getAttribute(key); entrySet.add(new MapEntry(key, value)); } return entrySet; }
Map<String, Object> attributeMap = new HashMap<>(); if (servletContext != null) { Enumeration<?> attrNameEnum = servletContext.getAttributeNames(); while (attrNameEnum.hasMoreElements()) { String attrName = (String) attrNameEnum.nextElement();
/** * Find all ServletContext attributes which implement {@link DisposableBean} * and destroy them, removing all affected ServletContext attributes eventually. * @param sc the ServletContext to check */ static void cleanupAttributes(ServletContext sc) { Enumeration<String> attrNames = sc.getAttributeNames(); while (attrNames.hasMoreElements()) { String attrName = attrNames.nextElement(); if (attrName.startsWith("org.springframework.")) { Object attrValue = sc.getAttribute(attrName); if (attrValue instanceof DisposableBean) { try { ((DisposableBean) attrValue).destroy(); } catch (Throwable ex) { logger.error("Couldn't invoke destroy method of attribute with name '" + attrName + "'", ex); } } } } }
public List<String> getAttributeNames() { return enum2list(this.getServletContext().getAttributeNames()); }
@Override public Enumeration<String> getAttributeNamesInScope(int scope) { switch (scope) { case PAGE_SCOPE: return getAttributeNames(); case REQUEST_SCOPE: return this.request.getAttributeNames(); case SESSION_SCOPE: HttpSession session = this.request.getSession(false); return (session != null ? session.getAttributeNames() : Collections.emptyEnumeration()); case APPLICATION_SCOPE: return this.servletContext.getAttributeNames(); default: throw new IllegalArgumentException("Invalid scope: " + scope); } }
@Override public void inject(final ServletContext servletContext, final Targets targets) { instancesInjector.inject(servletContext, targets); final Enumeration<String> attributeNames = servletContext.getAttributeNames(); while (attributeNames.hasMoreElements()) { final String attrName = attributeNames.nextElement(); targets.forEachTargetAndIn(this, (target, in) -> { final String name = in.matchedName(attrName); if (name != null) { final Object attrValue = servletContext.getAttribute(attrName); target.writeValue(name, attrValue, true); } }); } }