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 jdk.packager.services;
27
28 import jdk.packager.services.userjvmoptions.LauncherUserJvmOptions;
29 import java.util.Iterator;
30 import java.util.Map;
31 import java.util.ServiceLoader;
32
33 /**
34 * Runtime access to the UserJVMOptions.
35 *
36 * This class is not typically available in the Java Runtime, you must
37 * explicitly include the 'packager.jar' file from the lib directory
38 * of the JDK as part of your application bundle.
39 *
40 * @since 8u40
41 */
42 public interface UserJvmOptionsService {
43
44 /**
45 * Get the instance of UserJvmOptionService to use. Which one to use is
46 * configured by the packager and the launcher. Do not directly
47 * instantiate any instance of this interface, use this method to get
48 * an appropriate instance.
49 *
50 * @return the instance of UserJvmOptionsService for your application.
51 */
52 static UserJvmOptionsService getUserJVMDefaults() {
53 ServiceLoader<UserJvmOptionsService> loader = ServiceLoader.load(UserJvmOptionsService.class);
54 Iterator<UserJvmOptionsService> iter = loader.iterator();
55 if (iter.hasNext()) {
56 return iter.next();
57 } else {
58 return new LauncherUserJvmOptions();
59 //return new PreferencesUserJvmOptions();
60 }
61 }
62
63 /**
64 * The "current" set of UserJVMOptions.
65 *
66 * This will take effect on the next application start, and this may not
67 * reflect the current set of UserJVMOptions used to start this application.
68 *
69 * @return A map of the keys and values. Alterations to this map will not
70 * change the stored UserJVMOptions
71 */
72 Map<String, String> getUserJVMOptions();
73
74 /**
75 * Sets the passed in options as the UserJVMOptions.
76 *
77 * If the application has specified default values and those keys are not
78 * in this map, they will be replaced by the default values.
79 *
80 * No validation or error checking is performed on these values. It is
81 * entirely possible that you may provide a set of UserJVMOptions that
82 * may prevent the normal startup of your application and may require
83 * manual intervention to resolve.
84 *
85 * @param options The UserJVMOptions to set.
86 */
87 void setUserJVMOptions(Map<String, String> options);
88
89 /**
90 * The "default" set of UserJVMOptions.
91 *
92 * This returns the default set of keys and values that the application has
93 * been configured to use.
94 *
95 * @return the keys and values of the default UserJVMOptions.
96 * @throws UnsupportedOperationException if the defaults cannot be calculated.
97 */
98 Map<String, String> getUserJVMOptionDefaults();
99
100 }
|
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 jdk.packager.services;
27
28 import jdk.packager.services.userjvmoptions.PreferencesUserJvmOptions;
29 import java.util.Iterator;
30 import java.util.Map;
31 import java.util.ServiceLoader;
32
33 /**
34 * Runtime access to the UserJVMOptions.
35 *
36 * This class is not typically available in the Java Runtime, you must
37 * explicitly include the 'jdk.packager.services' module from the jmod directory
38 * of the JDK as part of your application bundle.
39 *
40 * @since 9
41 */
42 public interface UserJvmOptionsService {
43
44 /**
45 * Get the instance of UserJvmOptionService to use. Which one to use is
46 * configured by the packager and the launcher. Do not directly
47 * instantiate any instance of this interface, use this method to get
48 * an appropriate instance.
49 *
50 * @return the instance of UserJvmOptionsService for your application.
51 */
52 static UserJvmOptionsService getUserJVMDefaults() {
53 ServiceLoader<UserJvmOptionsService> loader = ServiceLoader.load(UserJvmOptionsService.class);
54 Iterator<UserJvmOptionsService> iter = loader.iterator();
55 if (iter.hasNext()) {
56 return iter.next();
57 } else {
58 return new PreferencesUserJvmOptions();
59 }
60 }
61
62 /**
63 * The "current" set of UserJVMOptions.
64 *
65 * This will take effect on the next application start, and this may not
66 * reflect the current set of UserJVMOptions used to start this application.
67 *
68 * @return A map of the keys and values. Alterations to this map will not
69 * change the stored UserJVMOptions
70 */
71 Map<String, String> getUserJVMOptions();
72
73 /**
74 * Sets the passed in options as the UserJVMOptions.
75 *
76 * If the application has specified default values and those keys are not
77 * in this map, they will be replaced by the default values.
78 *
79 * No validation or error checking is performed on these values. It is
80 * entirely possible that you may provide a set of UserJVMOptions that
81 * may prevent the normal startup of your application and may require
82 * manual intervention to resolve.
83 *
84 * @param options The UserJVMOptions to set.
85 */
86 void setUserJVMOptions(Map<String, String> options);
87
88 /**
89 * The "default" set of UserJVMOptions.
90 *
91 * This returns the default set of keys and values that the application has
92 * been configured to use.
93 *
94 * @return the keys and values of the default UserJVMOptions.
95 * @throws UnsupportedOperationException if the defaults cannot be calculated.
96 */
97 Map<String, String> getUserJVMOptionDefaults();
98 }
|