diff options
Diffstat (limited to 'java/sca/modules/policy-xml/src/main')
3 files changed, 49 insertions, 15 deletions
diff --git a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java b/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java index 109090ccab..33e88663ee 100644 --- a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java +++ b/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java @@ -247,10 +247,24 @@ abstract class PolicyIntentProcessor<T extends Intent> extends BaseStAXArtifactP for (Intent requiredIntent : policyIntent.getRequiredIntents()) { if (requiredIntent.isUnresolved()) { Intent resolvedRequiredIntent = resolver.resolveModel(Intent.class, requiredIntent); - if (resolvedRequiredIntent != null) { + // At this point, when the required intent is not resolved, it does not mean + // its undeclared, chances are that their dependency are not resolved yet. + // Lets try to resolve them first. + if (resolvedRequiredIntent.isUnresolved()) { + if (resolvedRequiredIntent instanceof ProfileIntent) { + if ((((ProfileIntent)resolvedRequiredIntent).getRequiredIntents()).contains(policyIntent)) { + error("CyclicReferenceFound", resolver, requiredIntent, policyIntent); + return; + } + resolveDependent(resolvedRequiredIntent, resolver); + } + } + + if (!resolvedRequiredIntent.isUnresolved()) { requiredIntents.add(resolvedRequiredIntent); } else { error("RequiredIntentNotFound", resolver, requiredIntent, policyIntent); + return; //throw new ContributionResolveException("Required Intent - " + requiredIntent //+ " not found for ProfileIntent " + policyIntent); } @@ -270,19 +284,36 @@ abstract class PolicyIntentProcessor<T extends Intent> extends BaseStAXArtifactP Intent qualifiableIntent = policyIntent.getQualifiableIntent(); if (qualifiableIntent.isUnresolved()) { Intent resolvedQualifiableIntent = resolver.resolveModel(Intent.class, qualifiableIntent); - - if (resolvedQualifiableIntent != null) { + // At this point, when the qualifiable intent is not resolved, it does not mean + // its undeclared, chances are that their dependency are not resolved yet. + // Lets try to resolve them first. + if (resolvedQualifiableIntent.isUnresolved()) { + if (resolvedQualifiableIntent instanceof QualifiedIntent) { + resolveDependent(resolvedQualifiableIntent, resolver); + } + } + + if (!resolvedQualifiableIntent.isUnresolved()) { policyIntent.setQualifiableIntent(resolvedQualifiableIntent); } else { error("QualifiableIntentNotFound", resolver, qualifiableIntent, policyIntent); //throw new ContributionResolveException("Qualifiable Intent - " + qualifiableIntent //+ " not found for QualifiedIntent " + policyIntent); - } - + } } } } + public void resolveDependent(Intent policyIntent, ModelResolver resolver) throws ContributionResolveException { + if (policyIntent instanceof ProfileIntent) + resolveProfileIntent((ProfileIntent)policyIntent, resolver); + + if (policyIntent instanceof QualifiedIntent) + resolveQualifiedIntent((QualifiedIntent)policyIntent, resolver); + + resolveContrainedArtifacts(policyIntent, resolver); + } + public void resolve(T policyIntent, ModelResolver resolver) throws ContributionResolveException { if (policyIntent instanceof ProfileIntent) { resolveProfileIntent((ProfileIntent)policyIntent, resolver); @@ -360,11 +391,12 @@ abstract class PolicyIntentProcessor<T extends Intent> extends BaseStAXArtifactP List<Intent> excludedIntents = new ArrayList<Intent>(); for (Intent excludedIntent : policyIntent.getExcludedIntents()) { if (excludedIntent.isUnresolved()) { - Intent resolvedExcludedIntent = resolver.resolveModel(Intent.class, excludedIntent); - if (resolvedExcludedIntent != null) { + Intent resolvedExcludedIntent = resolver.resolveModel(Intent.class, excludedIntent); + if (!resolvedExcludedIntent.isUnresolved()) { excludedIntents.add(resolvedExcludedIntent); } else { error("ExcludedIntentNotFound", resolver, excludedIntent, policyIntent); + return; //throw new ContributionResolveException("Excluded Intent " + excludedIntent //+ " not found for intent " + policyIntent); } diff --git a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java b/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java index b6f33aa677..e19099a2f3 100644 --- a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java +++ b/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java @@ -371,13 +371,13 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA for (Intent providedIntent : policySet.getProvidedIntents()) { if (providedIntent.isUnresolved()) { Intent resolvedProvidedIntent = resolver.resolveModel(Intent.class, providedIntent); - if (resolvedProvidedIntent != null) { + if (!resolvedProvidedIntent.isUnresolved()) { providedIntents.add(resolvedProvidedIntent); } else { error("ProvidedIntentNotFound", policySet, providedIntent, policySet); + return; //throw new ContributionResolveException("Provided Intent - " + providedIntent //+ " not found for PolicySet " + policySet); - } } else { providedIntents.add(providedIntent); @@ -394,11 +394,11 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA Intent mappedIntent = entry.getKey(); if (mappedIntent.isUnresolved()) { Intent resolvedMappedIntent = resolver.resolveModel(Intent.class, mappedIntent); - - if (resolvedMappedIntent != null) { + if (!resolvedMappedIntent.isUnresolved()) { mappedPolicies.put(resolvedMappedIntent, entry.getValue()); } else { error("MappedIntentNotFound", policySet, mappedIntent, policySet); + return; //throw new ContributionResolveException("Mapped Intent - " + mappedIntent //+ " not found for PolicySet " + policySet); } @@ -417,10 +417,11 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA for (PolicySet referredPolicySet : policySet.getReferencedPolicySets()) { if (referredPolicySet.isUnresolved()) { PolicySet resolvedReferredPolicySet = resolver.resolveModel(PolicySet.class, referredPolicySet); - if (resolvedReferredPolicySet != null) { + if (!resolvedReferredPolicySet.isUnresolved()) { referredPolicySets.add(resolvedReferredPolicySet); } else { error("ReferredPolicySetNotFound", policySet, referredPolicySet, policySet); + return; //throw new ContributionResolveException("Referred PolicySet - " + referredPolicySet //+ "not found for PolicySet - " + policySet); } @@ -453,9 +454,9 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA //resolve the policy attachments resolvePolicies(policySet, resolver); - if ( !policySet.isUnresolved() ) { + /*if ( !policySet.isUnresolved() ) { resolver.addModel(policySet); - } + }*/ } } } diff --git a/java/sca/modules/policy-xml/src/main/resources/policy-xml-validation-messages.properties b/java/sca/modules/policy-xml/src/main/resources/policy-xml-validation-messages.properties index d8eb214c15..60c73d5354 100644 --- a/java/sca/modules/policy-xml/src/main/resources/policy-xml-validation-messages.properties +++ b/java/sca/modules/policy-xml/src/main/resources/policy-xml-validation-messages.properties @@ -33,4 +33,5 @@ UnrecognizedIntentAttachPointType = Unrecognized IntentAttachPointType - {0} RequiredAttributeMissing = Required attribute {0} missing from BindingType Definition AlwaysProvidedIntentNotFound = Always Provided Intent - {0} not found for ExtensionType {1} MayProvideIntentNotFound = May Provide Intent - {0} not found for ExtensionType {1} -ContributionReadException = ContributionReadException occured due to: {0}
\ No newline at end of file +ContributionReadException = ContributionReadException occured due to: {0} +CyclicReferenceFound = Cyclic reference detected in required attributes of ProfileIntents {0} and {1}
\ No newline at end of file |