diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2008-09-19 05:31:14 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2008-09-19 05:31:14 +0000 |
commit | 6a633dee838417ed68cf91fbd2e9b3b9fa07bd8f (patch) | |
tree | 658d78b2087d2f851518be4d27ed9d913ac47ebb /branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java | |
parent | bd126f649a92dd53cd3b3ccef5029ab273436291 (diff) |
Simplified ServiceDiscoverer. Started to use it to create factories to resolve ClassNotFoundExceptions. Renamed calculator-osgi to calculator-equinox and a few fixes to get it working in Eclipse.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@696924 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java')
-rw-r--r-- | branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java | 28 |
1 files changed, 28 insertions, 0 deletions
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 bf65c3f323..0bbf09d101 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 @@ -31,8 +31,10 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.OutputStream; import java.lang.reflect.Constructor; import java.net.URI; import java.net.URISyntaxException; @@ -50,6 +52,7 @@ import java.util.zip.ZipInputStream; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; +import org.osgi.framework.BundleException; /** * Common functions and constants used by the admin components. @@ -344,6 +347,31 @@ final class NodeLauncherUtil { return path; } } + + static Bundle installBundle(BundleContext bundleContext, String location) throws BundleException, IOException { + // Development mode, copy the MANIFEST.MF file to the bundle location + if (location.endsWith("/target/classes/")) { + File target = file(new URL(location)); + File targetManifest = new File(target, "META-INF/MANIFEST.MF"); + File sourceManifest = new File(target.getParentFile().getParentFile(), "META-INF/MANIFEST.MF"); + targetManifest.getParentFile().mkdirs(); + OutputStream os = new FileOutputStream(targetManifest); + InputStream is = new FileInputStream(sourceManifest); + byte[] buf = new byte[2048]; + for (;;) { + int l = is.read(buf); + if (l == -1) { + break; + } + os.write(buf, 0, l); + } + is.close(); + os.close(); + } + + Bundle bundle = bundleContext.installBundle(location); + return bundle; + } static String string(Bundle b, boolean verbose) { StringBuffer sb = new StringBuffer(); |