Spring Framework LocaleContext - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework LocaleContext class.

This code example shows how to use the following methods:getLocale
		connection.setRequestProperty(HTTP_HEADER_CONTENT_TYPE, getContentType());
		connection.setRequestProperty(HTTP_HEADER_CONTENT_LENGTH, Integer.toString(contentLength));
 
		LocaleContext localeContext = LocaleContextHolder.getLocaleContext();
		if (localeContext != null) {
			Locale locale = localeContext.getLocale();
			if (locale != null) {
				connection.setRequestProperty(HTTP_HEADER_ACCEPT_LANGUAGE, StringUtils.toLanguageTag(locale));
			} 
		} 
		if (isAcceptGzipEncoding()) {
			connection.setRequestProperty(HTTP_HEADER_ACCEPT_ENCODING, ENCODING_GZIP);
		} 
	} 
 
	/** 
	 * Set the given serialized remote invocation as request body. 
	 * <p>The default implementation simply write the serialized invocation to the 
	 * HttpURLConnection's OutputStream. This can be overridden, for example, to write 
	 * a specific encoding and potentially set appropriate HTTP request headers. 
5
CodeRank
This code example shows how to use the following methods:getLocale
	 */ 
	protected HttpPost createHttpPost(HttpInvokerClientConfiguration config) throws IOException {
		HttpPost httpPost = new HttpPost(config.getServiceUrl());
		LocaleContext localeContext = LocaleContextHolder.getLocaleContext();
		if (localeContext != null) {
			Locale locale = localeContext.getLocale();
			if (locale != null) {
				httpPost.addHeader(HTTP_HEADER_ACCEPT_LANGUAGE, StringUtils.toLanguageTag(locale));
			} 
		} 
		if (isAcceptGzipEncoding()) {
			httpPost.addHeader(HTTP_HEADER_ACCEPT_ENCODING, ENCODING_GZIP);
		} 
		return httpPost;
	} 
 
	/** 
	 * Set the given serialized remote invocation as request body. 
	 * <p>The default implementation simply sets the serialized invocation as the 
	 * HttpPost's request body. This can be overridden, for example, to write a 
5
CodeRank
See Code Examples for Spring Framework LocaleContext Methods: