File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed
managers/context-manager-locale Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -11,29 +11,28 @@ allowing a configured `Locale` to be propagated.
11111 . Add it to your classpath.
1212 ``` xml
1313 <dependency >
14- <groupId >nl.talsmasoftware.context</groupId >
15- <artifactId >locale- context</artifactId >
14+ <groupId >nl.talsmasoftware.context.managers </groupId >
15+ <artifactId >context-manager-locale </artifactId >
1616 <version >[see Maven badge above]</version >
1717 </dependency >
1818 ```
19192 . Make sure to use the ` ContextAwareExecutorService ` as your threadpool.
20203 . Set the current Locale for some block of code:
2121 ``` java
22- private static LocaleContextManager localeContextManager = new LocaleContextManager ();
23-
2422 private void runWithLocale(Locale locale, Runnable someCode) {
25- try (Context< Locale > ctx = localeContextManager . activate (locale)) {
23+ try (Context ctx = CurrentLocaleHolder . set (locale)) {
2624 someCode. run();
2725 }
2826 }
2927 ```
30284 . Use the LocaleContext anywhere in your application:
3129 ``` java
3230 private void someMethod() {
33- Locale locale = LocaleContextManager . getCurrentLocaleOrDefault();
31+ Optional<Locale > optionalLocale = CurrentLocaleHolder . get();
32+ Locale locale = CurrentLocaleHolder . getOrDefault();
3433 }
3534 ```
3635
3736
38- [ maven-img ] : https://img.shields.io/maven-central/v/nl.talsmasoftware.context/locale- context
39- [ maven ] : https://search.maven.org/artifact/nl.talsmasoftware.context/locale- context
37+ [ maven-img ] : https://img.shields.io/maven-central/v/nl.talsmasoftware.context.managers/ context-manager-locale
38+ [ maven ] : https://search.maven.org/artifact/nl.talsmasoftware.context.managers/ context-manager-locale
You can’t perform that action at this time.
0 commit comments