summaryrefslogtreecommitdiffstats
path: root/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node
diff options
context:
space:
mode:
Diffstat (limited to 'branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node')
-rw-r--r--branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/ContributionLocationHelper.java66
-rw-r--r--branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java6
-rw-r--r--branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java24
-rw-r--r--branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java7
4 files changed, 72 insertions, 31 deletions
diff --git a/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/ContributionLocationHelper.java b/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/ContributionLocationHelper.java
new file mode 100644
index 0000000000..fd7aaed4c8
--- /dev/null
+++ b/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/ContributionLocationHelper.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.node.equinox.launcher;
+
+import java.io.File;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.osgi.framework.Bundle;
+
+/**
+ * ContributionLocationHelper
+ *
+ * @version $Rev: $ $Date: $
+ */
+public class ContributionLocationHelper {
+
+ /**
+ * Returns the location of the SCA contribution containing the given class.
+ *
+ * @param anchorClass
+ * @return
+ */
+ public static String getContributionLocation(final Class<?> anchorClass) {
+ URL url = AccessController.doPrivileged(new PrivilegedAction<URL>() {
+ public URL run() {
+ return anchorClass.getProtectionDomain().getCodeSource().getLocation();
+ }
+ });
+ String uri = url.toString();
+ return uri;
+ }
+
+ /**
+ * Returns the location of the SCA contribution represented by the given bundle.
+ *
+ * @param anchorClass
+ * @return
+ */
+ public static String getContributionLocation(final Bundle bundle) {
+ String uri = bundle.getLocation();
+ uri = uri.substring(uri.indexOf("file:") + 5);
+ File file = new File(uri);
+ uri = file.toURI().toString();
+ return uri;
+ }
+
+}
diff --git a/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java b/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java
index 2307e94907..d3c5ee2a9d 100644
--- a/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java
+++ b/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java
@@ -48,7 +48,7 @@ import org.osgi.framework.BundleContext;
/**
* Wraps the Equinox runtime.
*/
-public class EquinoxHost {
+class EquinoxHost {
private static Logger logger = Logger.getLogger(EquinoxHost.class.getName());
private BundleContext bundleContext;
@@ -118,7 +118,7 @@ public class EquinoxHost {
*
* @return
*/
- public BundleContext start() {
+ BundleContext start() {
try {
if (!EclipseStarter.isRunning()) {
@@ -292,7 +292,7 @@ public class EquinoxHost {
/**
* Stop the Equinox host.
*/
- public void stop() {
+ void stop() {
try {
// Uninstall all the bundles we've installed
diff --git a/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java b/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java
index 790b1ab48c..614c34b01e 100644
--- a/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java
+++ b/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java
@@ -65,7 +65,7 @@ public class NodeLauncher {
* @throws LauncherException
*/
public <T> T createNodeFromURL(String configurationURL) throws LauncherException {
- return (T)node(configurationURL, null, null, null, null, bundleContext);
+ return (T)node(configurationURL, null, null, null, bundleContext);
}
/**
@@ -80,7 +80,7 @@ public class NodeLauncher {
* @throws LauncherException
*/
public <T> T createNode(String compositeURI, Contribution... contributions) throws LauncherException {
- return (T)node(null, compositeURI, null, contributions, null, bundleContext);
+ return (T)node(null, compositeURI, null, contributions, bundleContext);
}
/**
@@ -94,25 +94,7 @@ public class NodeLauncher {
*/
public <T> T createNode(String compositeURI, String compositeContent, Contribution... contributions)
throws LauncherException {
- return (T)node(null, compositeURI, compositeContent, contributions, null, bundleContext);
- }
-
- /**
- * Create a SCA node based on the discovery of the contribution on the classpath for the
- * given classloader. This method should be treated a convenient shortcut with the following
- * assumptions:
- * <ul>
- * <li>This is a standalone application and there is a deployable composite file on the classpath.
- * <li>There is only one contribution which contains the deployable composite file physically in its packaging hierarchy.
- * </ul>
- *
- * @param compositeURI The URI of the composite file relative to the root of the enclosing contribution
- * @param classLoader The ClassLoader used to load the composite file as a resource. If the value is null,
- * then thread context classloader will be used
- * @return A newly created SCA node
- */
- public <T> T createNodeFromClassLoader(String compositeURI, ClassLoader classLoader) throws LauncherException {
- return (T)node(null, compositeURI, null, null, classLoader, bundleContext);
+ return (T)node(null, compositeURI, compositeContent, contributions, bundleContext);
}
public static void main(String[] args) throws Exception {
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 c2544a1872..c6379886cc 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
@@ -103,7 +103,6 @@ final class NodeLauncherUtil {
String compositeURI,
String compositeContent,
Contribution[] contributions,
- ClassLoader contributionClassLoader,
BundleContext bundleContext) throws LauncherException {
try {
@@ -129,12 +128,6 @@ final class NodeLauncherUtil {
// Construct the node with a configuration URI
bootstrap = bootstrapClass.getConstructor(String.class).newInstance(configurationURI);
- } else if (contributionClassLoader != null) {
-
- // Construct the node with a compositeURI and a classloader
- Constructor<?> constructor = bootstrapClass.getConstructor(String.class, ClassLoader.class);
- bootstrap = constructor.newInstance(compositeURI, contributionClassLoader);
-
} else if (compositeContent != null) {
// Construct the node with a composite URI, the composite content and