< prev index next >

src/java.base/share/classes/java/util/ResourceBundle.java

Print this page




 234  *
 235  * <h4><a id="other-modules">Resource bundles in other modules and class path</a></h4>
 236  *
 237  * Resource bundles in a named module may be <em>encapsulated</em> so that
 238  * it cannot be located by code in other modules.  Resource bundles
 239  * in unnamed modules and class path are open for any module to access.
 240  * Resource bundle follows the resource encapsulation rules as specified
 241  * in {@link Module#getResourceAsStream(String)}.
 242  *
 243  * <p>The {@code getBundle} factory methods with no {@code Control} parameter
 244  * locate and load resource bundles from
 245  * {@linkplain ResourceBundleProvider service providers}.
 246  * It may continue the search as if calling {@link Module#getResourceAsStream(String)}
 247  * to find the named resource from a given module and calling
 248  * {@link ClassLoader#getResourceAsStream(String)}; refer to
 249  * the specification of the {@code getBundle} method for details.
 250  * Only non-encapsulated resource bundles of "{@code java.class}"
 251  * or "{@code java.properties}" format are searched.
 252  *
 253  * <p>If the caller module is a
 254  * <a href="{@docRoot}/java/util/spi/ResourceBundleProvider.html#obtain-resource-bundle">
 255  * resource bundle provider</a>, it does not fall back to the
 256  * class loader search.
 257  *
 258  * <h4>Resource bundles in automatic modules</h4>
 259  *
 260  * A common format of resource bundles is in {@linkplain PropertyResourceBundle
 261  * .properties} file format.  Typically {@code .properties} resource bundles
 262  * are packaged in a JAR file.  Resource bundle only JAR file can be readily
 263  * deployed as an <a href="{@docRoot}/java/lang/module/ModuleFinder.html#automatic-modules">
 264  * automatic module</a>.  For example, if the JAR file contains the
 265  * entry "{@code p/q/Foo_ja.properties}" and no {@code .class} entry,
 266  * when resolved and defined as an automatic module, no package is derived
 267  * for this module.  This allows resource bundles in {@code .properties}
 268  * format packaged in one or more JAR files that may contain entries
 269  * in the same directory and can be resolved successfully as
 270  * automatic modules.
 271  *
 272  * <h3>ResourceBundle.Control</h3>
 273  *
 274  * The {@link ResourceBundle.Control} class provides information necessary
 275  * to perform the bundle loading process by the <code>getBundle</code>
 276  * factory methods that take a <code>ResourceBundle.Control</code>
 277  * instance. You can implement your own subclass in order to enable
 278  * non-standard resource bundle formats, change the search strategy, or
 279  * define caching parameters. Refer to the descriptions of the class and the
 280  * {@link #getBundle(String, Locale, ClassLoader, Control) getBundle}
 281  * factory method for details.
 282  *
 283  * <p> {@link ResourceBundle.Control} is designed for an application deployed




 234  *
 235  * <h4><a id="other-modules">Resource bundles in other modules and class path</a></h4>
 236  *
 237  * Resource bundles in a named module may be <em>encapsulated</em> so that
 238  * it cannot be located by code in other modules.  Resource bundles
 239  * in unnamed modules and class path are open for any module to access.
 240  * Resource bundle follows the resource encapsulation rules as specified
 241  * in {@link Module#getResourceAsStream(String)}.
 242  *
 243  * <p>The {@code getBundle} factory methods with no {@code Control} parameter
 244  * locate and load resource bundles from
 245  * {@linkplain ResourceBundleProvider service providers}.
 246  * It may continue the search as if calling {@link Module#getResourceAsStream(String)}
 247  * to find the named resource from a given module and calling
 248  * {@link ClassLoader#getResourceAsStream(String)}; refer to
 249  * the specification of the {@code getBundle} method for details.
 250  * Only non-encapsulated resource bundles of "{@code java.class}"
 251  * or "{@code java.properties}" format are searched.
 252  *
 253  * <p>If the caller module is a
 254  * <a href="{@docRoot}/java.base/java/util/spi/ResourceBundleProvider.html#obtain-resource-bundle">
 255  * resource bundle provider</a>, it does not fall back to the
 256  * class loader search.
 257  *
 258  * <h4>Resource bundles in automatic modules</h4>
 259  *
 260  * A common format of resource bundles is in {@linkplain PropertyResourceBundle
 261  * .properties} file format.  Typically {@code .properties} resource bundles
 262  * are packaged in a JAR file.  Resource bundle only JAR file can be readily
 263  * deployed as an <a href="{@docRoot}/java.base/java/lang/module/ModuleFinder.html#automatic-modules">
 264  * automatic module</a>.  For example, if the JAR file contains the
 265  * entry "{@code p/q/Foo_ja.properties}" and no {@code .class} entry,
 266  * when resolved and defined as an automatic module, no package is derived
 267  * for this module.  This allows resource bundles in {@code .properties}
 268  * format packaged in one or more JAR files that may contain entries
 269  * in the same directory and can be resolved successfully as
 270  * automatic modules.
 271  *
 272  * <h3>ResourceBundle.Control</h3>
 273  *
 274  * The {@link ResourceBundle.Control} class provides information necessary
 275  * to perform the bundle loading process by the <code>getBundle</code>
 276  * factory methods that take a <code>ResourceBundle.Control</code>
 277  * instance. You can implement your own subclass in order to enable
 278  * non-standard resource bundle formats, change the search strategy, or
 279  * define caching parameters. Refer to the descriptions of the class and the
 280  * {@link #getBundle(String, Locale, ClassLoader, Control) getBundle}
 281  * factory method for details.
 282  *
 283  * <p> {@link ResourceBundle.Control} is designed for an application deployed


< prev index next >