@Nullable public static RequestAttributes getFacesRequestAttributes() { FacesContext facesContext = FacesContext.getCurrentInstance(); return (facesContext != null ? new FacesRequestAttributes(facesContext) : null); } }
@Override public void setAttribute(String name, Object value, int scope) { getAttributeMap(scope).put(name, value); }
@Override public Object resolveReference(String key) { if (REFERENCE_REQUEST.equals(key)) { return getExternalContext().getRequest(); return getExternalContext().getSession(true); return getExternalContext().getContext(); return getExternalContext().getRequestMap(); return getExternalContext().getSessionMap(); return getExternalContext().getApplicationMap(); return getFacesContext(); return getExternalContext().getRequestCookieMap(); return getExternalContext().getRequestHeaderMap(); return getExternalContext().getRequestHeaderValuesMap(); return getExternalContext().getRequestParameterMap(); return getExternalContext().getRequestParameterValuesMap(); return getExternalContext().getInitParameterMap(); return getFacesContext().getViewRoot();
@Override public String getSessionId() { Object session = getExternalContext().getSession(true); try { // HttpSession has a getId() method. Method getIdMethod = session.getClass().getMethod("getId"); return String.valueOf(ReflectionUtils.invokeMethod(getIdMethod, session)); } catch (NoSuchMethodException ex) { throw new IllegalStateException("Session object [" + session + "] does not have a getId() method"); } }
@Override public Object resolveContextualObject(String key) { return new FacesRequestAttributes(getFacesContext()).resolveReference(key); }
/** * Return the JSF ExternalContext that this adapter operates on. * @see javax.faces.context.FacesContext#getExternalContext() */ protected final ExternalContext getExternalContext() { return getFacesContext().getExternalContext(); }
/** * Return the JSF attribute Map for the specified scope. * @param scope constant indicating request or session scope * @return the Map representation of the attributes in the specified scope * @see #SCOPE_REQUEST * @see #SCOPE_SESSION */ protected Map<String, Object> getAttributeMap(int scope) { if (scope == SCOPE_REQUEST) { return getExternalContext().getRequestMap(); } else { return getExternalContext().getSessionMap(); } }
@Override @Nullable public Object resolveContextualObject(String key) { return new FacesRequestAttributes(getFacesContext()).resolveReference(key); }
/** * Return the JSF ExternalContext that this adapter operates on. * @see javax.faces.context.FacesContext#getExternalContext() */ protected final ExternalContext getExternalContext() { return getFacesContext().getExternalContext(); }
@Override public void removeAttribute(String name, int scope) { getAttributeMap(scope).remove(name); }
@Override public Object resolveReference(String key) { if (REFERENCE_REQUEST.equals(key)) { return getExternalContext().getRequest(); return getExternalContext().getSession(true); return getExternalContext().getContext(); return getExternalContext().getRequestMap(); return getExternalContext().getSessionMap(); return getExternalContext().getApplicationMap(); return getFacesContext(); return getExternalContext().getRequestCookieMap(); return getExternalContext().getRequestHeaderMap(); return getExternalContext().getRequestHeaderValuesMap(); return getExternalContext().getRequestParameterMap(); return getExternalContext().getRequestParameterValuesMap(); return getExternalContext().getInitParameterMap(); return getFacesContext().getViewRoot();
@Override public Object getSessionMutex() { // Enforce presence of a session first to allow listeners to create the mutex attribute ExternalContext externalContext = getExternalContext(); Object session = externalContext.getSession(true); Object mutex = externalContext.getSessionMap().get(WebUtils.SESSION_MUTEX_ATTRIBUTE); if (mutex == null) { mutex = (session != null ? session : externalContext); } return mutex; }
@Nullable public static RequestAttributes getFacesRequestAttributes() { FacesContext facesContext = FacesContext.getCurrentInstance(); return (facesContext != null ? new FacesRequestAttributes(facesContext) : null); } }
/** * Return the JSF ExternalContext that this adapter operates on. * @see javax.faces.context.FacesContext#getExternalContext() */ protected final ExternalContext getExternalContext() { return getFacesContext().getExternalContext(); }
@Override public Object getAttribute(String name, int scope) { return getAttributeMap(scope).get(name); }
@Override public Object resolveReference(String key) { if (REFERENCE_REQUEST.equals(key)) { return getExternalContext().getRequest(); return getExternalContext().getSession(true); return getExternalContext().getContext(); return getExternalContext().getRequestMap(); return getExternalContext().getSessionMap(); return getExternalContext().getApplicationMap(); return getFacesContext(); return getExternalContext().getRequestCookieMap(); return getExternalContext().getRequestHeaderMap(); return getExternalContext().getRequestHeaderValuesMap(); return getExternalContext().getRequestParameterMap(); return getExternalContext().getRequestParameterValuesMap(); return getExternalContext().getInitParameterMap(); return getFacesContext().getViewRoot();
@Override public String getSessionId() { Object session = getExternalContext().getSession(true); try { // HttpSession has a getId() method. Method getIdMethod = session.getClass().getMethod("getId"); return String.valueOf(ReflectionUtils.invokeMethod(getIdMethod, session)); } catch (NoSuchMethodException ex) { throw new IllegalStateException("Session object [" + session + "] does not have a getId() method"); } }
@Nullable public static RequestAttributes getFacesRequestAttributes() { FacesContext facesContext = FacesContext.getCurrentInstance(); return (facesContext != null ? new FacesRequestAttributes(facesContext) : null); } }
/** * Return the JSF ExternalContext that this adapter operates on. * @see javax.faces.context.FacesContext#getExternalContext() */ protected final ExternalContext getExternalContext() { return getFacesContext().getExternalContext(); }
@Override public Object getAttribute(String name, int scope) { return getAttributeMap(scope).get(name); }