|
Lines 28-33
Link Here
|
| 28 |
import org.eclipse.core.runtime.IStatus; |
28 |
import org.eclipse.core.runtime.IStatus; |
| 29 |
import org.eclipse.core.runtime.Path; |
29 |
import org.eclipse.core.runtime.Path; |
| 30 |
import org.eclipse.core.runtime.Status; |
30 |
import org.eclipse.core.runtime.Status; |
|
|
31 |
import org.eclipse.jdt.launching.AbstractVMInstallType; |
| 32 |
import org.eclipse.jdt.launching.IVMInstall; |
| 31 |
import org.eclipse.jdt.launching.LibraryLocation; |
33 |
import org.eclipse.jdt.launching.LibraryLocation; |
| 32 |
|
34 |
|
| 33 |
import com.ibm.icu.text.MessageFormat; |
35 |
import com.ibm.icu.text.MessageFormat; |
|
Lines 38-44
Link Here
|
| 38 |
* |
40 |
* |
| 39 |
* @since 3.4 |
41 |
* @since 3.4 |
| 40 |
*/ |
42 |
*/ |
| 41 |
public class EEVMType { |
43 |
public class EEVMType extends AbstractVMInstallType { |
|
|
44 |
|
| 45 |
/** |
| 46 |
* VM Type id |
| 47 |
*/ |
| 48 |
public static final String ID_EE_VM_TYPE = "org.eclipse.jdt.launching.EEVMType"; //$NON-NLS-1$ |
| 42 |
|
49 |
|
| 43 |
/** |
50 |
/** |
| 44 |
* Map of {EE File -> {Map of {PropertyName -> PropertyValue}} |
51 |
* Map of {EE File -> {Map of {PropertyName -> PropertyValue}} |
|
Lines 58-112
Link Here
|
| 58 |
public static final String PROP_CLASS_LIB_LEVEL = "-Dee.class.library.level"; //$NON-NLS-1$ |
65 |
public static final String PROP_CLASS_LIB_LEVEL = "-Dee.class.library.level"; //$NON-NLS-1$ |
| 59 |
public static final String PROP_EXECUTABLE = "-Dee.executable"; //$NON-NLS-1$ |
66 |
public static final String PROP_EXECUTABLE = "-Dee.executable"; //$NON-NLS-1$ |
| 60 |
public static final String PROP_EXECUTABLE_CONSOLE = "-Dee.executable.console"; //$NON-NLS-1$ |
67 |
public static final String PROP_EXECUTABLE_CONSOLE = "-Dee.executable.console"; //$NON-NLS-1$ |
|
|
68 |
public static final String PROP_JAVA_HOME = "-Djava.home"; //$NON-NLS-1$ |
| 61 |
|
69 |
|
| 62 |
private static final String[] REQUIRED_PROPERTIES = new String[]{PROP_EXECUTABLE, PROP_BOOT_CLASS_PATH, PROP_LANGUAGE_LEVEL}; |
70 |
private static final String[] REQUIRED_PROPERTIES = new String[]{PROP_EXECUTABLE, PROP_BOOT_CLASS_PATH, PROP_LANGUAGE_LEVEL, PROP_JAVA_HOME}; |
| 63 |
|
71 |
|
| 64 |
/** |
72 |
/** |
| 65 |
* Returns whether the given install location corresponds to an .ee file. |
73 |
* Returns the library locations defined in the given definition file. |
| 66 |
* |
74 |
* |
| 67 |
* @param installLocation |
75 |
* @param eeFile definition file |
| 68 |
* @return whether the given install location corresponds to an .ee file. |
76 |
* @return library locations defined in the file or an empty collection if none |
| 69 |
*/ |
77 |
*/ |
| 70 |
public static boolean isEEInstall(File installLocation) { |
78 |
public static LibraryLocation[] getLibraryLocations(File eeFile) { |
| 71 |
if (installLocation.isFile()) { |
|
|
| 72 |
String name = installLocation.getName(); |
| 73 |
if (name.endsWith(".ee")) { //$NON-NLS-1$ |
| 74 |
return true; |
| 75 |
} |
| 76 |
} |
| 77 |
return false; |
| 78 |
} |
| 79 |
|
| 80 |
/* (non-Javadoc) |
| 81 |
* @see org.eclipse.jdt.launching.IVMInstallType#getDefaultLibraryLocations(java.io.File) |
| 82 |
*/ |
| 83 |
public static LibraryLocation[] getDefaultLibraryLocations(File installLocation) { |
| 84 |
|
79 |
|
| 85 |
Map properties = getProperties(installLocation); |
80 |
Map properties = getProperties(eeFile); |
| 86 |
if (properties == null) { |
81 |
if (properties == null) { |
| 87 |
return new LibraryLocation[]{}; |
82 |
return new LibraryLocation[]{}; |
| 88 |
} |
83 |
} |
| 89 |
|
84 |
|
| 90 |
List allLibs = new ArrayList(); |
85 |
List allLibs = new ArrayList(); |
| 91 |
|
86 |
|
| 92 |
String dirs = getProperty(PROP_ENDORSED_DIRS, installLocation); |
87 |
String dirs = getProperty(PROP_ENDORSED_DIRS, eeFile); |
| 93 |
if (dirs != null) { |
88 |
if (dirs != null) { |
| 94 |
// Add all endorsed libraries - they are first, as they replace |
89 |
// Add all endorsed libraries - they are first, as they replace |
| 95 |
allLibs.addAll(StandardVMType.gatherAllLibraries(resolvePaths(dirs, installLocation))); |
90 |
allLibs.addAll(StandardVMType.gatherAllLibraries(resolvePaths(dirs, eeFile))); |
| 96 |
} |
91 |
} |
| 97 |
|
92 |
|
| 98 |
// next is the bootpath libraries |
93 |
// next is the bootpath libraries |
| 99 |
dirs = getProperty(PROP_BOOT_CLASS_PATH, installLocation); |
94 |
dirs = getProperty(PROP_BOOT_CLASS_PATH, eeFile); |
| 100 |
if (dirs != null) { |
95 |
if (dirs != null) { |
| 101 |
String[] bootpath = resolvePaths(dirs, installLocation); |
96 |
String[] bootpath = resolvePaths(dirs, eeFile); |
| 102 |
List boot = new ArrayList(bootpath.length); |
97 |
List boot = new ArrayList(bootpath.length); |
| 103 |
URL url = getDefaultJavadocLocation(installLocation); |
98 |
URL url = getJavadocLocation(eeFile); |
| 104 |
for (int i = 0; i < bootpath.length; i++) { |
99 |
for (int i = 0; i < bootpath.length; i++) { |
| 105 |
IPath path = new Path(bootpath[i]); |
100 |
IPath path = new Path(bootpath[i]); |
| 106 |
File lib = path.toFile(); |
101 |
File lib = path.toFile(); |
| 107 |
if (lib.exists() && lib.isFile()) { |
102 |
if (lib.exists() && lib.isFile()) { |
| 108 |
LibraryLocation libraryLocation = new LibraryLocation(path, |
103 |
LibraryLocation libraryLocation = new LibraryLocation(path, |
| 109 |
getDefaultSourceLocation(installLocation), |
104 |
getDefaultSourceLocation(eeFile), |
| 110 |
Path.EMPTY, |
105 |
Path.EMPTY, |
| 111 |
url); |
106 |
url); |
| 112 |
boot.add(libraryLocation); |
107 |
boot.add(libraryLocation); |
|
Lines 116-124
Link Here
|
| 116 |
} |
111 |
} |
| 117 |
|
112 |
|
| 118 |
// Add all extension libraries |
113 |
// Add all extension libraries |
| 119 |
dirs = getProperty(PROP_EXTENSION_DIRS, installLocation); |
114 |
dirs = getProperty(PROP_EXTENSION_DIRS, eeFile); |
| 120 |
if (dirs != null) { |
115 |
if (dirs != null) { |
| 121 |
allLibs.addAll(StandardVMType.gatherAllLibraries(resolvePaths(dirs, installLocation))); |
116 |
allLibs.addAll(StandardVMType.gatherAllLibraries(resolvePaths(dirs, eeFile))); |
| 122 |
} |
117 |
} |
| 123 |
|
118 |
|
| 124 |
|
119 |
|
|
Lines 135-158
Link Here
|
| 135 |
return (LibraryLocation[])allLibs.toArray(new LibraryLocation[allLibs.size()]); |
130 |
return (LibraryLocation[])allLibs.toArray(new LibraryLocation[allLibs.size()]); |
| 136 |
} |
131 |
} |
| 137 |
|
132 |
|
| 138 |
/* (non-Javadoc) |
133 |
|
| 139 |
* @see org.eclipse.jdt.launching.AbstractVMInstallType#getDefaultJavadocLocation(java.io.File) |
134 |
/** |
|
|
135 |
* Returns the javadoc location specified in the definition file or <code>null</code> |
| 136 |
* if none. |
| 137 |
* |
| 138 |
* @param eeFile definition file |
| 139 |
* @return javadoc location specified in the definition file or <code>null</code> if none |
| 140 |
*/ |
140 |
*/ |
| 141 |
public static URL getDefaultJavadocLocation(File installLocation) { |
141 |
public static URL getJavadocLocation(File eeFile) { |
| 142 |
String version = getProperty(PROP_LANGUAGE_LEVEL, installLocation); |
142 |
String version = getProperty(PROP_LANGUAGE_LEVEL, eeFile); |
| 143 |
if (version != null) { |
143 |
if (version != null) { |
| 144 |
return StandardVMType.getDefaultJavadocLocation(version); |
144 |
return StandardVMType.getDefaultJavadocLocation(version); |
| 145 |
} |
145 |
} |
| 146 |
return null; |
146 |
return null; |
| 147 |
} |
147 |
} |
| 148 |
|
148 |
|
| 149 |
/* (non-Javadoc) |
149 |
/** |
| 150 |
* @see org.eclipse.jdt.launching.AbstractVMInstallType#getDefaultVMArguments(java.io.File) |
150 |
* Returns VM arguments defined in the given definition file or <code>null</code> if none. |
|
|
151 |
* |
| 152 |
* @param eeFile definition file |
| 153 |
* @return VM arguments or <code>null</code> if none |
| 151 |
*/ |
154 |
*/ |
| 152 |
public static String getDefaultVMArguments(File installLocation) { |
155 |
public static String getVMArguments(File eeFile) { |
| 153 |
Map properties = getProperties(installLocation); |
156 |
Map properties = getProperties(eeFile); |
| 154 |
if (properties != null) { |
157 |
if (properties != null) { |
| 155 |
List args = (List) fgArguments.get(installLocation); |
158 |
List args = (List) fgArguments.get(eeFile); |
| 156 |
StringBuffer buf = new StringBuffer(); |
159 |
StringBuffer buf = new StringBuffer(); |
| 157 |
Iterator iterator = args.iterator(); |
160 |
Iterator iterator = args.iterator(); |
| 158 |
while (iterator.hasNext()) { |
161 |
while (iterator.hasNext()) { |
|
Lines 185-204
Link Here
|
| 185 |
return Path.EMPTY; |
188 |
return Path.EMPTY; |
| 186 |
} |
189 |
} |
| 187 |
|
190 |
|
| 188 |
/* (non-Javadoc) |
191 |
/** |
| 189 |
* @see org.eclipse.jdt.launching.IVMInstallType#validateInstallLocation(java.io.File) |
192 |
* Returns a status indicating if the given definition file is valid. |
|
|
193 |
* |
| 194 |
* @param eeFile definition file |
| 195 |
* @return status indicating if the given definition file is valid |
| 190 |
*/ |
196 |
*/ |
| 191 |
public static IStatus validateInstallLocation(File installLocation) { |
197 |
public static IStatus validateDefinitionFile(File eeFile) { |
| 192 |
Map properties = getProperties(installLocation); |
198 |
Map properties = getProperties(eeFile); |
| 193 |
if (properties == null) { |
199 |
if (properties == null) { |
| 194 |
return new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), MessageFormat.format(LaunchingMessages.EEVMType_0, new String[]{installLocation.getName()} )); |
200 |
return new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), MessageFormat.format(LaunchingMessages.EEVMType_0, new String[]{eeFile.getName()} )); |
| 195 |
} |
201 |
} |
| 196 |
// validate required properties |
202 |
// validate required properties |
| 197 |
for (int i = 0; i < REQUIRED_PROPERTIES.length; i++) { |
203 |
for (int i = 0; i < REQUIRED_PROPERTIES.length; i++) { |
| 198 |
String key = REQUIRED_PROPERTIES[i]; |
204 |
String key = REQUIRED_PROPERTIES[i]; |
| 199 |
String property = (String) properties.get(key); |
205 |
String property = (String) properties.get(key); |
| 200 |
if (property == null) { |
206 |
if (property == null) { |
| 201 |
return new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), MessageFormat.format(LaunchingMessages.EEVMType_1, new String[]{installLocation.getName(), key} )); |
207 |
return new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), MessageFormat.format(LaunchingMessages.EEVMType_1, new String[]{eeFile.getName(), key} )); |
| 202 |
} |
208 |
} |
| 203 |
} |
209 |
} |
| 204 |
return Status.OK_STATUS; |
210 |
return Status.OK_STATUS; |
|
Lines 209-215
Link Here
|
| 209 |
* is considered first. |
215 |
* is considered first. |
| 210 |
* |
216 |
* |
| 211 |
* @param installLocation ee file |
217 |
* @param installLocation ee file |
| 212 |
* @return standard executable |
218 |
* @return standard executable or <code>null</code> if none |
| 213 |
*/ |
219 |
*/ |
| 214 |
public static File getExecutable(File installLocation) { |
220 |
public static File getExecutable(File installLocation) { |
| 215 |
String property = getProperty(PROP_EXECUTABLE, installLocation); |
221 |
String property = getProperty(PROP_EXECUTABLE, installLocation); |
|
Lines 320-323
Link Here
|
| 320 |
} |
326 |
} |
| 321 |
return null; |
327 |
return null; |
| 322 |
} |
328 |
} |
|
|
329 |
|
| 330 |
/* (non-Javadoc) |
| 331 |
* @see org.eclipse.jdt.launching.AbstractVMInstallType#doCreateVMInstall(java.lang.String) |
| 332 |
*/ |
| 333 |
protected IVMInstall doCreateVMInstall(String id) { |
| 334 |
return new EEVMInstall(this, id); |
| 335 |
} |
| 336 |
|
| 337 |
/* (non-Javadoc) |
| 338 |
* @see org.eclipse.jdt.launching.IVMInstallType#detectInstallLocation() |
| 339 |
*/ |
| 340 |
public File detectInstallLocation() { |
| 341 |
return null; |
| 342 |
} |
| 343 |
|
| 344 |
/* (non-Javadoc) |
| 345 |
* @see org.eclipse.jdt.launching.IVMInstallType#getDefaultLibraryLocations(java.io.File) |
| 346 |
*/ |
| 347 |
public LibraryLocation[] getDefaultLibraryLocations(File installLocationOrDefinitionFile) { |
| 348 |
return new LibraryLocation[0]; |
| 349 |
} |
| 350 |
|
| 351 |
/* (non-Javadoc) |
| 352 |
* @see org.eclipse.jdt.launching.IVMInstallType#getName() |
| 353 |
*/ |
| 354 |
public String getName() { |
| 355 |
// TODO: |
| 356 |
return "Execution Environment Description"; |
| 357 |
} |
| 358 |
|
| 359 |
/* (non-Javadoc) |
| 360 |
* @see org.eclipse.jdt.launching.IVMInstallType#validateInstallLocation(java.io.File) |
| 361 |
*/ |
| 362 |
public IStatus validateInstallLocation(File installLocationOrDefinitionFile) { |
| 363 |
return new Status(IStatus.INFO, LaunchingPlugin.getUniqueIdentifier(), "Unable to validate install location."); |
| 364 |
} |
| 323 |
} |
365 |
} |