summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/node-impl
diff options
context:
space:
mode:
authoredwardsmj <edwardsmj@13f79535-47bb-0310-9956-ffa450edef68>2009-04-28 22:13:15 +0000
committeredwardsmj <edwardsmj@13f79535-47bb-0310-9956-ffa450edef68>2009-04-28 22:13:15 +0000
commit10bd5577378db1c24c03eac1484a58d95831812a (patch)
tree5a6bb3cab09869222b676b6380c3d8539290162a /java/sca/modules/node-impl
parent4aa4ae7815a12dcb6e7681d371d7ee0b140b52f9 (diff)
Fix to NodeImpl for TUSCANY-2989 - now resolves a supplied composite with an absolute URI outside any contribution against the first supplied contribution.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@769564 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/node-impl')
-rw-r--r--java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java48
1 files changed, 37 insertions, 11 deletions
diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
index f87e1f56e2..3a76f9e1ec 100644
--- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
+++ b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
@@ -48,6 +48,9 @@ import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.CompositeService;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint;
+// Added MJE 28/04/2009
+import org.apache.tuscany.sca.assembly.xml.CompositeDocumentProcessor;
+//
import org.apache.tuscany.sca.contribution.Artifact;
import org.apache.tuscany.sca.contribution.Contribution;
import org.apache.tuscany.sca.contribution.ContributionFactory;
@@ -140,6 +143,8 @@ public class NodeImpl implements Node, Client, SCAClient {
private WorkScheduler workScheduler;
private Contribution systemContribution;
private Definitions systemDefinitions;
+ // Added MJE 28/04/2009
+ private URLArtifactProcessor<Composite> compositeDocumentProcessor;
/**
* Constructs a new SCA node.
@@ -374,6 +379,10 @@ public class NodeImpl implements Node, Client, SCAClient {
// Create contribution content processor
URLArtifactProcessorExtensionPoint docProcessorExtensions = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
contributionProcessor = docProcessorExtensions.getProcessor(Contribution.class);
+
+ // Added MJE 28/04/2009
+ // Create Composite Document processor
+ compositeDocumentProcessor = docProcessorExtensions.getProcessor(Composite.class);
// Get the model resolvers
modelResolvers = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class);
@@ -546,6 +555,8 @@ public class NodeImpl implements Node, Client, SCAClient {
composite = configuration.getComposite();
+ // If a composite was not originally supplied when the Node was created, pick one of the deployable
+ // composites from the supplied contributions. Note: throws an exception if none can be found.
if (composite == null) {
setDefaultComposite(configuration, workspace);
}
@@ -557,11 +568,9 @@ public class NodeImpl implements Node, Client, SCAClient {
compositeFile.setURI(composite.getURI());
for (Contribution contribution: workspace.getContributions()) {
ModelResolver resolver = contribution.getModelResolver();
-// for (Artifact artifact : contribution.getArtifacts()){
-// logger.log(Level.INFO,"artifact - " + artifact.getURI());
-// }
+
Artifact resolvedArtifact = resolver.resolveModel(Artifact.class, compositeFile);
-// if (!resolvedArtifact.isUnresolved() && resolvedArtifact.getModel() instanceof Composite) {
+ if (!resolvedArtifact.isUnresolved() && resolvedArtifact.getModel() instanceof Composite) {
if (!composite.isUnresolved()) {
@@ -576,12 +585,29 @@ public class NodeImpl implements Node, Client, SCAClient {
composite = (Composite)resolvedArtifact.getModel();
}
found = true;
- // break;
- // }
- }
-// if (!found) {
-// throw new IllegalArgumentException("Composite not found: " + composite.getURI());
-// }
+ break;
+ } // end if
+ } // end for
+
+ if (!found) {
+ // If the composite was not found, then it must be a separate composite file outside any of the contributions
+ // - a "composite by value" - this requires its URI to be absolute and pointing at the composite file itself.
+ // First read in the composite file to create a composite model object...
+ URI compositeURI = new URI(composite.getURI());
+ URL compositeURL = compositeURI.toURL();
+ composite = compositeDocumentProcessor.read(compositeURL, compositeURI, compositeURL);
+ if( composite == null ) {
+ throw new IllegalArgumentException("Composite not found: " + compositeURI);
+ }
+
+ // Resolve the "composite by value" against the FIRST contribution
+ Contribution contribution = workspace.getContributions().get(0);
+ ModelResolver resolver = contribution.getModelResolver();
+ compositeProcessor.resolve(composite, resolver);
+ if( composite.isUnresolved() ) {
+ throw new IllegalArgumentException("Could not resolve composite: " + compositeURI + " in contribution " + contribution.getURI() );
+ }
+ } // end if
// Build the composite and wire the components included in it
compositeBuilder.build(composite, systemDefinitions, monitor);
@@ -760,7 +786,7 @@ public class NodeImpl implements Node, Client, SCAClient {
* Sets a default composite by using any deployable one.
*/
private void setDefaultComposite(ConfiguredNodeImplementation configuration, Workspace workspace) {
- // just use the first deployable composte
+ // just use the first deployable composite
for (Contribution contribution : workspace.getContributions()) {
for (Composite c : contribution.getDeployables()) {
composite = assemblyFactory.createComposite();