author | naoto |
Thu, 01 Jun 2017 14:52:53 -0700 | |
changeset 45439 | 5673d77a787b |
parent 43712 | 5dfd0950317c |
permissions | -rw-r--r-- |
36511 | 1 |
/* |
45439
5673d77a787b
8180375: Rename <baseName>Provider to <packagename>.spi.<simpleName>Provider
naoto
parents:
43712
diff
changeset
|
2 |
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
36511 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package java.util.spi; |
|
27 |
||
28 |
import java.util.Locale; |
|
29 |
import java.util.ResourceBundle; |
|
30 |
||
31 |
/** |
|
32 |
* {@code ResourceBundleProvider} is a provider interface that is used for |
|
38782
ff27bc5c278e
8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents:
36511
diff
changeset
|
33 |
* loading resource bundles for named modules. Implementation classes of |
ff27bc5c278e
8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents:
36511
diff
changeset
|
34 |
* this interface are loaded with {@link java.util.ServiceLoader ServiceLoader} |
ff27bc5c278e
8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents:
36511
diff
changeset
|
35 |
* during a call to the |
36511 | 36 |
* {@link ResourceBundle#getBundle(String, Locale, ClassLoader) |
37 |
* ResourceBundle.getBundle} method. The provider service type is determined by |
|
45439
5673d77a787b
8180375: Rename <baseName>Provider to <packagename>.spi.<simpleName>Provider
naoto
parents:
43712
diff
changeset
|
38 |
* {@code <package name> + ".spi." + <simple name> + "Provider"}. |
38782
ff27bc5c278e
8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents:
36511
diff
changeset
|
39 |
* |
ff27bc5c278e
8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents:
36511
diff
changeset
|
40 |
* <p> |
ff27bc5c278e
8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents:
36511
diff
changeset
|
41 |
* For example, if the base name is "com.example.app.MyResources", |
45439
5673d77a787b
8180375: Rename <baseName>Provider to <packagename>.spi.<simpleName>Provider
naoto
parents:
43712
diff
changeset
|
42 |
* {@code com.example.app.spi.MyResourcesProvider} will be the provider service type: |
38782
ff27bc5c278e
8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents:
36511
diff
changeset
|
43 |
* <pre>{@code |
ff27bc5c278e
8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents:
36511
diff
changeset
|
44 |
* public interface MyResourcesProvider extends ResourceBundleProvider { |
ff27bc5c278e
8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents:
36511
diff
changeset
|
45 |
* } |
ff27bc5c278e
8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents:
36511
diff
changeset
|
46 |
* }</pre> |
ff27bc5c278e
8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents:
36511
diff
changeset
|
47 |
* |
36511 | 48 |
* <p> |
49 |
* This providers's {@link #getBundle(String, Locale) getBundle} method is called |
|
50 |
* through the resource bundle loading process instead of {@link |
|
51 |
* java.util.ResourceBundle.Control#newBundle(String, Locale, String, ClassLoader, boolean) |
|
52 |
* ResourceBundle.Control.newBundle()}. Refer to {@link ResourceBundle} for |
|
53 |
* details. |
|
54 |
* |
|
38782
ff27bc5c278e
8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents:
36511
diff
changeset
|
55 |
* @see <a href="../ResourceBundle.html#bundleprovider"> |
ff27bc5c278e
8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents:
36511
diff
changeset
|
56 |
* Resource Bundles in Named Modules</a> |
ff27bc5c278e
8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents:
36511
diff
changeset
|
57 |
* @see <a href="../ResourceBundle.html#RBP_support"> |
ff27bc5c278e
8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents:
36511
diff
changeset
|
58 |
* ResourceBundleProvider Service Providers</a> |
36511 | 59 |
* @since 9 |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
38782
diff
changeset
|
60 |
* @spec JPMS |
36511 | 61 |
*/ |
62 |
public interface ResourceBundleProvider { |
|
63 |
/** |
|
64 |
* Returns a {@code ResourceBundle} for the given bundle name and locale. |
|
38782
ff27bc5c278e
8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents:
36511
diff
changeset
|
65 |
* This method returns {@code null} if there is no {@code ResourceBundle} |
ff27bc5c278e
8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents:
36511
diff
changeset
|
66 |
* found for the given parameters. |
36511 | 67 |
* |
68 |
* |
|
69 |
* @param baseName |
|
70 |
* the base bundle name of the resource bundle, a fully |
|
71 |
* qualified class name |
|
72 |
* @param locale |
|
73 |
* the locale for which the resource bundle should be loaded |
|
74 |
* @return the ResourceBundle created for the given parameters, or null if no |
|
75 |
* {@code ResourceBundle} for the given parameters is found |
|
76 |
*/ |
|
77 |
public ResourceBundle getBundle(String baseName, Locale locale); |
|
78 |
} |