You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2008/09/09 03:29:56 UTC
svn commit: r693336 - in
/tuscany/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher:
NodeLauncher.java NodeLauncherUtil.java
Author: rfeng
Date: Mon Sep 8 18:29:55 2008
New Revision: 693336
URL: http://svn.apache.org/viewvc?rev=693336&view=rev
Log:
Use the bundle to load the implementation.node classes
Modified:
tuscany/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.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/NodeLauncher.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java?rev=693336&r1=693335&r2=693336&view=diff
==============================================================================
--- tuscany/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java (original)
+++ tuscany/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java Mon Sep 8 18:29:55 2008
@@ -65,7 +65,7 @@
* @throws LauncherException
*/
public <T> T createNodeFromURL(String configurationURL) throws LauncherException {
- return (T)node(configurationURL, null, null, null, null);
+ return (T)node(configurationURL, null, null, null, null, bundleContext);
}
/**
@@ -80,7 +80,7 @@
* @throws LauncherException
*/
public <T> T createNode(String compositeURI, Contribution... contributions) throws LauncherException {
- return (T)node(null, compositeURI, null, contributions, null);
+ return (T)node(null, compositeURI, null, contributions, null, bundleContext);
}
/**
@@ -94,7 +94,7 @@
*/
public <T> T createNode(String compositeURI, String compositeContent, Contribution... contributions)
throws LauncherException {
- return (T)node(null, compositeURI, compositeContent, contributions, null);
+ return (T)node(null, compositeURI, compositeContent, contributions, null, bundleContext);
}
/**
@@ -112,7 +112,7 @@
* @return A newly created SCA node
*/
public <T> T createNodeFromClassLoader(String compositeURI, ClassLoader classLoader) throws LauncherException {
- return (T)node(null, compositeURI, null, null, classLoader);
+ return (T)node(null, compositeURI, null, null, classLoader, bundleContext);
}
public static void main(String[] args) throws Exception {
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=693336&r1=693335&r2=693336&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 Mon Sep 8 18:29:55 2008
@@ -47,6 +47,7 @@
import java.util.zip.ZipInputStream;
import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
/**
* Common functions and constants used by the admin components.
@@ -55,6 +56,8 @@
*/
final class NodeLauncherUtil {
+ private static final String LAUNCHER_EQUINOX_LIBRARIES = "org.apache.tuscany.sca.node.launcher.equinox.libraries";
+
private static final String SCANODE_FACTORY = "org.apache.tuscany.sca.node.SCANodeFactory";
private static final String DOMAIN_MANAGER_LAUNCHER_BOOTSTRAP =
@@ -69,18 +72,29 @@
/**
* Collect JAR files under the given directory.
* @param contributions
- *
+ * @param bundleContext TODO
* @throws LauncherException
*/
static Object node(String configurationURI,
String compositeURI,
String compositeContent,
Contribution[] contributions,
- ClassLoader contributionClassLoader) throws LauncherException {
+ ClassLoader contributionClassLoader, BundleContext bundleContext) throws LauncherException {
try {
+ Bundle bundle = null;
+ for (Bundle b : bundleContext.getBundles()) {
+ if ("org.apache.tuscany.sca.implementation.node.runtime".equals(b.getSymbolicName())) {
+ bundle = b;
+ break;
+ }
+ }
+ if (bundle == null) {
+ throw new IllegalStateException(
+ "Bundle org.apache.tuscany.sca.implementation.node.runtime is not installed");
+ }
// Use Java reflection to create the node as only the runtime class
// loader knows the runtime classes required by the node
- Class<?> bootstrapClass = Class.forName(NODE_IMPLEMENTATION_LAUNCHER_BOOTSTRAP);
+ Class<?> bootstrapClass = bundle.loadClass(NODE_IMPLEMENTATION_LAUNCHER_BOOTSTRAP);
Object bootstrap;
if (configurationURI != null) {
@@ -256,7 +270,7 @@
for (String jarFile : jarFiles) {
addPackages(jarFile, packages);
classpath.append("\"external:");
- classpath.append(file(new URL(jarFile)).getAbsolutePath().replace(File.separatorChar, '/'));
+ classpath.append(file(new URL(jarFile)).getPath().replace(File.separatorChar, '/'));
classpath.append("\",");
}
@@ -282,7 +296,7 @@
Attributes attributes = manifest.getMainAttributes();
attributes.putValue("Manifest-Version", "1.0");
attributes.putValue(BUNDLE_MANIFESTVERSION, "2");
- attributes.putValue(BUNDLE_SYMBOLICNAME, "org.apache.tuscany.sca.node.launcher.equinox.libraries");
+ attributes.putValue(BUNDLE_SYMBOLICNAME, LAUNCHER_EQUINOX_LIBRARIES);
attributes.putValue(EXPORT_PACKAGE, exports.substring(0, exports.length() - 1));
attributes.putValue(IMPORT_PACKAGE, imports.substring(0, imports.length() - 1));
attributes.putValue(BUNDLE_CLASSPATH, classpath.substring(0, classpath.length() - 1));