Package org.springframework.context.i18n

Examples of org.springframework.context.i18n.LocaleContext


    HttpServletRequest processedRequest = request;
    HandlerExecutionChain mappedHandler = null;
    int interceptorIndex = -1;

    // Expose current LocaleResolver and request as LocaleContext.
    LocaleContext previousLocaleContext = LocaleContextHolder.getLocaleContext();
    LocaleContextHolder.setLocaleContext(buildLocaleContext(request), this.threadContextInheritable);

    // Expose current RequestAttributes to current thread.
    RequestAttributes previousRequestAttributes = RequestContextHolder.getRequestAttributes();
    ServletRequestAttributes requestAttributes = new ServletRequestAttributes(request);
View Full Code Here


   * to obtain the current locale, which might change during a request.
   * @param request current HTTP request
   * @return the corresponding LocaleContext
   */
  protected LocaleContext buildLocaleContext(final HttpServletRequest request) {
    return new LocaleContext() {
      public Locale getLocale() {
        return localeResolver.resolveLocale(request);
      }
      public String toString() {
        return getLocale().toString();
View Full Code Here

   * @return the HttpPost instance
   * @throws java.io.IOException if thrown by I/O methods
   */
  protected HttpPost createHttpPost(HttpInvokerClientConfiguration config) throws IOException {
    HttpPost httpPost = new HttpPost(config.getServiceUrl());
    LocaleContext locale = LocaleContextHolder.getLocaleContext();
    if (locale != null) {
      httpPost.addHeader(HTTP_HEADER_ACCEPT_LANGUAGE, StringUtils.toLanguageTag(locale.getLocale()));
    }
    if (isAcceptGzipEncoding()) {
      httpPost.addHeader(HTTP_HEADER_ACCEPT_ENCODING, ENCODING_GZIP);
    }
    return httpPost;
View Full Code Here

    }
    connection.setDoOutput(true);
    connection.setRequestMethod(HTTP_METHOD_POST);
    connection.setRequestProperty(HTTP_HEADER_CONTENT_TYPE, getContentType());
    connection.setRequestProperty(HTTP_HEADER_CONTENT_LENGTH, Integer.toString(contentLength));
    LocaleContext locale = LocaleContextHolder.getLocaleContext();
    if (locale != null) {
      connection.setRequestProperty(HTTP_HEADER_ACCEPT_LANGUAGE, StringUtils.toLanguageTag(locale.getLocale()));
    }
    if (isAcceptGzipEncoding()) {
      connection.setRequestProperty(HTTP_HEADER_ACCEPT_ENCODING, ENCODING_GZIP);
    }
  }
View Full Code Here

   * @return the PostMethod instance
   * @throws IOException if thrown by I/O methods
   */
  protected PostMethod createPostMethod(HttpInvokerClientConfiguration config) throws IOException {
    PostMethod postMethod = new PostMethod(config.getServiceUrl());
    LocaleContext locale = LocaleContextHolder.getLocaleContext();
    if (locale != null) {
      postMethod.addRequestHeader(HTTP_HEADER_ACCEPT_LANGUAGE, StringUtils.toLanguageTag(locale.getLocale()));
    }
    if (isAcceptGzipEncoding()) {
      postMethod.addRequestHeader(HTTP_HEADER_ACCEPT_ENCODING, ENCODING_GZIP);
    }
    return postMethod;
View Full Code Here

    HttpServletRequest processedRequest = request;
    HandlerExecutionChain mappedHandler = null;
    int interceptorIndex = -1;

    // Expose current LocaleResolver and request as LocaleContext.
    LocaleContext previousLocaleContext = LocaleContextHolder.getLocaleContext();
    LocaleContextHolder.setLocaleContext(buildLocaleContext(request), this.threadContextInheritable);

    // Expose current RequestAttributes to current thread.
    RequestAttributes previousRequestAttributes = RequestContextHolder.getRequestAttributes();
    ServletRequestAttributes requestAttributes = new ServletRequestAttributes(request);
View Full Code Here

   * to obtain the current locale, which might change during a request.
   * @param request current HTTP request
   * @return the corresponding LocaleContext
   */
  protected LocaleContext buildLocaleContext(final HttpServletRequest request) {
    return new LocaleContext() {
      public Locale getLocale() {
        return localeResolver.resolveLocale(request);
      }
    };
  }
View Full Code Here

   * @return the HttpPost instance
   * @throws java.io.IOException if thrown by I/O methods
   */
  protected HttpPost createHttpPost(HttpInvokerClientConfiguration config) throws IOException {
    HttpPost httpPost = new HttpPost(config.getServiceUrl());
    LocaleContext locale = LocaleContextHolder.getLocaleContext();
    if (locale != null) {
      httpPost.addHeader(HTTP_HEADER_ACCEPT_LANGUAGE, StringUtils.toLanguageTag(locale.getLocale()));
    }
    if (isAcceptGzipEncoding()) {
      httpPost.addHeader(HTTP_HEADER_ACCEPT_ENCODING, ENCODING_GZIP);
    }
    return httpPost;
View Full Code Here

   * @param request current HTTP request
   * @return the corresponding LocaleContext
   */
  @Override
  protected LocaleContext buildLocaleContext(final HttpServletRequest request) {
    return new LocaleContext() {
      public Locale getLocale() {
        return localeResolver.resolveLocale(request);
      }
      @Override
      public String toString() {
View Full Code Here

   * @param request current HTTP request
   * @return the corresponding LocaleContext
   */
  @Override
  protected LocaleContext buildLocaleContext(final HttpServletRequest request) {
    return new LocaleContext() {
      public Locale getLocale() {
        return localeResolver.resolveLocale(request);
      }
      public String toString() {
        return getLocale().toString();
View Full Code Here

TOP

Related Classes of org.springframework.context.i18n.LocaleContext

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.