diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules/contribution/src/main/java')
2 files changed, 52 insertions, 11 deletions
diff --git a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ProcessorContext.java b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ProcessorContext.java index 75cfab4924..d464af40f2 100644 --- a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ProcessorContext.java +++ b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ProcessorContext.java @@ -19,6 +19,7 @@ package org.apache.tuscany.sca.contribution.processor; +import org.apache.tuscany.sca.contribution.Artifact; import org.apache.tuscany.sca.contribution.Contribution; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.UtilityExtensionPoint; @@ -32,6 +33,7 @@ import org.apache.tuscany.sca.monitor.MonitorFactory; */ public class ProcessorContext { protected Contribution contribution; + protected Artifact artifact; protected Monitor monitor; protected Object parentModel; @@ -62,10 +64,19 @@ public class ProcessorContext { this.monitor = new DefaultMonitorFactory().createMonitor(); } + /** + * Get the current contribution + * @return The current contribution + */ public Contribution getContribution() { return contribution; } + /** + * Set the current contribution + * @param contribution + * @return + */ public Contribution setContribution(Contribution contribution) { Contribution old = this.contribution; this.contribution = contribution; @@ -92,4 +103,25 @@ public class ProcessorContext { return old; } + /** + * Get the current artifact + * @return The current artifact + */ + public Artifact getArtifact() { + return artifact; + } + + /** + * Set the current artifact. This should be called by URLArtifactProcessor to set the document + * context (such as the URI of the composite file). + * + * @param artifact The new artifact + * @return The old artifact + */ + public Artifact setArtifact(Artifact artifact) { + Artifact old = this.artifact; + this.artifact = artifact; + return old; + } + } diff --git a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/impl/ContributionContentProcessor.java b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/impl/ContributionContentProcessor.java index 232bf9c72f..40a92d74f3 100644 --- a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/impl/ContributionContentProcessor.java +++ b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/impl/ContributionContentProcessor.java @@ -139,7 +139,7 @@ public class ContributionContentProcessor implements ExtendedURLArtifactProcesso monitor.pushContext("Artifact: " + artifact.getURI()); - old = context.setContribution(contribution); + Artifact oldArtifact = context.setArtifact(artifact); try { // Read each artifact URL artifactLocationURL = null; @@ -169,7 +169,7 @@ public class ContributionContentProcessor implements ExtendedURLArtifactProcesso } } finally { monitor.popContext(); - context.setContribution(old); + context.setArtifact(oldArtifact); } } @@ -252,23 +252,32 @@ public class ContributionContentProcessor implements ExtendedURLArtifactProcesso for (Artifact artifact : contribution.getArtifacts()) { Object model = artifact.getModel(); if (model != null) { + Artifact oldArtifact = context.setArtifact(artifact); try { artifactProcessor.resolve(model, contributionResolver, context); } catch (Throwable e) { throw new ContributionResolveException(e); + } finally { + context.setArtifact(oldArtifact); } } } - // Resolve deployable composites - List<Composite> deployables = contribution.getDeployables(); - for (int i = 0, n = deployables.size(); i < n; i++) { - Composite deployable = deployables.get(i); - Composite resolved = (Composite)contributionResolver.resolveModel(Composite.class, deployable, context); - if (resolved != deployable) { - deployables.set(i, resolved); - } - } // end for + // Resolve deployable composites + List<Composite> deployables = contribution.getDeployables(); + Artifact oldArtifact = context.setArtifact(contribution); + try { + for (int i = 0, n = deployables.size(); i < n; i++) { + Composite deployable = deployables.get(i); + Composite resolved = + (Composite)contributionResolver.resolveModel(Composite.class, deployable, context); + if (resolved != deployable) { + deployables.set(i, resolved); + } + } // end for + } finally { + context.setArtifact(oldArtifact); + } } finally { monitor.popContext(); context.setContribution(old); |