Description
e.g.:
@Bundle //without #name it will be mapped by convention
public interface MyConfig
{
@Named("value1")
public class MyValue1 implements BundleKey, MyConfig {}
public class MyValue2 implements BundleKey, MyConfig {}
}
usage:
@Inject
@Bundle(MyConfig.class)
private ResourceBundle resourceBundle;
//...
this.resourceBundle.getValue(MyConfig.MyValue2.class);
@Produces
@MyConfig
protected org.apache.myfaces.extensions.cdi.core.api.ResourceBundle createConfig(org.apache.myfaces.extensions.cdi.core.api.ResourceBundle injectableResourceBundle) {
return injectableResourceBundle.useBundle("my.custom.bundle");
}
or
@Produces
@MyLabels
protected org.apache.myfaces.extensions.cdi.core.api.ResourceBundle createLabels(@Jsf org.apache.myfaces.extensions.cdi.core.api.ResourceBundle injectableResourceBundle) {
return injectableResourceBundle.useBundle("my.custom.bundle");
}
... to benefit from the existing local-resolver.
usage:
@Inject
@MyLabels
private ResourceBundle injectableResourceBundle;
this.injectableResourceBundle.getValue("myKey");
it would allow to inject resource-bundles in a type-safe manner and it should be a simple wrapper for java.util.ResourceBundle but without MissingResourceException.