/** * expose the request to the current thread * @param request */ public static void exposeRequest(PortletRequest request) { //use same code as requestInitialized from Spring RequestContextListener PortletRequestAttributes attributes = new PortletRequestAttributes(request); request.setAttribute(REQUEST_ATTRIBUTES_ATTRIBUTE, attributes); LocaleContextHolder.setLocale(request.getLocale()); RequestContextHolder.setRequestAttributes(attributes); }
/** * Bind the portlet request and context to the current thread (to use Sping-scoped beans). * @param request * @param context * @return the request attributes (that should be released by unbindRequest()). */ public static PortletRequestAttributes bindRequestAndContext( final PortletRequest request, final PortletContext context) { LocaleContextHolder.setLocale(request.getLocale()); PortletRequestAttributes requestAttributes = new PortletRequestAttributes(request); RequestContextHolder.setRequestAttributes(requestAttributes); BeanUtilsWeb.initBeanFactory(context); return requestAttributes; }
PortletRequestAttributes requestAttributes = null; if (previousRequestAttributes == null || previousRequestAttributes.getClass().equals(PortletRequestAttributes.class)) { requestAttributes = new PortletRequestAttributes(request); RequestContextHolder.setRequestAttributes(requestAttributes, this.threadContextInheritable);
PortletRequestAttributes.class == previousRequestAttributes.getClass() || ServletRequestAttributes.class == previousRequestAttributes.getClass()) { requestAttributes = new PortletRequestAttributes(request, response); RequestContextHolder.setRequestAttributes(requestAttributes, this.threadContextInheritable);