Ignore direct policy sets when external policy sets are attached
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@964064 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c2ce223c5c
commit
e8b380a59b
2 changed files with 52 additions and 10 deletions
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue