Author: jsdelfino
Date: Sun Sep 7 04:44:28 2008
New Revision: 692822
URL: http://svn.apache.org/viewvc?rev=692822&view=rev
Log:
Fixed determination of the location of the node launcher bundle.
Modified:
tuscany/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java
tuscany/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java
Modified:
tuscany/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java?rev=692822&r1=692821&r2=692822&view=diff
==============================================================================
---
tuscany/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java
(original)
+++
tuscany/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java
Sun Sep 7 04:44:28 2008
@@ -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 @@
// 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();
Modified:
tuscany/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java?rev=692822&r1=692821&r2=692822&view=diff
==============================================================================
---
tuscany/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java
(original)
+++
tuscany/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java
Sun Sep 7 04:44:28 2008
@@ -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 @@
}
}
+ /**
+ * 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());