/** * @return The request attributes. * @throws NoRequestBoundException */ static RequestAttributes getContextAttributes() throws NoRequestBoundException { RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); if (requestAttributes == null) { throw new NoRequestBoundException(); } if (!(requestAttributes instanceof ServletRequestAttributes) && !(requestAttributes instanceof PortletRequestAttributes)) { throw new IllegalArgumentException( "requestAttributes of unknown class [" + requestAttributes.getClass() + "]"); } return requestAttributes; }