Examples of RequestAttributes


Examples of org.springframework.web.context.request.RequestAttributes

        getLogger().debug("Bound request context to thread: {}", request);
    }

    private void cleanupSpringWebEnvironment(HttpServletRequest request) {
        RequestAttributes attributes = RequestContextHolder.getRequestAttributes();

        RequestContextHolder.resetRequestAttributes();
        LocaleContextHolder.resetLocaleContext();

        if (attributes instanceof ServletRequestAttributes) {
View Full Code Here

Examples of org.springframework.web.context.request.RequestAttributes

        log.debug("Registered Global Proxy for interface {}", intfs.getName());
    }

    private static class RequestProxyTargetFactory implements ProxyTargetFactory {
        public Object getObject() {
            RequestAttributes requestAttrs = RequestContextHolder.currentRequestAttributes();

            if (!(requestAttrs instanceof ServletRequestAttributes)) {
                throw new IllegalStateException("Current request is not a servlet request");
            }
View Full Code Here

Examples of org.springframework.web.context.request.RequestAttributes

     *
     * @throws IllegalStateException if no WebApplicationContext could not be found
     * @return The current web application context.
     */
    public static WebApplicationContext getCurrentWebApplicationContext() {
        final RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
        return getCurrentWebApplicationContext(attributes);
    }
View Full Code Here

Examples of org.springframework.web.context.request.RequestAttributes

     * @param webAppContext The current web application context.
     * @return A handle which should be passed to {@link #leavingContext(WebApplicationContext, Object)}.
     */
    public static Object enteringContext(WebApplicationContext webAppContext) {
        // get request attributes
        final RequestAttributes attributes = RequestContextHolder.currentRequestAttributes();

        // save current class loader and web application context
        final ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
        final WebApplicationContext oldContext = (WebApplicationContext) attributes.getAttribute(CONTAINER_REQUEST_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);

        // set new class loader and context
        attributes.setAttribute(CONTAINER_REQUEST_ATTRIBUTE, webAppContext, RequestAttributes.SCOPE_REQUEST);
        Thread.currentThread().setContextClassLoader(webAppContext.getClassLoader());

        return new ContextInfo(oldContext, oldClassLoader);
    }
View Full Code Here

Examples of org.springframework.web.context.request.RequestAttributes

            throw new IllegalArgumentException("Handle must be an instance of ContextInfo and not " + handle);
        }
        final ContextInfo info = (ContextInfo) handle;

        // get request attributes
        final RequestAttributes attributes = RequestContextHolder.currentRequestAttributes();

        // restore class loader and previous web application context
        Thread.currentThread().setContextClassLoader(info.classLoader);
        if (info.webAppContext == null) {
            attributes.removeAttribute(CONTAINER_REQUEST_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
        } else {
            attributes.setAttribute(CONTAINER_REQUEST_ATTRIBUTE, info.webAppContext, RequestAttributes.SCOPE_REQUEST);
        }
    }
View Full Code Here

Examples of org.springframework.web.context.request.RequestAttributes

            // for a component that is released by another component insided recycle()
            // which got called by PoolableFactoryBean.enteringPool() <- putIntoPool() <- run() (below),
            // which is registered as destruction callback on the request attributes -
            // such a destruction callback is called *after* the request attributes
            // are set back to null
            final RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
            if (attributes != null) {
                // removing the attribute removes the call back handler!
                attributes.removeAttribute(this.attributeName, RequestAttributes.SCOPE_REQUEST);
            }
            return null;
        }
        if ( method.getName().equals("hashCode") && args == null ) {
            return new Integer(this.hashCode());
View Full Code Here

Examples of org.springframework.web.context.request.RequestAttributes

        renderWithinGrailsWebRequest(model, request, response);
    }

    private void renderWithinGrailsWebRequest(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
        boolean attributesChanged = false;
        try {
            GrailsWebRequest webRequest;
            if(!(requestAttributes instanceof GrailsWebRequest)) {
                webRequest = createGrailsWebRequest(request, response, request.getServletContext());
View Full Code Here

Examples of org.springframework.web.context.request.RequestAttributes

        result.putAll(stack.pop());
        return result;
    }

    private static LayoutWriterStack currentStack() {
        RequestAttributes attributes = RequestContextHolder.currentRequestAttributes();
        if (attributes != null) {
            LayoutWriterStack stack = (LayoutWriterStack) attributes.getAttribute(ATTRIBUTE_NAME_WRITER_STACK, RequestAttributes.SCOPE_REQUEST);
            if (stack == null) {
                stack = new LayoutWriterStack();
                attributes.setAttribute(ATTRIBUTE_NAME_WRITER_STACK, stack, RequestAttributes.SCOPE_REQUEST);
            }
            return stack;
        }
        return null;
    }
View Full Code Here

Examples of org.springframework.web.context.request.RequestAttributes

    /**
     * @return The currently bound GrailsApplication instance
     * @since 2.0
     */
    public static GrailsApplication currentApplication() {
        final RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
        if (!(requestAttributes instanceof GrailsWebRequest)) {
            return null;
        }

        return ((GrailsWebRequest)requestAttributes).getAttributes().getGrailsApplication();
View Full Code Here

Examples of org.springframework.web.context.request.RequestAttributes

     * Looks up the current Grails WebRequest instance
     * @return The GrailsWebRequest instance
     */
    public static GrailsWebRequest lookup() {
        GrailsWebRequest webRequest = null;
        RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
        if (requestAttributes instanceof GrailsWebRequest) {
            webRequest = (GrailsWebRequest) requestAttributes;
        }
        return webRequest;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.