summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java24
-rw-r--r--sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java38
2 files changed, 52 insertions, 10 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 a5ad40df86..428b1c6d2d 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
@@ -381,6 +381,18 @@ public class ComponentPolicyBuilderImpl {
return null;
}
+ // Replace qualifiable intents with their default qualifier. This can't be done until
+ // after inheritance.
+ protected void expandDefaultIntents(PolicySubject subject, BuilderContext context) {
+
+ Set<Intent> copy = new HashSet<Intent>(subject.getRequiredIntents());
+ for (Intent i : copy) {
+ if (i.getDefaultQualifiedIntent() != null) {
+ subject.getRequiredIntents().remove(i);
+ subject.getRequiredIntents().add(i.getDefaultQualifiedIntent());
+ }
+ }
+ }
protected void resolveAndNormalize(PolicySubject subject, BuilderContext context) {
Definitions definitions = context.getDefinitions();
Set<Intent> intents = new HashSet<Intent>();
@@ -422,14 +434,6 @@ public class ComponentPolicyBuilderImpl {
}
- // Replace qualifiable intents with the default qualified intent
- copy = new HashSet<Intent>(intents);
- for (Intent i : copy) {
- if (i.getDefaultQualifiedIntent() != null) {
- intents.remove(i);
- intents.add(i.getDefaultQualifiedIntent());
- }
- }
subject.getRequiredIntents().clear();
subject.getRequiredIntents().addAll(intents);
@@ -524,7 +528,9 @@ public class ComponentPolicyBuilderImpl {
// 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(), "IntentNotSatisfiedAtBuild", subject, intent.getName(), subject.toString());
+
+ // warning(context.getMonitor(), "IntentNotSatisfiedAtBuild", subject, intent.getName(), subject.toString());
+ error(context.getMonitor(), "IntentNotSatisfiedAtBuild", subject, intent.getName(), subject.toString());
}
}
}
diff --git a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java
index ea459bf2fa..bb8ea62a87 100644
--- a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java
+++ b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java
@@ -19,6 +19,8 @@
package org.apache.tuscany.sca.builder.impl;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Set;
import javax.xml.namespace.QName;
@@ -37,6 +39,8 @@ import org.apache.tuscany.sca.assembly.builder.PolicyBuilder;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
/**
* A composite builder that computes policy sets based on attached intents and policy sets.
@@ -113,9 +117,15 @@ public class CompositePolicyBuilderImpl extends ComponentPolicyBuilderImpl imple
// Replace qualifiable intents with the default qualied intent
resolveAndNormalize(ep, context);
+ // Replace qualifiable intents with their default qualifier
+ expandDefaultIntents(ep, context);
+
// Remove the intents whose @contraints do not include the current element
removeConstrainedIntents(ep, context);
+ // Remove any direct policy sets if an external one has been applied
+ removeDirectPolicySetsIfExternalExists(ep, context);
+
// check that all intents are resolved
checkIntentsResolved(ep, context);
@@ -157,9 +167,14 @@ public class CompositePolicyBuilderImpl extends ComponentPolicyBuilderImpl imple
// Replace qualifiable intents with the default qualified intent
resolveAndNormalize(epr, context);
+ // Replace qualifiable intents with their default qualifier
+ expandDefaultIntents(epr, context);
+
// Remove the intents whose @contraints do not include the current element
removeConstrainedIntents(epr, context);
+ removeDirectPolicySetsIfExternalExists(epr, context);
+
// check that all intents are resolved
checkIntentsResolved(epr, context);
@@ -183,6 +198,8 @@ public class CompositePolicyBuilderImpl extends ComponentPolicyBuilderImpl imple
// Remove the intents whose @contraints do not include the current element
removeConstrainedIntents(implementation, context);
+ removeDirectPolicySetsIfExternalExists(implementation, context);
+
// check that all intents are resolved
checkIntentsResolved(implementation, context);
}
@@ -196,7 +213,26 @@ public class CompositePolicyBuilderImpl extends ComponentPolicyBuilderImpl imple
}
}
- /**
+ private void removeDirectPolicySetsIfExternalExists(PolicySubject subject,
+ BuilderContext context) {
+ boolean foundExternalPolicySet = false;
+ for (PolicySet ps : subject.getPolicySets() ) {
+ if ( ps.getAttachTo() != null )
+ foundExternalPolicySet = true;
+ }
+
+ if ( foundExternalPolicySet ) {
+ List<PolicySet> copy = new ArrayList<PolicySet>(subject.getPolicySets());
+ for ( PolicySet ps : copy ) {
+ if ( ps.getAttachTo() == null ) {
+ subject.getPolicySets().remove(ps);
+ }
+ }
+ }
+
+ }
+
+ /**
* This is mainly about removing policies that don't "applyTo" the element where
* they have ended up after all the attachment and inheritance processing
*