diff options
Diffstat (limited to 'branches/sca-java-1.x/modules/workspace-impl/src/main/java')
-rw-r--r-- | branches/sca-java-1.x/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/branches/sca-java-1.x/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java b/branches/sca-java-1.x/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java index f81b386420..4aa619aa3f 100644 --- a/branches/sca-java-1.x/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java +++ b/branches/sca-java-1.x/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java @@ -50,9 +50,13 @@ import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint; import org.apache.tuscany.sca.contribution.scanner.ContributionScanner; import org.apache.tuscany.sca.contribution.service.ContributionReadException; import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.definitions.SCADefinitions; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; +import org.apache.tuscany.sca.policy.Intent; +import org.apache.tuscany.sca.policy.IntentAttachPointType; +import org.apache.tuscany.sca.policy.PolicySet; import org.apache.tuscany.sca.workspace.scanner.impl.DirectoryContributionScanner; import org.apache.tuscany.sca.workspace.scanner.impl.JarContributionScanner; @@ -71,6 +75,8 @@ public class ContributionContentProcessor implements URLArtifactProcessor<Contri private StAXArtifactProcessor<Object> extensionProcessor; private UtilityExtensionPoint utilities; private Monitor monitor = null; + private ModelResolver policyDefinitionsResolver = null; + private List<SCADefinitions> policyDefinitions = null; public ContributionContentProcessor(ExtensionPointRegistry extensionPoints, Monitor monitor) { this.extensionPoints = extensionPoints; @@ -89,6 +95,13 @@ public class ContributionContentProcessor implements URLArtifactProcessor<Contri this.contributionFactory = modelFactories.getFactory(ContributionFactory.class); } + public ContributionContentProcessor(ExtensionPointRegistry extensionPoints, Monitor monitor, + ModelResolver policyDefinitionsResolver, List<SCADefinitions> policyDefinitions) { + this(extensionPoints, monitor); + this.policyDefinitionsResolver = policyDefinitionsResolver; + this.policyDefinitions = policyDefinitions; + } + /* public ContributionContentProcessor(ModelFactoryExtensionPoint modelFactories, ModelResolverExtensionPoint modelResolvers, URLArtifactProcessor<Object> artifactProcessor, StAXArtifactProcessor<Object> extensionProcessor, Monitor monitor) { @@ -116,7 +129,12 @@ public class ContributionContentProcessor implements URLArtifactProcessor<Contri Contribution contribution = contributionFactory.createContribution(); contribution.setURI(contributionURI.toString()); contribution.setLocation(contributionURL.toString()); - ModelResolver modelResolver = new ExtensibleModelResolver(contribution, extensionPoints); + ModelResolver modelResolver; + if (policyDefinitionsResolver != null) { + modelResolver = new ExtensibleModelResolver(contribution, extensionPoints, modelResolvers, modelFactories, policyDefinitionsResolver); + } else { + modelResolver = new ExtensibleModelResolver(contribution, extensionPoints); + } contribution.setModelResolver(modelResolver); contribution.setUnresolved(true); @@ -150,6 +168,11 @@ public class ContributionContentProcessor implements URLArtifactProcessor<Contri // Add the loaded model to the model resolver modelResolver.addModel(model); + // Add policy definitions to the list of policy definitions + if (policyDefinitionsResolver != null) { + addPolicyDefinitions(model); + } + // Merge contribution metadata into the contribution model if (model instanceof ContributionMetadata) { contributionMetadata = true; @@ -245,4 +268,38 @@ public class ContributionContentProcessor implements URLArtifactProcessor<Contri } } } + + /** + * The following code was copied from ContributionServiceImpl to fix TUSCANY-3171 + * + * @param model + */ + private void addPolicyDefinitions(Object model) { + + // Add policy definitions to the list of policy definitions + if (model instanceof SCADefinitions) { + policyDefinitions.add((SCADefinitions)model); + + SCADefinitions definitions = (SCADefinitions)model; + for (Intent intent : definitions.getPolicyIntents() ) { + policyDefinitionsResolver.addModel(intent); + } + + for (PolicySet policySet : definitions.getPolicySets() ) { + policyDefinitionsResolver.addModel(policySet); + } + + for (IntentAttachPointType attachPointType : definitions.getBindingTypes() ) { + policyDefinitionsResolver.addModel(attachPointType); + } + + for (IntentAttachPointType attachPointType : definitions.getImplementationTypes() ) { + policyDefinitionsResolver.addModel(attachPointType); + } + for (Object binding : definitions.getBindings() ) { + policyDefinitionsResolver.addModel(binding); + } + } + } + } |