summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/node-launcher-equinox/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/sca/modules/node-launcher-equinox/src')
-rw-r--r--java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java7
-rw-r--r--java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java39
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());