129 } else if (o != null) {
130 Log.debug("Bundle param " + key + " is not type " + klass);
131 }
132 }
133 return defaultValue;
134 }
135
136 public <C> C fetchParam(Class<C> klass, String... keys) {
137 return fetchParamWithDefault(klass, null, keys);
138 }
139
140 // NOTE: we do not care about application parameters here
141 // as they will be embeded into jar file manifest and
142 // java launcher will take care of them!
143
144 public Map<String, ? super Object> getBundleParamsAsMap() {
145 return new HashMap<>(params);
146 }
147
148 public void setJvmargs(List<String> jvmargs) {
149 putUnlessNullOrEmpty(JVM_OPTIONS.getID(), jvmargs);
150 }
151
152 public void setArguments(List<String> arguments) {
153 putUnlessNullOrEmpty(ARGUMENTS.getID(), arguments);
154 }
155
156 public void setAddModules(String value) {
157 putUnlessNull(StandardBundlerParam.ADD_MODULES.getID(), value);
158 }
159
160 public void setLimitModules(String value) {
161 putUnlessNull(StandardBundlerParam.LIMIT_MODULES.getID(), value);
162 }
163
164 public void setModulePath(String value) {
165 putUnlessNull(StandardBundlerParam.MODULE_PATH.getID(), value);
166 }
167
168 public void setMainModule(String value) {
169 putUnlessNull(StandardBundlerParam.MODULE.getID(), value);
170 }
171
172 public void setDebug(String value) {
173 putUnlessNull(JLinkBundlerHelper.DEBUG.getID(), value);
174 }
175
176 public String getApplicationID() {
177 return fetchParam(IDENTIFIER);
178 }
179
180 public String getPreferencesID() {
181 return fetchParam(PREFERENCES_ID);
182 }
183
184 public String getApplicationClass() {
185 return fetchParam(MAIN_CLASS);
186 }
187
188 public void setApplicationClass(String applicationClass) {
189 putUnlessNull(PARAM_APPLICATION_CLASS, applicationClass);
190 }
191
192 public String getAppVersion() {
193 return fetchParam(VERSION);
194 }
195
196 public void setAppVersion(String version) {
197 putUnlessNull(PARAM_VERSION, version);
198 }
199
200 public String getDescription() {
201 return fetchParam(DESCRIPTION);
202 }
203
223 }
224
225 @SuppressWarnings("deprecation")
226 public void setType(BundlerType type) {
227 putUnlessNull(PARAM_TYPE, type);
228 }
229
230 public String getBundleFormat() {
231 return fetchParam(String.class, PARAM_BUNDLE_FORMAT);
232 }
233
234 public void setBundleFormat(String t) {
235 putUnlessNull(PARAM_BUNDLE_FORMAT, t);
236 }
237
238 public boolean getVerbose() {
239 return fetchParam(VERBOSE);
240 }
241
242 public List<String> getJvmargs() {
243 return JVM_OPTIONS.fetchFrom(params);
244 }
245
246 public List<String> getArguments() {
247 return ARGUMENTS.fetchFrom(params);
248 }
249
250 public jdk.jpackage.internal.RelativeFileSet getAppResource() {
251 return fetchParam(APP_RESOURCES);
252 }
253
254 public void setAppResource(jdk.jpackage.internal.RelativeFileSet fs) {
255 putUnlessNull(PARAM_APP_RESOURCES, fs);
256 }
257
258 public void setAppResourcesList(
259 List<jdk.jpackage.internal.RelativeFileSet> rfs) {
260 putUnlessNull(APP_RESOURCES_LIST.getID(), rfs);
261 }
262
263 public String getMainClassName() {
264 String applicationClass = getApplicationClass();
265
266 if (applicationClass == null) {
267 return null;
268 }
269
270 int idx = applicationClass.lastIndexOf(".");
271 if (idx >= 0) {
272 return applicationClass.substring(idx+1);
273 }
274 return applicationClass;
275 }
276
277 public String getCopyright() {
278 return fetchParam(COPYRIGHT);
279 }
280
281 public void setCopyright(String c) {
282 putUnlessNull(PARAM_COPYRIGHT, c);
283 }
284
285 public String getIdentifier() {
286 return fetchParam(IDENTIFIER);
287 }
288
289 public void setIdentifier(String s) {
290 putUnlessNull(PARAM_IDENTIFIER, s);
291 }
292
293 private String mainJar = null;
294
295 // assuming that application was packaged according to the rules
296 // we must have application jar, i.e. jar where we embed launcher
297 // and have main application class listed as main class!
298 // If there are more than one, or none - it will be treated as
299 // deployment error
300 //
301 // Note we look for both JavaFX executable jars and regular executable jars
302 // As long as main "application" entry point is the same it is main class
303 // (i.e. for FX jar we will use JavaFX manifest entry ...)
304 public String getMainApplicationJar() {
305 jdk.jpackage.internal.RelativeFileSet appResources = getAppResource();
306 if (mainJar != null) {
307 if (getApplicationClass() == null) try {
308 if (appResources != null) {
309 File srcdir = appResources.getBaseDirectory();
310 JarFile jf = new JarFile(new File(srcdir, mainJar));
|
129 } else if (o != null) {
130 Log.debug("Bundle param " + key + " is not type " + klass);
131 }
132 }
133 return defaultValue;
134 }
135
136 public <C> C fetchParam(Class<C> klass, String... keys) {
137 return fetchParamWithDefault(klass, null, keys);
138 }
139
140 // NOTE: we do not care about application parameters here
141 // as they will be embeded into jar file manifest and
142 // java launcher will take care of them!
143
144 public Map<String, ? super Object> getBundleParamsAsMap() {
145 return new HashMap<>(params);
146 }
147
148 public void setJvmargs(List<String> jvmargs) {
149 putUnlessNullOrEmpty(JAVA_OPTIONS.getID(), jvmargs);
150 }
151
152 public void setArguments(List<String> arguments) {
153 putUnlessNullOrEmpty(ARGUMENTS.getID(), arguments);
154 }
155
156 public void setAddModules(String value) {
157 putUnlessNull(StandardBundlerParam.ADD_MODULES.getID(), value);
158 }
159
160 public void setLimitModules(String value) {
161 putUnlessNull(StandardBundlerParam.LIMIT_MODULES.getID(), value);
162 }
163
164 public void setModulePath(String value) {
165 putUnlessNull(StandardBundlerParam.MODULE_PATH.getID(), value);
166 }
167
168 public void setMainModule(String value) {
169 putUnlessNull(StandardBundlerParam.MODULE.getID(), value);
170 }
171
172 public void setDebug(String value) {
173 putUnlessNull(JLinkBundlerHelper.DEBUG.getID(), value);
174 }
175
176 public String getApplicationID() {
177 return fetchParam(IDENTIFIER);
178 }
179
180 public String getApplicationClass() {
181 return fetchParam(MAIN_CLASS);
182 }
183
184 public void setApplicationClass(String applicationClass) {
185 putUnlessNull(PARAM_APPLICATION_CLASS, applicationClass);
186 }
187
188 public String getAppVersion() {
189 return fetchParam(VERSION);
190 }
191
192 public void setAppVersion(String version) {
193 putUnlessNull(PARAM_VERSION, version);
194 }
195
196 public String getDescription() {
197 return fetchParam(DESCRIPTION);
198 }
199
219 }
220
221 @SuppressWarnings("deprecation")
222 public void setType(BundlerType type) {
223 putUnlessNull(PARAM_TYPE, type);
224 }
225
226 public String getBundleFormat() {
227 return fetchParam(String.class, PARAM_BUNDLE_FORMAT);
228 }
229
230 public void setBundleFormat(String t) {
231 putUnlessNull(PARAM_BUNDLE_FORMAT, t);
232 }
233
234 public boolean getVerbose() {
235 return fetchParam(VERBOSE);
236 }
237
238 public List<String> getJvmargs() {
239 return JAVA_OPTIONS.fetchFrom(params);
240 }
241
242 public List<String> getArguments() {
243 return ARGUMENTS.fetchFrom(params);
244 }
245
246 public jdk.jpackage.internal.RelativeFileSet getAppResource() {
247 return fetchParam(APP_RESOURCES);
248 }
249
250 public void setAppResource(jdk.jpackage.internal.RelativeFileSet fs) {
251 putUnlessNull(PARAM_APP_RESOURCES, fs);
252 }
253
254 public void setAppResourcesList(
255 List<jdk.jpackage.internal.RelativeFileSet> rfs) {
256 putUnlessNull(APP_RESOURCES_LIST.getID(), rfs);
257 }
258
259 public String getMainClassName() {
260 String applicationClass = getApplicationClass();
261
262 if (applicationClass == null) {
263 return null;
264 }
265
266 int idx = applicationClass.lastIndexOf(".");
267 if (idx >= 0) {
268 return applicationClass.substring(idx+1);
269 }
270 return applicationClass;
271 }
272
273 public String getCopyright() {
274 return fetchParam(COPYRIGHT);
275 }
276
277 public void setCopyright(String c) {
278 putUnlessNull(PARAM_COPYRIGHT, c);
279 }
280
281 private String mainJar = null;
282
283 // assuming that application was packaged according to the rules
284 // we must have application jar, i.e. jar where we embed launcher
285 // and have main application class listed as main class!
286 // If there are more than one, or none - it will be treated as
287 // deployment error
288 //
289 // Note we look for both JavaFX executable jars and regular executable jars
290 // As long as main "application" entry point is the same it is main class
291 // (i.e. for FX jar we will use JavaFX manifest entry ...)
292 public String getMainApplicationJar() {
293 jdk.jpackage.internal.RelativeFileSet appResources = getAppResource();
294 if (mainJar != null) {
295 if (getApplicationClass() == null) try {
296 if (appResources != null) {
297 File srcdir = appResources.getBaseDirectory();
298 JarFile jf = new JarFile(new File(srcdir, mainJar));
|