diff --git a/i18n-api/src/main/java/hu/blackbelt/osgi/i18n/api/EnumI18nService.java b/i18n-api/src/main/java/hu/blackbelt/osgi/i18n/api/EnumI18nService.java index 0c0d61c..4c0ba0e 100644 --- a/i18n-api/src/main/java/hu/blackbelt/osgi/i18n/api/EnumI18nService.java +++ b/i18n-api/src/main/java/hu/blackbelt/osgi/i18n/api/EnumI18nService.java @@ -20,11 +20,13 @@ public interface EnumI18nService { */ void register(Class clazz, Supplier localeSupplier); + void register(String className, ClassLoader classLoader) throws ClassNotFoundException; - /** - * Unregister an Enm i18n message. - * @param clazz - */ + void register(String className, Supplier localeSupplier, ClassLoader classLoader) throws ClassNotFoundException; + /** + * Unregister an Enm i18n message. + * @param clazz + */ void unregister(Class clazz); String getMessageForEnum(Enum entry, Object... args); diff --git a/i18n-resourcebundle/src/main/java/hu/blackbelt/osgi/i18n/resourcebundle/EnumI18nServiceImpl.java b/i18n-resourcebundle/src/main/java/hu/blackbelt/osgi/i18n/resourcebundle/EnumI18nServiceImpl.java index 576e9eb..0ffc79f 100644 --- a/i18n-resourcebundle/src/main/java/hu/blackbelt/osgi/i18n/resourcebundle/EnumI18nServiceImpl.java +++ b/i18n-resourcebundle/src/main/java/hu/blackbelt/osgi/i18n/resourcebundle/EnumI18nServiceImpl.java @@ -48,10 +48,17 @@ void activate(Config config) { defaultLocale = I18NUtil.getLocaleFromBCP47(config.defaultLocale()); } + @Override public void register(Class clazz) { register(clazz, this.localeSupplier); } + @Override + public void register(String className, ClassLoader classLoader) throws ClassNotFoundException { + Class clazz = (Class) classLoader.loadClass(className); + register(clazz, this.localeSupplier); + } + @Override public void register(Class clazz, Supplier localeSupplier) { MessageStreamLoader messageStreamLoader = new ClassLoaderBasedMessageStreamLoader(clazz.getClassLoader()); @@ -60,6 +67,12 @@ public void register(Class clazz, Supplier localeSupplie resolvers.put(clazz, messageResolver); } + @Override + public void register(String className, Supplier localeSupplier, ClassLoader classLoader) throws ClassNotFoundException { + Class clazz = (Class) classLoader.loadClass(className); + register(clazz, localeSupplier); + } + public void unregister(Class clazz) { resolvers.remove(clazz); }