You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2008/07/14 19:13:27 UTC
svn commit: r676650 - in /tuscany/java/sca:
modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/
modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/
samples/calculator-distributed...
Author: jsdelfino
Date: Mon Jul 14 10:13:26 2008
New Revision: 676650
URL: http://svn.apache.org/viewvc?rev=676650&view=rev
Log:
Fix for TUSCANY-2409. Mirrored changes to SCANodeFactory in NodeLauncher.
Added:
tuscany/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/Contribution.java
Modified:
tuscany/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationLauncherBootstrap.java
tuscany/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncher.java
tuscany/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncherUtil.java
tuscany/java/sca/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeA.java
tuscany/java/sca/samples/domain-management/src/main/java/manager/DistributeAndRunComponents.java
tuscany/java/sca/tutorial/store-client/launch/LaunchStoreClientNode.java
Modified: tuscany/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationLauncherBootstrap.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationLauncherBootstrap.java?rev=676650&r1=676649&r2=676650&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationLauncherBootstrap.java (original)
+++ tuscany/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationLauncherBootstrap.java Mon Jul 14 10:13:26 2008
@@ -97,6 +97,17 @@
/**
* Bootstrap a new SCA node.
*
+ * @param configurationURI
+ * @param contributionClassLoader
+ */
+ public NodeImplementationLauncherBootstrap(String compositeURI, ClassLoader contributionClassLoader) throws Exception {
+ SCANode2Factory nodeFactory = SCANode2Factory.newInstance();
+ node = new NodeFacade(nodeFactory.createSCANodeFromClassLoader(compositeURI, contributionClassLoader));
+ }
+
+ /**
+ * Bootstrap a new SCA node.
+ *
* @param compositeURI
* @param uris
* @param locations
Added: tuscany/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/Contribution.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/Contribution.java?rev=676650&view=auto
==============================================================================
--- tuscany/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/Contribution.java (added)
+++ tuscany/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/Contribution.java Mon Jul 14 10:13:26 2008
@@ -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
Modified: tuscany/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncher.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncher.java?rev=676650&r1=676649&r2=676650&view=diff
==============================================================================
--- tuscany/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncher.java (original)
+++ tuscany/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncher.java Mon Jul 14 10:13:26 2008
@@ -50,66 +50,62 @@
}
/**
- * 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 @@
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 {
Modified: tuscany/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncherUtil.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncherUtil.java?rev=676650&r1=676649&r2=676650&view=diff
==============================================================================
--- tuscany/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncherUtil.java (original)
+++ tuscany/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncherUtil.java Mon Jul 14 10:13:26 2008
@@ -312,7 +312,7 @@
* @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 @@
// 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 @@
locations[i] = contributions[i].getLocation();
}
bootstrap = constructor.newInstance(compositeURI, compositeContent, uris, locations);
+
} else {
// Construct the node with a composite URI and the URIs and
Modified: tuscany/java/sca/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeA.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeA.java?rev=676650&r1=676649&r2=676650&view=diff
==============================================================================
--- tuscany/java/sca/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeA.java (original)
+++ tuscany/java/sca/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeA.java Mon Jul 14 10:13:26 2008
@@ -33,7 +33,7 @@
try {
NodeLauncher nodeLauncher = NodeLauncher.newInstance();
- node = nodeLauncher.createNode("http://localhost:9990/node-config/NodeA");
+ node = nodeLauncher.createNodeFromURL("http://localhost:9990/node-config/NodeA");
node.start();
Modified: tuscany/java/sca/samples/domain-management/src/main/java/manager/DistributeAndRunComponents.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/samples/domain-management/src/main/java/manager/DistributeAndRunComponents.java?rev=676650&r1=676649&r2=676650&view=diff
==============================================================================
--- tuscany/java/sca/samples/domain-management/src/main/java/manager/DistributeAndRunComponents.java (original)
+++ tuscany/java/sca/samples/domain-management/src/main/java/manager/DistributeAndRunComponents.java Mon Jul 14 10:13:26 2008
@@ -281,10 +281,10 @@
// Create the SCA node, give it the composite and the list of contributions
// to use
List<Contribution> dependencies = nodeDependencies.get(node);
- org.apache.tuscany.sca.node.launcher.NodeLauncher.Contribution[] contributions = new org.apache.tuscany.sca.node.launcher.NodeLauncher.Contribution[dependencies.size()];
+ org.apache.tuscany.sca.node.launcher.Contribution[] contributions = new org.apache.tuscany.sca.node.launcher.Contribution[dependencies.size()];
for (int c =0, n = dependencies.size(); c < n; c++) {
Contribution dependency = dependencies.get(c);
- contributions[c] = new org.apache.tuscany.sca.node.launcher.NodeLauncher.Contribution(dependency.getURI(), dependency.getLocation());
+ contributions[c] = new org.apache.tuscany.sca.node.launcher.Contribution(dependency.getURI(), dependency.getLocation());
}
SCANode2 runtimeNode = launcher.createNode("http://sample/" + node.getName(), print(runnable), contributions);
Modified: tuscany/java/sca/tutorial/store-client/launch/LaunchStoreClientNode.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/tutorial/store-client/launch/LaunchStoreClientNode.java?rev=676650&r1=676649&r2=676650&view=diff
==============================================================================
--- tuscany/java/sca/tutorial/store-client/launch/LaunchStoreClientNode.java (original)
+++ tuscany/java/sca/tutorial/store-client/launch/LaunchStoreClientNode.java Mon Jul 14 10:13:26 2008
@@ -29,7 +29,7 @@
public static void main(String[] args) throws Exception {
NodeLauncher nodeLauncher = NodeLauncher.newInstance();
- SCANode2 storeClientNode = nodeLauncher.createNode("http://localhost:9990/node-config/StoreClientNode");
+ SCANode2 storeClientNode = nodeLauncher.createNodeFromURL("http://localhost:9990/node-config/StoreClientNode");
storeClientNode.start();
SCAClient client = (SCAClient)storeClientNode;