@SuppressWarnings({"UnusedDeclaration"}) protected void setContextAttribute(String key, Object value) { if (value == null) { removeContextAttribute(key); } else { getRequiredServletContext().setAttribute(key, value); } }
/** * It is highly recommended not to override this method directly, and instead override the * {@link #toStringBuilder() toStringBuilder()} method, a better-performing alternative. * * @return the String representation of this instance. */ @Override public String toString() { return toStringBuilder().toString(); }
private ServletContext getRequiredServletContext() { ServletContext servletContext = getServletContext(); if (servletContext == null) { String msg = "ServletContext property must be set via the setServletContext method."; throw new IllegalStateException(msg); } return servletContext; }
@SuppressWarnings({"UnusedDeclaration"}) protected Object getContextAttribute(String key) { return getRequiredServletContext().getAttribute(key); }
@SuppressWarnings({"UnusedDeclaration"}) protected String getContextInitParam(String paramName) { return getServletContext().getInitParameter(paramName); }
protected void removeContextAttribute(String key) { getRequiredServletContext().removeAttribute(key); }