summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/node2-launcher/src/main
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2008-07-14 17:13:26 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2008-07-14 17:13:26 +0000
commit2e47a0cdf5eec96d282d31319c404bfc6fb0bc92 (patch)
treea6805856ad5129335fc7fcf29166dbc8658fe8c4 /java/sca/modules/node2-launcher/src/main
parent9e569d19c4305f332d4f4b11413c052dbc9f05b6 (diff)
Fix for TUSCANY-2409. Mirrored changes to SCANodeFactory in NodeLauncher.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@676650 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/node2-launcher/src/main')
-rw-r--r--java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/Contribution.java48
-rw-r--r--java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncher.java82
-rw-r--r--java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncherUtil.java13
3 files changed, 97 insertions, 46 deletions
diff --git a/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/Contribution.java b/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/Contribution.java
new file mode 100644
index 0000000000..4f4f861e2f
--- /dev/null
+++ b/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/Contribution.java
@@ -0,0 +1,48 @@
+/*
+ * 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.launcher;
+
+/**
+ * Represents an SCA contribution uri + location.
+ *
+ * @version $Rev$ $Date$
+ */
+public final class Contribution {
+ private String uri;
+ private String location;
+
+ /**
+ * Constructs a new SCA contribution.
+ *
+ * @param uri
+ * @param location
+ */
+ public Contribution(String uri, String location) {
+ this.uri = uri;
+ this.location = location;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+} \ No newline at end of file
diff --git a/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncher.java b/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncher.java
index 1ba784420f..60c50c6919 100644
--- a/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncher.java
+++ b/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncher.java
@@ -50,66 +50,62 @@ public class NodeLauncher {
}
/**
- * Creates a new node.
+ * Creates a new SCA node from the configuration URL
*
- * @param configurationURI
- * @return a new node
+ * @param configurationURL the URL of the node configuration which is the ATOM feed
+ * that contains the URI of the composite and a collection of URLs for the contributions
+ *
+ * @return a new SCA node.
* @throws LauncherException
*/
- public <T> T createNode(String configurationURI) throws LauncherException {
- return (T)node(configurationURI, null, null, null);
+ public <T> T createNodeFromURL(String configurationURL) throws LauncherException {
+ return (T)node(configurationURL, null, null, null, null);
}
/**
- * Represents an SCA contribution uri + location.
+ * Creates a new SCA Node.
+ *
+ * @param compositeURI the URI of the composite to use
+ * @param contributions the URI of the contributions that provides the composites and related
+ * artifacts. If the list is empty, then we will use the thread context classloader to discover
+ * the contribution on the classpath
+ *
+ * @return a new SCA node.
+ * @throws LauncherException
*/
- public static final class Contribution {
- private String uri;
- private String location;
-
- /**
- * Constructs a new SCA contribution.
- *
- * @param uri
- * @param location
- */
- public Contribution(String uri, String location) {
- this.uri = uri;
- this.location = location;
- }
-
- public String getURI() {
- return uri;
- }
-
- public String getLocation() {
- return location;
- }
+ public <T> T createNode(String compositeURI, Contribution...contributions) throws LauncherException {
+ return (T)node(null, compositeURI, null, contributions, null);
}
/**
- * Creates a new Node.
+ * Creates a new SCA Node.
*
- * @param compositeURI
- * @param contributions
- * @return a new node
+ * @param compositeURI the URI of the composite to use
+ * @param compositeContent the XML content of the composite to use
+ * @param contributions the URI of the contributions that provides the composites and related artifacts
+ * @return a new SCA node.
* @throws LauncherException
*/
- public <T> T createNode(String compositeURI, Contribution...contributions) throws LauncherException {
- return (T)node(null, compositeURI, null, contributions);
+ public <T> T createNode(String compositeURI, String compositeContent, Contribution...contributions) throws LauncherException {
+ return (T)node(null, compositeURI, compositeContent, contributions, null);
}
/**
- * Creates a new Node.
+ * 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
- * @param compositeContent
- * @param contributions
- * @return a new node
- * @throws LauncherException
+ * @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 createNode(String compositeURI, String compositeContent, Contribution...contributions) throws LauncherException {
- return (T)node(null, compositeURI, compositeContent, contributions);
+ public <T> T createSCANodeFromClassLoader(String compositeURI, ClassLoader classLoader) throws LauncherException {
+ return (T)node(null, compositeURI, null, null, classLoader);
}
public static void main(String[] args) throws Exception {
@@ -119,7 +115,7 @@ public class NodeLauncher {
NodeLauncher launcher = newInstance();
String configurationURI = args[0];
logger.info("SCA Node configuration: " + configurationURI);
- Object node = launcher.createNode(configurationURI);
+ Object node = launcher.createNodeFromURL(configurationURI);
// Start the node
try {
diff --git a/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncherUtil.java b/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncherUtil.java
index 2a208d4c07..5580d14e74 100644
--- a/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncherUtil.java
+++ b/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncherUtil.java
@@ -312,7 +312,7 @@ final class NodeLauncherUtil {
* @param contributions
* @throws LauncherException
*/
- static Object node(String configurationURI, String compositeURI, String compositeContent, NodeLauncher.Contribution[] contributions) throws LauncherException {
+ static Object node(String configurationURI, String compositeURI, String compositeContent, Contribution[] contributions, ClassLoader contributionClassLoader) throws LauncherException {
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
try {
@@ -339,10 +339,16 @@ 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 and the URIs and
- // locations of a list of contributions
+ // Construct the node with a composite URI, the composite content and
+ // the URIs and locations of a list of contributions
Constructor<?> constructor = bootstrapClass.getConstructor(String.class, String.class, String[].class, String[].class);
String[] uris = new String[contributions.length];
String[] locations = new String[contributions.length];
@@ -351,6 +357,7 @@ final class NodeLauncherUtil {
locations[i] = contributions[i].getLocation();
}
bootstrap = constructor.newInstance(compositeURI, compositeContent, uris, locations);
+
} else {
// Construct the node with a composite URI and the URIs and