summaryrefslogtreecommitdiffstats
path: root/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2008-09-28 19:06:08 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2008-09-28 19:06:08 +0000
commit0376e0e4f9d31c3e08159f56a8a9d54b4dc47783 (patch)
tree8676c4444709d5ca7afad059702170aa3cc49875 /branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany
parentdb72136306cdedbee6b1cfb03a299fab8157ff8e (diff)
Adjusted algorithm to determine classpath entries.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@699881 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany')
-rw-r--r--branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java13
-rw-r--r--branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java110
2 files changed, 72 insertions, 51 deletions
diff --git a/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java b/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java
index e95263d2f2..96cde75779 100644
--- a/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java
+++ b/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java
@@ -158,7 +158,18 @@ class EquinoxHost {
}
// Determine the runtime classpath entries
- Set<URL> urls = runtimeClasspathEntries();
+ Set<URL> urls;
+ if (!startedEclipse) {
+
+ // Use classpath entries from a distribution if there is one and the modules
+ // directories available in a dev environment for example
+ urls = runtimeClasspathEntries(true, false, true);
+ } else {
+
+ // Use classpath entries from a distribution if there is one and the classpath
+ // entries on the current application's classloader
+ urls = runtimeClasspathEntries(true, true, false);
+ }
// Sort out which are bundles (and not already installed) and which are just
// regular JARs
diff --git a/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java b/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java
index c6379886cc..64d53e2e49 100644
--- a/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java
+++ b/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java
@@ -610,10 +610,13 @@ final class NodeLauncherUtil {
/**
* Determine the Tuscany runtime classpath entries.
- *
+ *
+ * @param useDistribution
+ * @param useAppClasspath
+ * @param useModulesDirectory
* @return
*/
- static Set<URL> runtimeClasspathEntries() throws FileNotFoundException,
+ static Set<URL> runtimeClasspathEntries(boolean useDistribution, boolean useAppClasspath, boolean useModulesDirectory) throws FileNotFoundException,
URISyntaxException, MalformedURLException {
// Build list of runtime JARs
@@ -627,37 +630,41 @@ final class NodeLauncherUtil {
// that JAR (e.g. the Tuscany modules directory) as well as the ../modules and
// ../lib directories
if (uri.getPath().endsWith(".jar")) {
-
- File file = new File(uri);
- if (file.exists()) {
- File jarDirectory = file.getParentFile();
- if (jarDirectory != null && jarDirectory.exists()) {
-
- // Collect JAR files from the directory containing the input JAR
- // (e.g. the Tuscany modules directory)
- URL jarDirectoryURL = jarDirectory.toURI().toURL();
- jarDirectoryURLs.add(jarDirectoryURL);
- collectClasspathEntries(jarDirectory, jarURLs, new StandAloneJARFileNameFilter());
-
- File homeDirectory = jarDirectory.getParentFile();
- if (homeDirectory != null && homeDirectory.exists()) {
- collectDistributionClasspathEntries(homeDirectory.getAbsolutePath(), jarDirectoryURLs, jarURLs, new StandAloneJARFileNameFilter());
+ if (useDistribution) {
+
+ File file = new File(uri);
+ if (file.exists()) {
+ File jarDirectory = file.getParentFile();
+ if (jarDirectory != null && jarDirectory.exists()) {
+
+ // Collect JAR files from the directory containing the input JAR
+ // (e.g. the Tuscany modules directory)
+ URL jarDirectoryURL = jarDirectory.toURI().toURL();
+ jarDirectoryURLs.add(jarDirectoryURL);
+ collectClasspathEntries(jarDirectory, jarURLs, new StandAloneJARFileNameFilter());
+
+ File homeDirectory = jarDirectory.getParentFile();
+ if (homeDirectory != null && homeDirectory.exists()) {
+ collectDistributionClasspathEntries(homeDirectory.getAbsolutePath(), jarDirectoryURLs, jarURLs, new StandAloneJARFileNameFilter());
+ }
}
}
}
} else if (uri.getPath().endsWith("/target/classes/")) {
-
+
// Development mode, we're running off classes in a workspace
// and not from Maven surefire, collect all bundles in the workspace
- ClassLoader cl = NodeLauncherUtil.class.getClassLoader();
- if (!cl.getClass().getName().startsWith("org.apache.maven.surefire")) {
- File file = new File(uri);
- if (file.exists()) {
- File moduleDirectory = file.getParentFile().getParentFile();
- if (moduleDirectory != null) {
- File modulesDirectory = moduleDirectory.getParentFile();
- if (modulesDirectory != null && modulesDirectory.exists() && modulesDirectory.getName().equals("modules")) {
- collectDevelopmentClasspathEntries(modulesDirectory.getAbsolutePath(), jarDirectoryURLs, jarURLs, new StandAloneDevelopmentClassesFileNameFilter());
+ if (useModulesDirectory) {
+ ClassLoader cl = NodeLauncherUtil.class.getClassLoader();
+ if (!cl.getClass().getName().startsWith("org.apache.maven.surefire")) {
+ File file = new File(uri);
+ if (file.exists()) {
+ File moduleDirectory = file.getParentFile().getParentFile();
+ if (moduleDirectory != null) {
+ File modulesDirectory = moduleDirectory.getParentFile();
+ if (modulesDirectory != null && modulesDirectory.exists() && modulesDirectory.getName().equals("modules")) {
+ collectDevelopmentClasspathEntries(modulesDirectory.getAbsolutePath(), jarDirectoryURLs, jarURLs, new StandAloneDevelopmentClassesFileNameFilter());
+ }
}
}
}
@@ -667,26 +674,30 @@ final class NodeLauncherUtil {
// Look for a TUSCANY_HOME system property or environment variable
// Add all the JARs found under $TUSCANY_HOME, $TUSCANY_HOME/modules
// and $TUSCANY_HOME/lib
- String home = getProperty(TUSCANY_HOME);
- if (home != null && home.length() != 0) {
- logger.info(TUSCANY_HOME + ": " + home);
- collectDistributionClasspathEntries(home, jarDirectoryURLs, jarURLs, new StandAloneJARFileNameFilter());
- }
-
- // Look for a TUSCANY_PATH system property or environment variable
- // Add all the JARs found under $TUSCANY_PATH, $TUSCANY_PATH/modules
- // and $TUSCANY_PATH/lib
- String ext = getProperty(TUSCANY_PATH);
- if (ext != null && ext.length() != 0) {
- logger.info(TUSCANY_PATH + ": " + ext);
- String separator = getProperty("path.separator");
- for (StringTokenizer tokens = new StringTokenizer(ext, separator); tokens.hasMoreTokens();) {
- collectDistributionClasspathEntries(tokens.nextToken(), jarDirectoryURLs, jarURLs, new StandAloneJARFileNameFilter());
+ if (useDistribution) {
+ String home = getProperty(TUSCANY_HOME);
+ if (home != null && home.length() != 0) {
+ logger.info(TUSCANY_HOME + ": " + home);
+ collectDistributionClasspathEntries(home, jarDirectoryURLs, jarURLs, new StandAloneJARFileNameFilter());
+ }
+
+ // Look for a TUSCANY_PATH system property or environment variable
+ // Add all the JARs found under $TUSCANY_PATH, $TUSCANY_PATH/modules
+ // and $TUSCANY_PATH/lib
+ String ext = getProperty(TUSCANY_PATH);
+ if (ext != null && ext.length() != 0) {
+ logger.info(TUSCANY_PATH + ": " + ext);
+ String separator = getProperty("path.separator");
+ for (StringTokenizer tokens = new StringTokenizer(ext, separator); tokens.hasMoreTokens();) {
+ collectDistributionClasspathEntries(tokens.nextToken(), jarDirectoryURLs, jarURLs, new StandAloneJARFileNameFilter());
+ }
}
}
// Add the classpath entries from the current classloader
- collectClassLoaderClasspathEntries(jarURLs, NodeLauncherUtil.class.getClassLoader(), false);
+ if (useAppClasspath) {
+ collectClassLoaderClasspathEntries(jarURLs, NodeLauncherUtil.class.getClassLoader());
+ }
return jarURLs;
@@ -700,7 +711,7 @@ final class NodeLauncherUtil {
*/
static List<URL> jarFilesOnClasspath(ClassLoader classLoader) {
Set<URL> entries = new HashSet<URL>();
- collectClassLoaderClasspathEntries(entries, classLoader, false);
+ collectClassLoaderClasspathEntries(entries, classLoader);
return new ArrayList<URL>(entries);
}
@@ -723,7 +734,7 @@ final class NodeLauncherUtil {
* @param urls
* @param cl
*/
- private static void collectClassLoaderClasspathEntries(Set<URL> urls, ClassLoader cl, boolean recursive) {
+ private static void collectClassLoaderClasspathEntries(Set<URL> urls, ClassLoader cl) {
if (cl == null) {
return;
}
@@ -735,13 +746,12 @@ final class NodeLauncherUtil {
for (URL jarURL : jarURLs) {
urls.add(jarURL);
}
+ int count = jarURLs.length;
+ if (count != 0) {
+ logger.info("Runtime classpath: " + count + " JAR" + (count > 1? "s":"")+ " from application classpath.");
+ }
}
}
-
- // Collect JARs from the parent ClassLoader
- if (recursive) {
- collectClassLoaderClasspathEntries(urls, cl.getParent(), recursive);
- }
}
/**