/
ManifestBasedSREInstall.java
573 lines (526 loc) · 21.1 KB
/
ManifestBasedSREInstall.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
/*
* $Id$
*
* SARL is an general-purpose agent programming language.
* More details on http://www.sarl.io
*
* Copyright (C) 2014-2019 the original authors or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.sarl.eclipse.runtime;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.ref.SoftReference;
import java.net.URL;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import com.google.common.base.Objects;
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.internal.launching.RuntimeClasspathEntry;
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
import org.eclipse.jdt.launching.LibraryLocation;
import org.eclipse.jdt.launching.PropertyChangeEvent;
import org.osgi.framework.Version;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import io.sarl.eclipse.SARLEclipsePlugin;
import io.sarl.eclipse.util.Utilities;
/**
* SRE install that is based on the information within the MANIFEST file.
*
* <p>The standard SRE install assumes:
* <ul>
* <li>The SRE is based on a single JAR file.</li>
* <li>The main class of the SRE is defined in the Manifest field <code>"Main-Class"</code>.</li>
* <li>The Manifest contains a section named <code>"SARL-Runtime-Environment"</code>. This section contains the following entries:
* <ul>
* <li>The version number of the SARL specifications that are supported by the SRE is defined in the Manifest field <code>"SARL-Spec-Version"</code>.
* </li>
* <li>The name of the SRE may be given by the field <code>"Name"</code>.</li>
* <li>The VM arguments of the SRE may be given by the field <code>"VM-Arguments"</code>.</li>
* <li>The program arguments of the SRE may be given by the field <code>"Program-Arguments"</code>.</li>
* <li>The command line option for avoiding the logo is given by the field <code>"CLI-Hide-Logo"</code>.</li>
* <li>The command line option for displaying the logo is given by the field <code>"CLI-Show-Logo"</code>.</li>
* <li>The command line option for displaying the information messages is given by the field<code>"CLI-Show-Info"</code>.</li>
* <li>The command line option for hiding the information messages is given by the field<code>"CLI-Hide-Info"</code>.</li>
* <li>The command line option for using the default root context id is given by the field<code>"CLI-Default-Context-ID"</code>.</li>
* <li>The command line option for using the random root context id is given by the field<code>"CLI-Random-Context-ID"</code>.</li>
* <li>The command line option for using the agent-type-based root context id is given by the field<code>"CLI-BootAgent-Context-ID"</code>.</li>
* </ul>
* </li>
* </ul>
*
* @author $Author: sgalland$
* @version $FullVersion$
* @mavengroupid $GroupId$
* @mavenartifactid $ArtifactId$
*/
public class ManifestBasedSREInstall extends AbstractSREInstall {
private IPath jarFile;
private String vmArguments = Utilities.EMPTY_STRING;
private String programArguments = Utilities.EMPTY_STRING;
private String cliLogoOff;
private String cliLogoOn;
private String cliShowInfo;
private String cliHideInfo;
private String cliDefaultContextID;
private String cliRandomContextID;
private String cliBootAgentContextID;
private String cliSreOffline;
private String cliNoMoreOption;
private String cliEmbedded;
private String manifestMainClass;
private String manifestName;
private transient SoftReference<Map<String, String>> optionBuffer;
/**
* Construct a SRE installation.
*
* @param id the identifier of this SRE installation.
*/
public ManifestBasedSREInstall(String id) {
super(id);
}
@Override
public IPath getPreferredClassPathContainerPath() {
return null;
}
@Override
public ManifestBasedSREInstall clone() {
final ManifestBasedSREInstall clone = (ManifestBasedSREInstall) super.clone();
clone.jarFile = this.jarFile == null ? null : Path.fromPortableString(clone.jarFile.toPortableString());
return clone;
}
@Override
public ManifestBasedSREInstall copy(String id) {
return (ManifestBasedSREInstall) super.copy(id);
}
/**
* Replies the path to the JAR file that is supporting this SRE installation.
*
* @return the path to the JAR file. Must not be <code>null</code>.
*/
public IPath getJarFile() {
return this.jarFile;
}
/**
* Change the path to the JAR file that is supporting this SRE installation.
*
* @param jarFile the path to the JAR file. Must not be <code>null</code>.
*/
public void setJarFile(IPath jarFile) {
if (!Objects.equal(jarFile, this.jarFile)) {
final PropertyChangeEvent event = new PropertyChangeEvent(this, ISREInstallChangedListener.PROPERTY_JAR_FILE,
this.jarFile, jarFile);
this.jarFile = jarFile;
setDirty(true);
if (getNotify()) {
SARLRuntime.fireSREChanged(event);
}
}
}
@Override
public String getLocation() {
final IPath iJarFile = getJarFile();
if (iJarFile == null) {
return getName();
}
return iJarFile.toOSString();
}
@Override
public String getName() {
String nam = getNameNoDefault();
if (Strings.isNullOrEmpty(nam)) {
final IPath path = getJarFile();
if (path != null) {
nam = path.removeFileExtension().lastSegment();
} else {
nam = getId();
}
}
return nam;
}
@SuppressWarnings({ "checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity" })
@Override
protected void resolveDirtyFields(boolean forceSettings) {
if (this.jarFile != null) {
try (JarFile jFile = new JarFile(this.jarFile.toFile())) {
final Manifest manifest = jFile.getManifest();
//
// Main class
this.manifestMainClass = manifest.getMainAttributes().getValue(SREConstants.MANIFEST_MAIN_CLASS);
if (Strings.isNullOrEmpty(this.manifestMainClass)) {
throw new SREException(MessageFormat.format(Messages.StandardSREInstall_0, getId()));
}
if (forceSettings || Strings.isNullOrEmpty(getMainClass())) {
setMainClass(this.manifestMainClass);
}
// Get SARL section:
final Attributes sarlSection = manifest.getAttributes(SREConstants.MANIFEST_SECTION_SRE);
if (sarlSection == null) {
throw new SREException(Messages.StandardSREInstall_1);
}
//
// SARL version
final String sarlVersion = sarlSection.getValue(SREConstants.MANIFEST_SARL_SPEC_VERSION);
String minVersion = null;
String maxVersion = null;
if (!Strings.isNullOrEmpty(sarlVersion)) {
try {
final Version sarlVer = Version.parseVersion(sarlVersion);
if (sarlVer != null) {
minVersion = new Version(sarlVer.getMajor(), sarlVer.getMinor(), 0).toString();
maxVersion = new Version(sarlVer.getMajor(), sarlVer.getMinor() + 1, 0).toString();
}
} catch (Throwable exception) {
//
}
}
if (forceSettings || Strings.isNullOrEmpty(getMinimalSARLVersion())) {
setMinimalSARLVersion(minVersion);
}
if (forceSettings || Strings.isNullOrEmpty(getMaximalSARLVersion())) {
setMaximalSARLVersion(maxVersion);
}
//
// SRE Name
this.manifestName = Strings.nullToEmpty(sarlSection.getValue(SREConstants.MANIFEST_SRE_NAME));
if (forceSettings || Strings.isNullOrEmpty(getNameNoDefault())) {
setName(this.manifestName);
}
//
// VM arguments
final String vmArgs = Strings.nullToEmpty(sarlSection.getValue(SREConstants.MANIFEST_VM_ARGUMENTS));
if (!this.vmArguments.equals(vmArgs)) {
final PropertyChangeEvent event = new PropertyChangeEvent(this,
ISREInstallChangedListener.PROPERTY_VM_ARGUMENTS, this.vmArguments, Strings.nullToEmpty(vmArgs));
this.vmArguments = vmArgs;
if (getNotify()) {
SARLRuntime.fireSREChanged(event);
}
}
//
// VM-specific attributes
setVMSpecificAttributesMap(null);
//
// Specific CLI Options
this.optionBuffer = null;
this.cliLogoOn = sarlSection.getValue(SREConstants.MANIFEST_CLI_SHOW_LOGO);
this.cliLogoOff = sarlSection.getValue(SREConstants.MANIFEST_CLI_HIDE_LOGO);
this.cliShowInfo = sarlSection.getValue(SREConstants.MANIFEST_CLI_SHOW_INFO);
this.cliHideInfo = sarlSection.getValue(SREConstants.MANIFEST_CLI_HIDE_INFO);
this.cliDefaultContextID = sarlSection.getValue(SREConstants.MANIFEST_CLI_DEFAULT_CONTEXT_ID);
this.cliRandomContextID = sarlSection.getValue(SREConstants.MANIFEST_CLI_RANDOM_CONTEXT_ID);
this.cliBootAgentContextID = sarlSection.getValue(SREConstants.MANIFEST_CLI_BOOT_AGENT_CONTEXT_ID);
this.cliSreOffline = sarlSection.getValue(SREConstants.MANIFEST_CLI_SRE_OFFLINE);
this.cliNoMoreOption = sarlSection.getValue(SREConstants.MANIFEST_CLI_NO_MORE_OPTION);
this.cliEmbedded = sarlSection.getValue(SREConstants.MANIFEST_CLI_EMBEDDED);
//
// Program arguments
final String programArgs = Strings.nullToEmpty(sarlSection.getValue(SREConstants.MANIFEST_PROGRAM_ARGUMENTS));
if (!this.programArguments.equals(programArgs)) {
final PropertyChangeEvent event = new PropertyChangeEvent(this,
ISREInstallChangedListener.PROPERTY_PROGRAM_ARGUMENTS, this.programArguments, programArgs);
this.programArguments = programArgs;
if (getNotify()) {
SARLRuntime.fireSREChanged(event);
}
}
//
// Library Location
if (forceSettings || getClassPathEntries().isEmpty()) {
final List<IRuntimeClasspathEntry> classPath = new ArrayList<>();
LibraryLocation location = new LibraryLocation(this.jarFile, Path.EMPTY, Path.EMPTY);
IClasspathEntry cpEntry = JavaCore.newLibraryEntry(location.getSystemLibraryPath(),
location.getSystemLibrarySourcePath(), location.getPackageRootPath());
IRuntimeClasspathEntry rtcpEntry = new RuntimeClasspathEntry(cpEntry);
// No more a bootstrap library for enabling it to be in the classpath (not the JVM bootstrap).
// In fact you can have a single bootstrap library if you add a new one you remove the default one and it bugs
rtcpEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
classPath.add(rtcpEntry);
//
final String classPathStr = manifest.getMainAttributes().getValue(SREConstants.MANIFEST_CLASS_PATH);
final IPath rootPath = this.jarFile.removeLastSegments(1);
if (!Strings.isNullOrEmpty(classPathStr)) {
for (final String cpElement : classPathStr.split(Pattern.quote(":"))) { //$NON-NLS-1$
final IPath path = parsePath(cpElement, Path.EMPTY, rootPath);
location = new LibraryLocation(path, Path.EMPTY, Path.EMPTY);
cpEntry = JavaCore.newLibraryEntry(location.getSystemLibraryPath(),
location.getSystemLibrarySourcePath(), location.getPackageRootPath());
rtcpEntry = new RuntimeClasspathEntry(cpEntry);
// No more a bootstrap library for enabling it to be in the classpath (not the JVM bootstrap).
// In fact you can have a single bootstrap library if you add a new one you remove the default one and it bugs
rtcpEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
classPath.add(rtcpEntry);
}
}
setClassPathEntries(classPath);
}
//
// Bootstrap
final ZipEntry jEntry = jFile.getEntry(SREConstants.SERVICE_SRE_BOOTSTRAP);
String bootstrap = null;
if (jEntry != null) {
try (InputStream is = jFile.getInputStream(jEntry)) {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(is))) {
String line = reader.readLine();
if (line != null) {
line = line.trim();
if (!line.isEmpty()) {
bootstrap = line;
}
}
}
}
}
if (forceSettings || Strings.isNullOrEmpty(getBootstrap())) {
setBootstrap(bootstrap);
}
} catch (SREException e) {
throw e;
} catch (Throwable e) {
throw new SREException(e);
}
} else {
throw new SREException(Messages.StandardSREInstall_2);
}
}
@Override
public String getSREArguments() {
if (isDirty()) {
setDirty(false);
resolveDirtyFields(true);
}
return this.programArguments;
}
@Override
public String getJVMArguments() {
if (isDirty()) {
setDirty(false);
resolveDirtyFields(true);
}
return this.vmArguments;
}
@Override
public IStatus getValidity(int ignoreCauses) {
if (isDirty()) {
return revalidate(ignoreCauses);
}
try {
final IPath path = getJarFile();
if (path == null && (ignoreCauses & CODE_SOURCE) == 0) {
return SARLEclipsePlugin.getDefault().createStatus(IStatus.ERROR, CODE_SOURCE, Messages.StandardSREInstall_2);
}
final File file = (path == null) ? null : path.toFile();
if ((file == null || !file.canRead()) && (ignoreCauses & CODE_SOURCE) == 0) {
return SARLEclipsePlugin.getDefault().createStatus(IStatus.ERROR, CODE_SOURCE, Messages.StandardSREInstall_3);
}
} catch (Throwable e) {
if ((ignoreCauses & CODE_GENERAL) == 0) {
return SARLEclipsePlugin.getDefault().createStatus(IStatus.ERROR, CODE_GENERAL, e);
}
}
return super.getValidity(ignoreCauses);
}
@Override
public void getAsXML(Document document, Element element) throws IOException {
if (isDirty()) {
setDirty(false);
resolveDirtyFields(true);
}
final IPath path = getJarFile();
element.setAttribute(SREConstants.XML_LIBRARY_PATH, path.toPortableString());
final String name = Strings.nullToEmpty(getName());
if (!name.equals(this.manifestName)) {
element.setAttribute(SREConstants.XML_SRE_NAME, name);
}
final String mainClass = Strings.nullToEmpty(getMainClass());
if (!mainClass.equals(this.manifestMainClass)) {
element.setAttribute(SREConstants.XML_MAIN_CLASS, mainClass);
}
final String bootstrap = Strings.nullToEmpty(getBootstrap());
if (!Strings.isNullOrEmpty(bootstrap)) {
element.setAttribute(SREConstants.XML_BOOTSTRAP, bootstrap);
} else {
element.removeAttribute(SREConstants.XML_BOOTSTRAP);
}
final List<IRuntimeClasspathEntry> libraries = getClassPathEntries();
if (libraries.size() != 1 || !libraries.get(0).getClasspathEntry().getPath().equals(this.jarFile)) {
final IPath rootPath = path.removeLastSegments(1);
for (final IRuntimeClasspathEntry location : libraries) {
final Element libraryNode = document.createElement(SREConstants.XML_LIBRARY_LOCATION);
libraryNode.setAttribute(SREConstants.XML_SYSTEM_LIBRARY_PATH,
makeRelativePath(location.getPath(), path, rootPath));
libraryNode.setAttribute(SREConstants.XML_PACKAGE_ROOT_PATH,
makeRelativePath(location.getSourceAttachmentRootPath(), path, rootPath));
libraryNode.setAttribute(SREConstants.XML_SOURCE_PATH,
makeRelativePath(location.getSourceAttachmentPath(), path, rootPath));
/* No javadoc path accessible from ClasspathEntry
final URL javadoc = location.getJavadocLocation();
if (javadoc != null) {
libraryNode.setAttribute(SREConstants.XML_JAVADOC_PATH, javadoc.toString());
}
*/
element.appendChild(libraryNode);
}
}
}
@Override
@SuppressWarnings("checkstyle:npathcomplexity")
public void setFromXML(Element element) throws IOException {
final IPath path = parsePath(
element.getAttribute(SREConstants.XML_LIBRARY_PATH), null, null);
try {
if (path != null) {
setJarFile(path);
final String name = element.getAttribute(SREConstants.XML_SRE_NAME);
if (!Strings.isNullOrEmpty(name)) {
setName(name);
}
final String mainClass = element.getAttribute(SREConstants.XML_MAIN_CLASS);
if (!Strings.isNullOrEmpty(mainClass)) {
setMainClass(mainClass);
}
final String bootstrap = element.getAttribute(SREConstants.XML_BOOTSTRAP);
if (!Strings.isNullOrEmpty(bootstrap)) {
setBootstrap(bootstrap);
}
final List<IRuntimeClasspathEntry> locations = new ArrayList<>();
final NodeList children = element.getChildNodes();
final IPath rootPath = path.removeLastSegments(1);
for (int i = 0; i < children.getLength(); ++i) {
final Node node = children.item(i);
if (node instanceof Element && SREConstants.XML_LIBRARY_LOCATION.equalsIgnoreCase(node.getNodeName())) {
final Element libraryNode = (Element) node;
final IPath systemLibraryPath = parsePath(
libraryNode.getAttribute(SREConstants.XML_SYSTEM_LIBRARY_PATH), null, rootPath);
if (systemLibraryPath != null) {
final IPath packageRootPath = parsePath(
libraryNode.getAttribute(SREConstants.XML_PACKAGE_ROOT_PATH),
Path.EMPTY, rootPath);
final IPath sourcePath = parsePath(
libraryNode.getAttribute(SREConstants.XML_SOURCE_PATH), Path.EMPTY, rootPath);
URL javadoc = null;
try {
final String urlTxt = libraryNode.getAttribute(SREConstants.XML_JAVADOC_PATH);
javadoc = new URL(urlTxt);
} catch (Throwable exception) {
//
}
final LibraryLocation location = new LibraryLocation(systemLibraryPath, sourcePath, packageRootPath,
javadoc);
final IClasspathEntry cpEntry = JavaCore.newLibraryEntry(
location.getSystemLibraryPath(),
location.getSystemLibrarySourcePath(),
location.getPackageRootPath());
final IRuntimeClasspathEntry rtcpEntry = new RuntimeClasspathEntry(cpEntry);
// No more a bootstrap library for enabling it to be in the classpath (not the JVM bootstrap).
// In fact you can have a single bootstrap library if you add a new one you remove the default one and it bugs
rtcpEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
locations.add(rtcpEntry);
} else {
SARLEclipsePlugin.getDefault()
.logErrorMessage(MessageFormat.format(Messages.StandardSREInstall_4, getId()));
}
}
}
if (!locations.isEmpty()) {
setClassPathEntries(locations);
}
return;
}
} catch (Throwable exception) {
throw new IOException(MessageFormat.format(Messages.StandardSREInstall_5, getId()), exception);
}
throw new IOException(MessageFormat.format(Messages.StandardSREInstall_5, getId()));
}
/** Path the given string for extracting a path.
*
* @param path the string representation of the path to parse.
* @param defaultPath the default path.
* @param rootPath the root path to use is the given path is not absolute.
* @return the absolute path.
*/
private static IPath parsePath(String path, IPath defaultPath, IPath rootPath) {
if (!Strings.isNullOrEmpty(path)) {
try {
final IPath pathObject = Path.fromPortableString(path);
if (pathObject != null) {
if (rootPath != null && !pathObject.isAbsolute()) {
return rootPath.append(pathObject);
}
return pathObject;
}
} catch (Throwable exception) {
//
}
}
return defaultPath;
}
private static String makeRelativePath(IPath pathToConvert, IPath jarPath, IPath rootPath) {
if (pathToConvert == null) {
return null;
}
if (!jarPath.equals(pathToConvert) && rootPath.isPrefixOf(pathToConvert)) {
return pathToConvert.makeRelativeTo(rootPath).toPortableString();
}
return pathToConvert.toPortableString();
}
@Override
public Map<String, String> getAvailableCommandLineOptions() {
if (isDirty()) {
setDirty(false);
resolveDirtyFields(true);
}
Map<String, String> options = (this.optionBuffer == null) ? null : this.optionBuffer.get();
if (options == null) {
options = Maps.newHashMap();
putIfNotempty(options, SREConstants.MANIFEST_CLI_SHOW_LOGO, this.cliLogoOn);
putIfNotempty(options, SREConstants.MANIFEST_CLI_HIDE_LOGO, this.cliLogoOff);
putIfNotempty(options, SREConstants.MANIFEST_CLI_SHOW_INFO, this.cliShowInfo);
putIfNotempty(options, SREConstants.MANIFEST_CLI_HIDE_INFO, this.cliHideInfo);
putIfNotempty(options, SREConstants.MANIFEST_CLI_DEFAULT_CONTEXT_ID, this.cliDefaultContextID);
putIfNotempty(options, SREConstants.MANIFEST_CLI_RANDOM_CONTEXT_ID, this.cliRandomContextID);
putIfNotempty(options, SREConstants.MANIFEST_CLI_BOOT_AGENT_CONTEXT_ID, this.cliBootAgentContextID);
putIfNotempty(options, SREConstants.MANIFEST_CLI_SRE_OFFLINE, this.cliSreOffline);
putIfNotempty(options, SREConstants.MANIFEST_CLI_NO_MORE_OPTION, this.cliNoMoreOption);
putIfNotempty(options, SREConstants.MANIFEST_CLI_EMBEDDED, this.cliEmbedded);
this.optionBuffer = new SoftReference<>(options);
}
return Collections.unmodifiableMap(options);
}
private static void putIfNotempty(Map<String, String> map, String key, String value) {
if (!Strings.isNullOrEmpty(value)) {
map.put(key, value);
}
}
}