Refactor CookieLocaleResolver
At present, CookieLocaleResolver extends CookieGenerator instead of AbstractLocale(Context)Resolver like other LocaleResolver implementations. This means it duplicates some common aspects of LocaleResolver hierarchy while also exposing some CookieGenerator operations, such as #addCookie and #removeCookie. Additionally, CookieGenerator's support for writing cookies is based on Servlet support which at current baseline doesn't support SameSite directive. This commit refactors CookieLocaleResolver to make it extend AbstractLocaleContextResolver and also replaces CookieGenerator's cookie writing support with newer and more capable ResponseCookie. Simplify creation of CookieLocaleResolver with custom cookie name This commit introduces CookieLocaleResolver constructor that accepts cookie name thus allowing for a simpler creation of an instance with the desired cookie name. See gh-28779
This commit is contained in:
committed by
rstoyanchev
parent
f6d1806e30
commit
7ea49fa9f4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,13 +30,12 @@ import org.springframework.util.Assert;
|
||||
* given response.
|
||||
*
|
||||
* <p>Can serve as base class for components that generate specific cookies,
|
||||
* such as CookieLocaleResolver and CookieThemeResolver.
|
||||
* such as CookieThemeResolver.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 1.1.4
|
||||
* @see #addCookie
|
||||
* @see #removeCookie
|
||||
* @see org.springframework.web.servlet.i18n.CookieLocaleResolver
|
||||
* @see org.springframework.web.servlet.theme.CookieThemeResolver
|
||||
*/
|
||||
public class CookieGenerator {
|
||||
|
||||
Reference in New Issue
Block a user