summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/builder/src/main
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-03-01 12:55:50 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-03-01 12:55:50 +0000
commitaa4198ee954c8fae577160b510d9fc94dabded18 (patch)
treec25f9b94526c50cf5c7c4bcedc9cb1843b494f16 /sca-java-2.x/trunk/modules/builder/src/main
parentd8234862d2003940b84b0607b4b7f34e1623f8a4 (diff)
Check that intents are properly satisfied, particularly in the qualified intent case. Raise a warning if not.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@917504 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/builder/src/main')
-rw-r--r--sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java
index 0eed2bdb16..0879136e64 100644
--- a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java
+++ b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java
@@ -338,6 +338,9 @@ public class ComponentPolicyBuilderImpl {
subject.getRequiredIntents().clear();
subject.getRequiredIntents().addAll(intents);
+ // resolve policy set names that have been specified for the
+ // policy subject against the real policy sets from the
+ // definitions files
Set<PolicySet> policySets = new HashSet<PolicySet>();
if (definitions != null) {
for (PolicySet policySet : subject.getPolicySets()) {
@@ -351,23 +354,53 @@ public class ComponentPolicyBuilderImpl {
}
}
+ // find the policy sets that satisfy the intents that are now
+ // attached to the policy subject. From the OASIS policy
+ // spec CD02 rev7:
+ // 1272 A policySet provides an intent if any of the statements are true:
+ // 1273 1. The intent is contained in the policySet @provides list.
+ // 1274 2. The intent is a qualified intent and the unqualified form of the intent is contained in the policySet
+ // 1275 @provides list.
+ // 1276 3. The policySet @provides list contains a qualified form of the intent (where the intent is qualifiable).
for (Intent intent : subject.getRequiredIntents()) {
+ boolean intentMatched = false;
+
loop: for (PolicySet ps : definitions.getPolicySets()) {
// FIXME: We will have to check the policy references and intentMap too
// as well as the appliesTo
if (ps.getProvidedIntents().contains(intent)) {
policySets.add(ps);
+ intentMatched = true;
break;
}
+
+ for (Intent psProvidedIntent : ps.getProvidedIntents()){
+ if (isQualifiedBy(psProvidedIntent, intent)){
+ policySets.add(ps);
+ intentMatched = true;
+ break loop;
+ }
+ }
+
for (IntentMap map : ps.getIntentMaps()) {
for (Qualifier q : map.getQualifiers()) {
if (intent.equals(q.getIntent())) {
policySets.add(ps);
+ intentMatched = true;
break loop;
}
}
}
}
+
+ if (!intentMatched){
+ // Raise a warning as we have an intent that doesn't have a matching
+ // policy set at this start.
+ // TODO - this could be because the intent is provided by and extension
+ // and hence there is no explicit policy set. Need and extra piece
+ // of processing to walk through the extension models.
+ warning(context.getMonitor(), "IntentNotSatisfied", subject, intent.getName(), subject.toString());
+ }
}
subject.getPolicySets().clear();
@@ -387,5 +420,13 @@ public class ComponentPolicyBuilderImpl {
}
return names;
}
+
+ protected boolean isQualifiedBy(Intent qualifiableIntent, Intent qualifiedIntent){
+ if (qualifiedIntent.getQualifiableIntent() == qualifiableIntent){
+ return true;
+ } else {
+ return false;
+ }
+ }
}