Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDJ Houghton2011-01-12 19:47:18 +0000
committerDJ Houghton2011-01-12 19:47:18 +0000
commit09fc5dd7221bd1f1b0dfd11535fa06cf5a04e042 (patch)
treee6af4a3fd1fa2899022124e68f20cc16b85a319f /bundles/org.eclipse.equinox.p2.reconciler.dropins
parente8946c843ad5b8a335a1e5e5a25eb4b1a0170fea (diff)
downloadrt.equinox.p2-09fc5dd7221bd1f1b0dfd11535fa06cf5a04e042.tar.gz
rt.equinox.p2-09fc5dd7221bd1f1b0dfd11535fa06cf5a04e042.tar.xz
rt.equinox.p2-09fc5dd7221bd1f1b0dfd11535fa06cf5a04e042.zip
Bug 332971 - [reconciler] Provide mechanism for specifying multiple non-default drop-ins folders
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.reconciler.dropins')
-rw-r--r--bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/Activator.java33
-rw-r--r--bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/DropinsRepositoryListener.java3
2 files changed, 33 insertions, 3 deletions
diff --git a/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/Activator.java b/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/Activator.java
index 6d5a536bf..d8da4f56a 100644
--- a/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/Activator.java
+++ b/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/Activator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2007, 2011 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
@@ -596,6 +596,32 @@ public class Activator implements BundleActivator {
}
/*
+ * Perform variable substitution on the given string. Replace vars in the form %foo%
+ * with the equivalent property set in the System properties.
+ */
+ public static String substituteVariables(String path) {
+ if (path == null)
+ return path;
+ int beginIndex = path.indexOf('%');
+ // no variable
+ if (beginIndex == -1)
+ return path;
+ beginIndex++;
+ int endIndex = path.indexOf('%', beginIndex);
+ // no matching end % to indicate variable
+ if (endIndex == -1)
+ return path;
+ // get the variable name and do a lookup
+ String var = path.substring(beginIndex, endIndex);
+ if (var.length() == 0 || var.indexOf(File.pathSeparatorChar) != -1)
+ return path;
+ var = getContext().getProperty(var);
+ if (var == null)
+ return path;
+ return path.substring(0, beginIndex - 1) + var + path.substring(endIndex + 1);
+ }
+
+ /*
* Helper method to return the eclipse.home location. Return
* null if it is unavailable.
*/
@@ -640,8 +666,11 @@ public class Activator implements BundleActivator {
List<File> dropinsDirectories = new ArrayList<File>();
// did the user specify one via System properties?
String watchedDirectoryProperty = bundleContext.getProperty(DROPINS_DIRECTORY);
- if (watchedDirectoryProperty != null)
+ if (watchedDirectoryProperty != null) {
+ // perform a variable substitution if necessary
+ watchedDirectoryProperty = substituteVariables(watchedDirectoryProperty);
dropinsDirectories.add(new File(watchedDirectoryProperty));
+ }
// always add the one in the Eclipse home directory
File root = getEclipseHome();
diff --git a/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/DropinsRepositoryListener.java b/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/DropinsRepositoryListener.java
index d2cbd5622..96a6f86dd 100644
--- a/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/DropinsRepositoryListener.java
+++ b/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/DropinsRepositoryListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 IBM Corporation and others.
+ * Copyright (c) 2008, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -153,6 +153,7 @@ public class DropinsRepositoryListener extends RepositoryListener {
} else {
path = path.trim();
}
+ path = Activator.substituteVariables(path);
File linkedFile = new File(path);
if (!linkedFile.isAbsolute()) {
// link support is relative to the install root

Back to the top