diff --git a/i18n-api/src/main/java/hu/blackbelt/osgi/i18n/api/I18nService.java b/i18n-api/src/main/java/hu/blackbelt/osgi/i18n/api/I18nService.java index 83a19dd..2ec1660 100644 --- a/i18n-api/src/main/java/hu/blackbelt/osgi/i18n/api/I18nService.java +++ b/i18n-api/src/main/java/hu/blackbelt/osgi/i18n/api/I18nService.java @@ -1,5 +1,8 @@ package hu.blackbelt.osgi.i18n.api; +import java.util.Locale; +import java.util.function.Supplier; + public interface I18nService { /** @@ -9,6 +12,14 @@ public interface I18nService { */ T register(Class clazz); + /** + * Register an i18N proxy interface to OSGi service registry. The proxy methods resolved as string to access i18n data. + * + * @param clazz + * @param localeSupplier + */ + T register(Class clazz, Supplier localeSupplier); + /** * Unregister an i18N proxy interface from OSGi service registry. * @param clazz diff --git a/i18n-resourcebundle/src/main/java/hu/blackbelt/osgi/i18n/resourcebundle/I18nServiceImpl.java b/i18n-resourcebundle/src/main/java/hu/blackbelt/osgi/i18n/resourcebundle/I18nServiceImpl.java index a24d811..1b780a0 100644 --- a/i18n-resourcebundle/src/main/java/hu/blackbelt/osgi/i18n/resourcebundle/I18nServiceImpl.java +++ b/i18n-resourcebundle/src/main/java/hu/blackbelt/osgi/i18n/resourcebundle/I18nServiceImpl.java @@ -61,6 +61,11 @@ void deactivate() { @Override public T register(Class clazz) { + return register(clazz, this.localeSupplier); + } + + @Override + public T register(Class clazz, Supplier localeSupplier) { MessageStreamLoader messageStreamLoader = new ClassLoaderBasedMessageStreamLoader(clazz.getClassLoader()); ClassAndRequestContextLocaleBasedMessageResolver messageResolver = new ClassAndRequestContextLocaleBasedMessageResolver(localeSupplier, clazz, messageStreamLoader, null);