Package org.springframework.web.context.request

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


    if (user != null && user.hasDefaultLocation()) {
      return new DefaultSearchLocation(user.getDefaultLocationName(),
          user.getDefaultLocationLat(), user.getDefaultLocationLon(), false);
    }

    RequestAttributes attributes = RequestContextHolder.currentRequestAttributes();
    DefaultSearchLocation location = (DefaultSearchLocation) attributes.getAttribute(
        KEY_DEFAULT_SEARCH_LOCATION_FOR_SESSSION,
        RequestAttributes.SCOPE_SESSION);
    return location;
  }
View Full Code Here


      double lon) {
    _currentUserService.setDefaultLocation(locationName, lat, lon);

    DefaultSearchLocation location = new DefaultSearchLocation(locationName,
        lat, lon, true);
    RequestAttributes attributes = RequestContextHolder.currentRequestAttributes();
    attributes.setAttribute(KEY_DEFAULT_SEARCH_LOCATION_FOR_SESSSION, location,
        RequestAttributes.SCOPE_SESSION);
  }
View Full Code Here

  @Override
  public void clearDefaultLocationForCurrentUser() {

    _currentUserService.clearDefaultLocation();

    RequestAttributes attributes = RequestContextHolder.currentRequestAttributes();
    attributes.removeAttribute(KEY_DEFAULT_SEARCH_LOCATION_FOR_SESSSION,
        RequestAttributes.SCOPE_SESSION);
  }
View Full Code Here

    trace.put("path", request.getRequestURI());
    trace.put("headers", allHeaders);
    Throwable exception = (Throwable) request
        .getAttribute("javax.servlet.error.exception");
    if (exception != null && this.errorAttributes != null) {
      RequestAttributes requestAttributes = new ServletRequestAttributes(request);
      Map<String, Object> error = this.errorAttributes.getErrorAttributes(
          requestAttributes, true);
      trace.put("error", error);
    }
    return trace;
View Full Code Here

  @Override
  protected void onActionTearDown() {

    super.onActionTearDown();

    RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
    RequestContextHolder.resetRequestAttributes();
    if (attributes instanceof XWorkRequestAttributes)
      ((XWorkRequestAttributes) attributes).requestCompleted();
  }
View Full Code Here

        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

        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

        toolFactories = null;
    }

    public PullContext getContext() {
        RequestAttributes attrs = null;

        // 从request中取得context,假如当前不是在web环境中,则创建一个新的context,
        // 从而确保在非web环境中也可以使用pull service。
        try {
            attrs = RequestContextHolder.currentRequestAttributes();
        } catch (IllegalStateException e) {
            getLogger().debug("Getting pull context in non-WEB environment: {}", e.getMessage());
        }

        PullContext context;

        if (attrs == null) {
            context = new PullContextImpl();
        } else {
            context = (PullContext) attrs.getAttribute(contextKey, SCOPE_REQUEST);

            if (context == null) {
                context = new PullContextImpl();
                attrs.setAttribute(contextKey, context, SCOPE_REQUEST);
            }
        }

        return context;
    }
View Full Code Here

        toolFactories = null;
    }

    public PullContext getContext() {
        RequestAttributes attrs = null;

        // 从request中取得context,假如当前不是在web环境中,则创建一个新的context,
        // 从而确保在非web环境中也可以使用pull service。
        try {
            attrs = RequestContextHolder.currentRequestAttributes();
        } catch (IllegalStateException e) {
            getLogger().debug("Getting pull context in non-WEB environment: {}", e.getMessage());
        }

        PullContext context;

        if (attrs == null) {
            context = new PullContextImpl();
        } else {
            context = (PullContext) attrs.getAttribute(contextKey, SCOPE_REQUEST);

            if (context == null) {
                context = new PullContextImpl();
                attrs.setAttribute(contextKey, context, SCOPE_REQUEST);
            }
        }

        return context;
    }
View Full Code Here

        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

TOP

Related Classes of org.springframework.web.context.request.RequestAttributes

Copyright © 2018 www.massapicom. 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.