installLocation = buildLocation(PROP_INSTALL_AREA, null, "", true, false, null); //$NON-NLS-1$ Location temp = buildLocation(PROP_USER_AREA_DEFAULT, null, "", false, false, null); //$NON-NLS-1$ URL defaultLocation = temp == null ? null : temp.getURL(); if (defaultLocation == null) defaultLocation = buildURL(new File(System.getProperty(PROP_USER_HOME), "user").getAbsolutePath(), true); //$NON-NLS-1$ userLocation = buildLocation(PROP_USER_AREA, defaultLocation, "", false, false, null); //$NON-NLS-1$ temp = buildLocation(PROP_INSTANCE_AREA_DEFAULT, null, "", false, false, INSTANCE_DATA_AREA_PREFIX); //$NON-NLS-1$ defaultLocation = temp == null ? null : temp.getURL(); if (defaultLocation == null) defaultLocation = buildURL(new File(System.getProperty(PROP_USER_DIR), "workspace").getAbsolutePath(), true); //$NON-NLS-1$ instanceLocation = buildLocation(PROP_INSTANCE_AREA, defaultLocation, "", false, false, INSTANCE_DATA_AREA_PREFIX); //$NON-NLS-1$ mungeConfigurationLocation(); temp = buildLocation(PROP_CONFIG_AREA_DEFAULT, null, "", false, false, null); //$NON-NLS-1$ defaultLocation = temp == null ? null : temp.getURL(); if (defaultLocation == null && equinoxConfig.getConfiguration(PROP_CONFIG_AREA) == null) defaultLocation = buildURL(computeDefaultConfigurationLocation(), true); configurationLocation = buildLocation(PROP_CONFIG_AREA, defaultLocation, "", false, false, null); //$NON-NLS-1$ URL parentLocation = computeSharedConfigurationLocation(); if (parentLocation != null && !parentLocation.equals(configurationLocation.getURL())) { Location parent = new BasicLocation(null, parentLocation, true, null, equinoxConfig); String eclipseHomeLocationPath = getEclipseHomeLocation(eclipseLauncher, equinoxConfig); if (eclipseHomeLocationPath != null)
return new BasicLocation(property, defaultLocation, userReadOnlySetting != null || !computeReadOnly ? readOnly : !canWrite(defaultLocation), dataAreaPrefix, equinoxConfig, container, debugLocations); String trimmedLocation = location.trim(); if (trimmedLocation.equalsIgnoreCase(NONE)) return new BasicLocation(property, null, readOnly, dataAreaPrefix, equinoxConfig, container, debugLocations); if (trimmedLocation.startsWith(USER_HOME)) { String base = substituteVar(location, USER_HOME, PROP_USER_HOME); location = new File(base, userDefaultAppendage).getAbsolutePath(); } else if (trimmedLocation.startsWith(USER_DIR)) { String base = substituteVar(location, USER_DIR, PROP_USER_DIR); location = new File(base, userDefaultAppendage).getAbsolutePath(); throw new RuntimeException("The location cannot start with '" + INSTALL_HASH_PLACEHOLDER + "': " + location); //$NON-NLS-1$ //$NON-NLS-2$ } else if (idx > 0) { location = location.substring(0, idx) + getInstallDirHash() + location.substring(idx + INSTALL_HASH_PLACEHOLDER.length()); URL url = buildURL(location, true); BasicLocation result = null; if (url != null) { result = new BasicLocation(property, null, userReadOnlySetting != null || !computeReadOnly ? readOnly : !canWrite(url), dataAreaPrefix, equinoxConfig, container, debugLocations); result.setURL(url, false);
private String computeDefaultConfigurationLocation() { // 1) We store the config state relative to the 'eclipse' directory if possible // 2) If this directory is read-only // we store the state in <user.home>/.eclipse/<application-id>_<version> where <user.home> // is unique for each local user, and <application-id> is the one // defined in .eclipseproduct marker file. If .eclipseproduct does not // exist, use "eclipse" as the application-id. URL installURL = computeInstallConfigurationLocation(); if (installURL != null && "file".equals(installURL.getProtocol())) { //$NON-NLS-1$ File installDir = new File(installURL.getFile()); File defaultConfigDir = new File(installDir, CONFIG_DIR); if (!defaultConfigDir.exists()) defaultConfigDir.mkdirs(); if (defaultConfigDir.exists() && StorageUtil.canWrite(defaultConfigDir)) return defaultConfigDir.getAbsolutePath(); } // We can't write in the eclipse install dir so try for some place in the user's home dir return computeDefaultUserAreaLocation(CONFIG_DIR); }
private void registerLocations(BundleContext bc, EquinoxLocations equinoxLocations) { Dictionary<String, Object> locationProperties = new Hashtable<>(1); Location location = equinoxLocations.getUserLocation(); if (location != null) { locationProperties.put("type", EquinoxLocations.PROP_USER_AREA); //$NON-NLS-1$ register(bc, Location.class, location, locationProperties); } location = equinoxLocations.getInstanceLocation(); if (location != null) { locationProperties.put("type", EquinoxLocations.PROP_INSTANCE_AREA); //$NON-NLS-1$ register(bc, Location.class, location, locationProperties); } location = equinoxLocations.getConfigurationLocation(); if (location != null) { locationProperties.put("type", EquinoxLocations.PROP_CONFIG_AREA); //$NON-NLS-1$ register(bc, Location.class, location, locationProperties); } location = equinoxLocations.getInstallLocation(); if (location != null) { locationProperties.put("type", EquinoxLocations.PROP_INSTALL_AREA); //$NON-NLS-1$ register(bc, Location.class, location, locationProperties); } location = equinoxLocations.getEclipseHomeLocation(); if (location != null) { locationProperties.put("type", EquinoxLocations.PROP_HOME_LOCATION_AREA); //$NON-NLS-1$ register(bc, Location.class, location, locationProperties); } }
URL installURL = buildURL(installProperty, true); if (installURL == null) return null; File installDir = new File(installURL.getPath()); String installDirHash = getInstallDirHash();
Location installLoc = container.getLocations().getInstallLocation(); URL installURL = installLoc.getURL(); Location configLocation = container.getLocations().getConfigurationLocation(); Location parentConfigLocation = configLocation.getParentLocation(); Location osgiParentLocation = null;
private URL getConfigIni(EquinoxLocations locations, boolean parent) { if (Boolean.TRUE.toString().equals(getConfiguration(EquinoxConfiguration.PROP_IGNORE_USER_CONFIGURATION))) return null; Location configArea = locations.getConfigurationLocation(); if (configArea != null && parent) { configArea = configArea.getParentLocation(); } if (configArea == null) { return null; } try { return new URL(configArea.getURL().toExternalForm() + CONFIG_FILE); } catch (MalformedURLException e) { // its ok. This should never happen } return null; }
public EquinoxContainer(Map<String, ?> configuration) { this.equinoxConfig = new EquinoxConfiguration(configuration, new HookRegistry(this)); this.equinoxLocations = new EquinoxLocations(this.equinoxConfig); loadConfig(equinoxConfig, equinoxLocations); this.logServices = new EquinoxLogServices(this.equinoxConfig, this.equinoxLocations.getConfigurationLocation()); this.equinoxConfig.getHookRegistry().initialize(); try {
/** * Return hash code identifying an absolute installation path * @return hash code as String */ private String getInstallDirHash() { // compute an install dir hash to prevent configuration area collisions with other eclipse installs String installProperty = equinoxConfig.getConfiguration(PROP_INSTALL_AREA); URL installURL = buildURL(installProperty, true); if (installURL == null) return ""; //$NON-NLS-1$ File installDir = new File(installURL.getFile()); int hashCode; try { hashCode = installDir.getCanonicalPath().hashCode(); } catch (IOException ioe) { // fall back to absolute path hashCode = installDir.getAbsolutePath().hashCode(); } if (hashCode < 0) hashCode = -(hashCode); String installDirHash = String.valueOf(hashCode); return installDirHash; }
this.equinoxLocations = new EquinoxLocations(this.configValues, this.hookRegistry.getContainer(), debugLocations); this.configValues.loadConfigIni(getConfigIni(equinoxLocations, false)); this.configValues.loadConfigIni(getConfigIni(equinoxLocations, true));
private void registerLocations(BundleContext bc, EquinoxLocations equinoxLocations) { Dictionary<String, Object> locationProperties = new Hashtable<String, Object>(1); Location location = equinoxLocations.getUserLocation(); if (location != null) { locationProperties.put("type", EquinoxLocations.PROP_USER_AREA); //$NON-NLS-1$ register(bc, Location.class, location, locationProperties); } location = equinoxLocations.getInstanceLocation(); if (location != null) { locationProperties.put("type", EquinoxLocations.PROP_INSTANCE_AREA); //$NON-NLS-1$ register(bc, Location.class, location, locationProperties); } location = equinoxLocations.getConfigurationLocation(); if (location != null) { locationProperties.put("type", EquinoxLocations.PROP_CONFIG_AREA); //$NON-NLS-1$ register(bc, Location.class, location, locationProperties); } location = equinoxLocations.getInstallLocation(); if (location != null) { locationProperties.put("type", EquinoxLocations.PROP_INSTALL_AREA); //$NON-NLS-1$ register(bc, Location.class, location, locationProperties); } location = equinoxLocations.getEclipseHomeLocation(); if (location != null) { locationProperties.put("type", EquinoxLocations.PROP_HOME_LOCATION_AREA); //$NON-NLS-1$ register(bc, Location.class, location, locationProperties); } }
URL installURL = buildURL(installProperty, true); if (installURL == null) return null; File installDir = new File(installURL.getFile()); String installDirHash = getInstallDirHash();
Location installLoc = container.getLocations().getInstallLocation(); URL installURL = installLoc.getURL(); Location configLocation = container.getLocations().getConfigurationLocation(); Location parentConfigLocation = configLocation.getParentLocation(); Location osgiParentLocation = null;
private URL getConfigIni(EquinoxLocations locations, boolean parent) { if (Boolean.TRUE.toString().equals(getConfiguration(EquinoxConfiguration.PROP_IGNORE_USER_CONFIGURATION))) return null; Location configArea = locations.getConfigurationLocation(); if (configArea != null && parent) { configArea = configArea.getParentLocation(); } if (configArea == null) { return null; } try { return new URL(configArea.getURL().toExternalForm() + CONFIG_FILE); } catch (MalformedURLException e) { // its ok. This should never happen } return null; }
public EquinoxContainer(Map<String, ?> configuration) { this.equinoxConfig = new EquinoxConfiguration(configuration, new HookRegistry(this)); this.equinoxLocations = new EquinoxLocations(this.equinoxConfig); loadConfig(equinoxConfig, equinoxLocations); this.logServices = new EquinoxLogServices(this.equinoxConfig, this.equinoxLocations.getConfigurationLocation()); this.equinoxConfig.getHookRegistry().initialize(); try {
/** * Return hash code identifying an absolute installation path * @return hash code as String */ private String getInstallDirHash() { // compute an install dir hash to prevent configuration area collisions with other eclipse installs String installProperty = equinoxConfig.getConfiguration(PROP_INSTALL_AREA); URL installURL = buildURL(installProperty, true); if (installURL == null) return ""; //$NON-NLS-1$ File installDir = new File(installURL.getFile()); int hashCode; try { hashCode = installDir.getCanonicalPath().hashCode(); } catch (IOException ioe) { // fall back to absolute path hashCode = installDir.getAbsolutePath().hashCode(); } if (hashCode < 0) hashCode = -(hashCode); String installDirHash = String.valueOf(hashCode); return installDirHash; }
this.equinoxLocations = new EquinoxLocations(this.configValues, this.hookRegistry.getContainer(), debugLocations); this.configValues.loadConfigIni(getConfigIni(equinoxLocations, false)); this.configValues.loadConfigIni(getConfigIni(equinoxLocations, true));
installLocation = buildLocation(PROP_INSTALL_AREA, null, "", true, false, null); //$NON-NLS-1$ Location temp = buildLocation(PROP_USER_AREA_DEFAULT, null, "", false, false, null); //$NON-NLS-1$ URL defaultLocation = temp == null ? null : temp.getURL(); if (defaultLocation == null) defaultLocation = buildURL(new File(System.getProperty(PROP_USER_HOME), "user").getAbsolutePath(), true); //$NON-NLS-1$ userLocation = buildLocation(PROP_USER_AREA, defaultLocation, "", false, false, null); //$NON-NLS-1$ temp = buildLocation(PROP_INSTANCE_AREA_DEFAULT, null, "", false, false, INSTANCE_DATA_AREA_PREFIX); //$NON-NLS-1$ defaultLocation = temp == null ? null : temp.getURL(); if (defaultLocation == null) defaultLocation = buildURL(new File(System.getProperty(PROP_USER_DIR), "workspace").getAbsolutePath(), true); //$NON-NLS-1$ instanceLocation = buildLocation(PROP_INSTANCE_AREA, defaultLocation, "", false, false, INSTANCE_DATA_AREA_PREFIX); //$NON-NLS-1$ mungeConfigurationLocation(); temp = buildLocation(PROP_CONFIG_AREA_DEFAULT, null, "", false, false, null); //$NON-NLS-1$ defaultLocation = temp == null ? null : temp.getURL(); if (defaultLocation == null && equinoxConfig.getConfiguration(PROP_CONFIG_AREA) == null) defaultLocation = buildURL(computeDefaultConfigurationLocation(), true); configurationLocation = buildLocation(PROP_CONFIG_AREA, defaultLocation, "", false, false, null); //$NON-NLS-1$ URL parentLocation = computeSharedConfigurationLocation(); if (parentLocation != null && !parentLocation.equals(configurationLocation.getURL())) { Location parent = new BasicLocation(null, parentLocation, true, null, equinoxConfig, container, debugLocations); String eclipseHomeLocationPath = getEclipseHomeLocation(eclipseLauncher, equinoxConfig); if (eclipseHomeLocationPath != null)
private void registerLocations(BundleContext bc, EquinoxLocations equinoxLocations) { Dictionary<String, Object> locationProperties = new Hashtable<String, Object>(1); Location location = equinoxLocations.getUserLocation(); if (location != null) { locationProperties.put("type", EquinoxLocations.PROP_USER_AREA); //$NON-NLS-1$ register(bc, Location.class, location, locationProperties); } location = equinoxLocations.getInstanceLocation(); if (location != null) { locationProperties.put("type", EquinoxLocations.PROP_INSTANCE_AREA); //$NON-NLS-1$ register(bc, Location.class, location, locationProperties); } location = equinoxLocations.getConfigurationLocation(); if (location != null) { locationProperties.put("type", EquinoxLocations.PROP_CONFIG_AREA); //$NON-NLS-1$ register(bc, Location.class, location, locationProperties); } location = equinoxLocations.getInstallLocation(); if (location != null) { locationProperties.put("type", EquinoxLocations.PROP_INSTALL_AREA); //$NON-NLS-1$ register(bc, Location.class, location, locationProperties); } location = equinoxLocations.getEclipseHomeLocation(); if (location != null) { locationProperties.put("type", EquinoxLocations.PROP_HOME_LOCATION_AREA); //$NON-NLS-1$ register(bc, Location.class, location, locationProperties); } }
return new BasicLocation(property, defaultLocation, userReadOnlySetting != null || !computeReadOnly ? readOnly : !canWrite(defaultLocation), dataAreaPrefix, equinoxConfig, container, debugLocations); String trimmedLocation = location.trim(); if (trimmedLocation.equalsIgnoreCase(NONE)) return new BasicLocation(property, null, readOnly, dataAreaPrefix, equinoxConfig, container, debugLocations); if (trimmedLocation.startsWith(USER_HOME)) { String base = substituteVar(location, USER_HOME, PROP_USER_HOME); location = new File(base, userDefaultAppendage).getAbsolutePath(); } else if (trimmedLocation.startsWith(USER_DIR)) { String base = substituteVar(location, USER_DIR, PROP_USER_DIR); location = new File(base, userDefaultAppendage).getAbsolutePath(); throw new RuntimeException("The location cannot start with '" + INSTALL_HASH_PLACEHOLDER + "': " + location); //$NON-NLS-1$ //$NON-NLS-2$ } else if (idx > 0) { location = location.substring(0, idx) + getInstallDirHash() + location.substring(idx + INSTALL_HASH_PLACEHOLDER.length()); URL url = buildURL(location, true); BasicLocation result = null; if (url != null) { result = new BasicLocation(property, null, userReadOnlySetting != null || !computeReadOnly ? readOnly : !canWrite(url), dataAreaPrefix, equinoxConfig, container, debugLocations); result.setURL(url, false);