diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2008-09-07 11:44:28 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2008-09-07 11:44:28 +0000 |
commit | 7881c624c1531d9c60830f9a1556c4deeecb1688 (patch) | |
tree | 2213e6b333a9796d9222598f317f938e1199e532 /java/sca/modules | |
parent | 749d5c9a1c6a58fb7ff9078d97afb96039f89b7a (diff) |
Fixed determination of the location of the node launcher bundle.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@692822 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules')
2 files changed, 35 insertions, 11 deletions
diff --git a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java index b60032b5b9..a61449be21 100644 --- a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java +++ b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java @@ -19,6 +19,7 @@ package org.apache.tuscany.sca.node.equinox.launcher; +import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.bundleLocation; import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.string; import static org.osgi.framework.Constants.BUNDLE_SYMBOLICNAME; @@ -142,8 +143,10 @@ public class EquinoxHost { // Start Eclipse context = EclipseStarter.startup(new String[]{}, null); - // FIXME use the correct bundle location - Bundle launcherBundle = context.installBundle(new File("target/classes").toURI().toURL().toString()); + // Install the launcher bundle + String bundleLocation = bundleLocation(); + logger.info("Installing launcher bundle: " + bundleLocation); + Bundle launcherBundle = context.installBundle(bundleLocation); logger.info("Starting bundle: " + string(launcherBundle, false)); launcherBundle.start(); diff --git a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java index 1ffb987b80..f4c4f1369c 100644 --- a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java +++ b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java @@ -19,23 +19,17 @@ package org.apache.tuscany.sca.node.equinox.launcher; -import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.file; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.IOException; -import java.io.InputStream; import java.lang.reflect.Constructor; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; -import java.util.ArrayList; import java.util.HashSet; -import java.util.List; import java.util.Set; import java.util.jar.Attributes; -import java.util.jar.JarInputStream; -import java.util.jar.JarOutputStream; import java.util.jar.Manifest; import java.util.logging.Level; import java.util.regex.Matcher; @@ -277,6 +271,33 @@ final class NodeLauncherUtil { } } + /** + * Returns the location of this bundle. + * + * @return + * @throws IOException + */ + static String bundleLocation() throws IOException, URISyntaxException { + String resource = NodeLauncherUtil.class.getName().replace('.', '/') + ".class"; + URL url = NodeLauncherUtil.class.getClassLoader().getResource(resource); + if (url == null) { + throw new FileNotFoundException(resource); + } + URI uri = url.toURI(); + + String scheme = uri.getScheme(); + if (scheme.equals("jar")) { + String path = uri.toString().substring(4); + int i = path.indexOf("!/"); + path = path.substring(0, i); + return path; + } else { + String path = uri.toString(); + path = path.substring(0, path.length() - resource.length()); + return path; + } + } + static String string(Bundle b, boolean verbose) { StringBuffer sb = new StringBuffer(); sb.append(b.getBundleId()).append(" ").append(b.getSymbolicName()); |