use of org.eclipse.osgi.service.datalocation.Location in project rt.equinox.framework by eclipse.
the class EclipseStarter method getInitialBundles.
private static InitialBundle[] getInitialBundles(String[] installEntries) {
searchCandidates.clear();
List<InitialBundle> result = new ArrayList<>(installEntries.length);
int defaultStartLevel = Integer.parseInt(getProperty(PROP_BUNDLES_STARTLEVEL, DEFAULT_BUNDLES_STARTLEVEL));
String syspath = getSysPath();
// should canonicalize the syspath.
try {
syspath = new File(syspath).getCanonicalPath();
} catch (IOException ioe) {
// do nothing
}
Collection<ServiceReference<Location>> installLocRef;
try {
installLocRef = context.getServiceReferences(Location.class, Location.INSTALL_FILTER);
} catch (InvalidSyntaxException e) {
throw new RuntimeException(e);
}
Location installLocation = installLocRef == null ? null : context.getService(installLocRef.iterator().next());
if (installLocation == null) {
throw new IllegalStateException(Msg.EclipseStarter_InstallLocation);
}
for (int i = 0; i < installEntries.length; i++) {
String name = installEntries[i];
int level = defaultStartLevel;
boolean start = false;
int index = name.lastIndexOf('@');
if (index >= 0) {
// $NON-NLS-1$
String[] attributes = getArrayFromList(name.substring(index + 1, name.length()), ":");
for (int j = 0; j < attributes.length; j++) {
String attribute = attributes[j];
if (// $NON-NLS-1$
attribute.equals("start"))
start = true;
else {
try {
level = Integer.parseInt(attribute);
} catch (NumberFormatException e) {
// bug 188089
index = name.length();
continue;
}
}
}
name = name.substring(0, index);
}
try {
URL location = searchForBundle(name, syspath);
if (location == null) {
FrameworkLogEntry entry = new FrameworkLogEntry(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, 0, NLS.bind(Msg.ECLIPSE_STARTUP_BUNDLE_NOT_FOUND, installEntries[i]), 0, null, null);
log.log(entry);
// skip this entry
continue;
}
location = makeRelative(installLocation.getURL(), location);
String locationString = INITIAL_LOCATION + location.toExternalForm();
result.add(new InitialBundle(locationString, location, level, start));
} catch (IOException e) {
log.log(new FrameworkLogEntry(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, 0, e.getMessage(), 0, e, null));
}
}
return result.toArray(new InitialBundle[result.size()]);
}
use of org.eclipse.osgi.service.datalocation.Location in project rt.equinox.framework by eclipse.
the class SystemBundleActivator method registerLocations.
private void registerLocations(BundleContext bc, EquinoxLocations equinoxLocations) {
Dictionary<String, Object> locationProperties = new Hashtable<>(1);
Location location = equinoxLocations.getUserLocation();
if (location != null) {
// $NON-NLS-1$
locationProperties.put("type", EquinoxLocations.PROP_USER_AREA);
register(bc, Location.class, location, locationProperties);
}
location = equinoxLocations.getInstanceLocation();
if (location != null) {
// $NON-NLS-1$
locationProperties.put("type", EquinoxLocations.PROP_INSTANCE_AREA);
register(bc, Location.class, location, locationProperties);
}
location = equinoxLocations.getConfigurationLocation();
if (location != null) {
// $NON-NLS-1$
locationProperties.put("type", EquinoxLocations.PROP_CONFIG_AREA);
register(bc, Location.class, location, locationProperties);
}
location = equinoxLocations.getInstallLocation();
if (location != null) {
// $NON-NLS-1$
locationProperties.put("type", EquinoxLocations.PROP_INSTALL_AREA);
register(bc, Location.class, location, locationProperties);
}
location = equinoxLocations.getEclipseHomeLocation();
if (location != null) {
// $NON-NLS-1$
locationProperties.put("type", EquinoxLocations.PROP_HOME_LOCATION_AREA);
register(bc, Location.class, location, locationProperties);
}
}
Aggregations