Author: slaws
Date: Mon Mar 1 12:55:50 2010
New Revision: 917504
URL: http://svn.apache.org/viewvc?rev=917504&view=rev
Log:
Check that intents are properly satisfied, particularly in the qualified intent
case. Raise a warning if not.
Modified:
tuscany/sca-java-2.x/trunk/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties
tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java
tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
Modified:
tuscany/sca-java-2.x/trunk/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties?rev=917504&r1=917503&r2=917504&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties
(original)
+++
tuscany/sca-java-2.x/trunk/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties
Mon Mar 1 12:55:50 2010
@@ -71,4 +71,5 @@
PropertyXpathExpressionReturnedNull = The property XPath expression for
component {0} property {1} expression {2} did not match anything in the source
property
PropertyHasManyValues = The property component {0} property {1} has many
values but its "many" attribute is set to false
PropertXSDTypesDontMatch = [ASM_5036] The property component {0} property {1}
has XSD type {2} while its component type property has the XSD type {3}
-PropertXSDElementsDontMatch = [ASM_5036] The property component {0} property
{1} has XSD element {2} while its component type property has the XSD element
{3}
\ No newline at end of file
+PropertXSDElementsDontMatch = [ASM_5036] The property component {0} property
{1} has XSD element {2} while its component type property has the XSD element
{3}
+IntentNotSatisfied = The intent {0} associated with policy subject {1} has not
matching policy set
\ No newline at end of file
Modified:
tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java?rev=917504&r1=917503&r2=917504&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java
Mon Mar 1 12:55:50 2010
@@ -338,6 +338,9 @@
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 @@
}
}
+ // 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 @@
}
return names;
}
+
+ protected boolean isQualifiedBy(Intent qualifiableIntent, Intent
qualifiedIntent){
+ if (qualifiedIntent.getQualifiableIntent() == qualifiableIntent){
+ return true;
+ } else {
+ return false;
+ }
+ }
}
Modified:
tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java?rev=917504&r1=917503&r2=917504&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
Mon Mar 1 12:55:50 2010
@@ -43,7 +43,9 @@
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.MonitorFactory;
import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentMap;
import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.Qualifier;
import org.apache.tuscany.sca.runtime.EndpointReferenceBinder;
import org.apache.tuscany.sca.runtime.EndpointRegistry;
@@ -466,12 +468,31 @@
} else {
*/
- for (PolicySet policySet : referencePolicySets){
+ // TODO - this code also appears in the ComponentPolicyBuilder
+ // so should rationalize
+ loop: for (PolicySet policySet : referencePolicySets){
if (policySet.getProvidedIntents().contains(intent)){
eprIntents.remove(intent);
break;
}
+
+ for (Intent psProvidedIntent :
policySet.getProvidedIntents()){
+ if (isQualifiedBy(psProvidedIntent, intent)){
+ eprIntents.remove(intent);
+ break loop;
+ }
+ }
+
+ for (IntentMap map : policySet.getIntentMaps()) {
+ for (Qualifier q : map.getQualifiers()) {
+ if (intent.equals(q.getIntent())) {
+ eprIntents.remove(intent);
+ break loop;
+ }
+ }
+ }
}
+
/*
}
*/
@@ -571,6 +592,14 @@
return match;
}
+ protected boolean isQualifiedBy(Intent qualifiableIntent, Intent
qualifiedIntent){
+ if (qualifiedIntent.getQualifiableIntent() == qualifiableIntent){
+ return true;
+ } else {
+ return false;
+ }
+ }
+
/**
* Determine if endpoint reference and endpoint interface contracts match
*/