Skip to content

Commit 2451502

Browse files
authored
Update README.md
1 parent 9a9ff0b commit 2451502

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

managers/context-manager-locale/README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,28 @@ allowing a configured `Locale` to be propagated.
1111
1. 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
```
1919
2. Make sure to use the `ContextAwareExecutorService` as your threadpool.
2020
3. 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
```
3028
4. 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

0 commit comments

Comments
 (0)