You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sv...@apache.org on 2008/04/21 09:01:14 UTC
svn commit: r650028 - in
/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl:
BindingPolicyComputer.java CompositeWireBuilderImpl.java
ImplementationPolicyComputer.java PolicyComputer.java
Author: svkrish
Date: Mon Apr 21 00:01:08 2008
New Revision: 650028
URL: http://svn.apache.org/viewvc?rev=650028&view=rev
Log:
https://issues.apache.org/jira/browse/TUSCANY-2239
Modified:
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BindingPolicyComputer.java
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeWireBuilderImpl.java
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ImplementationPolicyComputer.java
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyComputer.java
Modified: incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BindingPolicyComputer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BindingPolicyComputer.java?rev=650028&r1=650027&r2=650028&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BindingPolicyComputer.java (original)
+++ incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BindingPolicyComputer.java Mon Apr 21 00:01:08 2008
@@ -25,6 +25,7 @@
import javax.xml.namespace.QName;
+import org.apache.tuscany.sca.assembly.Base;
import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.ConfiguredOperation;
import org.apache.tuscany.sca.assembly.Contract;
@@ -50,13 +51,20 @@
public void computeBindingIntentsAndPolicySets(Contract contract) throws PolicyValidationException {
for (Binding binding : contract.getBindings()) {
if (binding instanceof PolicySetAttachPoint) {
+ PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)binding;
computeIntents((IntentAttachPoint)binding, contract.getRequiredIntents());
aggregateAndPruneApplicablePolicySets(contract.getApplicablePolicySets(),
- ((PolicySetAttachPoint)binding).getApplicablePolicySets());
+ policiedBinding.getApplicablePolicySets());
+
+ computePolicySets(policiedBinding, contract.getPolicySets());
+
+ PolicyComputationUtils.checkForMutuallyExclusiveIntents(
+ policiedBinding.getRequiredIntents(),
+ policiedBinding.getPolicySets(),
+ policiedBinding.getType(),
+ contract.getName());
- computePolicySets((PolicySetAttachPoint)binding, contract.getPolicySets());
-
if ( binding instanceof OperationsConfigurator &&
contract instanceof OperationsConfigurator ) {
//add or merge service operations to the binding
@@ -66,7 +74,16 @@
computeIntentsForOperations((IntentAttachPoint)binding);
computePolicySetsForOperations(contract.getApplicablePolicySets(),
- (PolicySetAttachPoint)binding);
+ policiedBinding);
+
+ for ( ConfiguredOperation confOp : ((OperationsConfigurator)binding).getConfiguredOperations() ) {
+ PolicyComputationUtils.checkForMutuallyExclusiveIntents(
+ confOp.getRequiredIntents(),
+ confOp.getPolicySets(),
+ policiedBinding.getType(),
+ contract.getName() + "." + confOp.getName());
+ }
+
}
}
}
@@ -74,12 +91,20 @@
if ( contract.getCallback() != null ) {
for (Binding binding : contract.getCallback().getBindings()) {
if (binding instanceof PolicySetAttachPoint) {
+ PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)binding;
computeIntents((IntentAttachPoint)binding, contract.getCallback().getRequiredIntents());
aggregateAndPruneApplicablePolicySets(contract.getApplicablePolicySets(),
- ((PolicySetAttachPoint)binding).getApplicablePolicySets());
+ policiedBinding.getApplicablePolicySets());
+
+ computePolicySets(policiedBinding, contract.getCallback().getPolicySets());
+
+ PolicyComputationUtils.checkForMutuallyExclusiveIntents(
+ policiedBinding.getRequiredIntents(),
+ policiedBinding.getPolicySets(),
+ policiedBinding.getType(),
+ contract.getName() + " callback");
- computePolicySets((PolicySetAttachPoint)binding, contract.getCallback().getPolicySets());
}
}
}
@@ -259,4 +284,39 @@
target.clear();
target.addAll(policySetTable.values());
}
+
+ protected <C extends Contract> void inheritDefaultPolicies(Base parent, List<C> contracts) {
+
+ for (Contract contract : contracts) {
+
+ // The contract inherits default policies from the parent composite/component.
+ if ( parent instanceof PolicySetAttachPoint ) {
+ PolicyComputationUtils.addDefaultPolicies(
+ ((PolicySetAttachPoint)parent).getRequiredIntents(),
+ ((PolicySetAttachPoint)parent).getPolicySets(),
+ contract.getRequiredIntents(),
+ contract.getPolicySets());
+ }
+
+ // The contract's configured operations inherit default policies from the contract.
+ for ( ConfiguredOperation confOp : contract.getConfiguredOperations() ) {
+ PolicyComputationUtils.addDefaultPolicies(
+ contract.getRequiredIntents(),
+ contract.getPolicySets(),
+ confOp.getRequiredIntents(),
+ confOp.getPolicySets());
+ }
+
+ // The contract's callback inherits default policies from the contract.
+ if (contract.getCallback() != null) {
+ PolicyComputationUtils.addDefaultPolicies(
+ contract.getRequiredIntents(),
+ contract.getPolicySets(),
+ contract.getCallback().getRequiredIntents(),
+ contract.getCallback().getPolicySets());
+ }
+
+ }
+ }
+
}
Modified: incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeWireBuilderImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeWireBuilderImpl.java?rev=650028&r1=650027&r2=650028&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeWireBuilderImpl.java (original)
+++ incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeWireBuilderImpl.java Mon Apr 21 00:01:08 2008
@@ -866,49 +866,16 @@
public void computePolicies(Composite composite) {
-
- //compute policies for composite service bindings
- for (Service service : composite.getServices()) {
- addPoliciesFromPromotedService((CompositeService)service);
- try {
- //compute the intents for operations under service element
- bindingPolicyComputer.computeIntentsForOperations(service);
- //add or merge service operations to the binding
- //addInheritedOpConfOnBindings(service);
- bindingPolicyComputer.computeBindingIntentsAndPolicySets(service);
- bindingPolicyComputer.determineApplicableBindingPolicySets(service, null);
- } catch ( Exception e ) {
- warning("Policy related exception: " + e, e);
- //throw new RuntimeException(e);
- }
-
- }
-
- for (Reference reference : composite.getReferences()) {
- CompositeReference compReference = (CompositeReference)reference;
- addPoliciesFromPromotedReference(compReference);
- try {
- //compute the intents for operations under service element
- bindingPolicyComputer.computeIntentsForOperations(reference);
- //addInheritedOpConfOnBindings(reference);
-
- if (compReference.getCallback() != null) {
- PolicyComputationUtils.addInheritedIntents(compReference.getRequiredIntents(),
- compReference.getCallback().getRequiredIntents());
- PolicyComputationUtils.addInheritedPolicySets(compReference.getPolicySets(),
- compReference.getCallback().getPolicySets(),
- false);
- }
-
- bindingPolicyComputer.computeBindingIntentsAndPolicySets(reference);
- bindingPolicyComputer.determineApplicableBindingPolicySets(reference, null);
- } catch ( Exception e ) {
- warning("Policy related exception: " + e, e);
- //throw new RuntimeException(e);
- }
- }
for (Component component : composite.getComponents()) {
+
+ // Inherit default policies from the component to component-level contracts.
+ // This must be done BEFORE computing implementation policies because the
+ // implementation policy computer removes from the component any
+ // intents and policy sets that don't apply to implementations.
+ bindingPolicyComputer.inheritDefaultPolicies(component, component.getServices());
+ bindingPolicyComputer.inheritDefaultPolicies(component, component.getReferences());
+
Implementation implemenation = component.getImplementation();
try {
implPolicyComputer.computeImplementationIntentsAndPolicySets(implemenation, component);
@@ -988,7 +955,52 @@
//throw new RuntimeException(e);
}
}
- }
+ }
+
+ bindingPolicyComputer.inheritDefaultPolicies(composite, composite.getServices());
+ bindingPolicyComputer.inheritDefaultPolicies(composite, composite.getReferences());
+
+ //compute policies for composite service bindings
+ for (Service service : composite.getServices()) {
+ addPoliciesFromPromotedService((CompositeService)service);
+ try {
+ //compute the intents for operations under service element
+ bindingPolicyComputer.computeIntentsForOperations(service);
+ //add or merge service operations to the binding
+ //addInheritedOpConfOnBindings(service);
+ bindingPolicyComputer.computeBindingIntentsAndPolicySets(service);
+ bindingPolicyComputer.determineApplicableBindingPolicySets(service, null);
+ } catch ( Exception e ) {
+ warning("Policy related exception: " + e, e);
+ //throw new RuntimeException(e);
+ }
+
+ }
+
+ for (Reference reference : composite.getReferences()) {
+ CompositeReference compReference = (CompositeReference)reference;
+ addPoliciesFromPromotedReference(compReference);
+ try {
+ //compute the intents for operations under service element
+ bindingPolicyComputer.computeIntentsForOperations(reference);
+ //addInheritedOpConfOnBindings(reference);
+
+ if (compReference.getCallback() != null) {
+ PolicyComputationUtils.addInheritedIntents(compReference.getRequiredIntents(),
+ compReference.getCallback().getRequiredIntents());
+ PolicyComputationUtils.addInheritedPolicySets(compReference.getPolicySets(),
+ compReference.getCallback().getPolicySets(),
+ false);
+ }
+
+ bindingPolicyComputer.computeBindingIntentsAndPolicySets(reference);
+ bindingPolicyComputer.determineApplicableBindingPolicySets(reference, null);
+ } catch ( Exception e ) {
+ warning("Policy related exception: " + e, e);
+ //throw new RuntimeException(e);
+ }
+ }
+
}
private void addInheritedOperationConfigurations(OperationsConfigurator source,
Modified: incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ImplementationPolicyComputer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ImplementationPolicyComputer.java?rev=650028&r1=650027&r2=650028&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ImplementationPolicyComputer.java (original)
+++ incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ImplementationPolicyComputer.java Mon Apr 21 00:01:08 2008
@@ -30,6 +30,7 @@
import org.apache.tuscany.sca.policy.IntentAttachPoint;
import org.apache.tuscany.sca.policy.PolicySet;
import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.util.PolicyComputationUtils;
import org.apache.tuscany.sca.policy.util.PolicyValidationException;
/**
@@ -52,7 +53,7 @@
parent.getRequiredIntents().clear();
parent.getRequiredIntents().addAll(prunedIntents);
normalizeIntents(parent);
-
+
computeIntentsForOperations((OperationsConfigurator)parent,
(IntentAttachPoint)implementation,
parent.getRequiredIntents());
@@ -63,11 +64,27 @@
parent.getPolicySets().clear();
parent.getPolicySets().addAll(prunedPolicySets);
normalizePolicySets(parent);
+
+ PolicyComputationUtils.checkForMutuallyExclusiveIntents(
+ parent.getRequiredIntents(),
+ parent.getPolicySets(),
+ policiedImplementation.getType(),
+ parent.getName());
+
computePolicySetsForOperations(parent.getApplicablePolicySets(),
(OperationsConfigurator)parent,
(PolicySetAttachPoint)implementation);
+
+ for ( ConfiguredOperation confOp : ((OperationsConfigurator)parent).getConfiguredOperations() ) {
+ PolicyComputationUtils.checkForMutuallyExclusiveIntents(
+ confOp.getRequiredIntents(),
+ confOp.getPolicySets(),
+ policiedImplementation.getType(),
+ parent.getName() + "." + confOp.getName());
+ }
determineApplicableImplementationPolicySets(parent);
+
}
}
Modified: incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyComputer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyComputer.java?rev=650028&r1=650027&r2=650028&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyComputer.java (original)
+++ incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyComputer.java Mon Apr 21 00:01:08 2008
@@ -35,6 +35,7 @@
import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
import org.apache.tuscany.sca.policy.ProfileIntent;
import org.apache.tuscany.sca.policy.QualifiedIntent;
+import org.apache.tuscany.sca.policy.util.PolicyComputationUtils;
import org.apache.tuscany.sca.policy.util.PolicyValidationException;
import org.apache.tuscany.sca.policy.util.PolicyValidationUtils;
@@ -52,7 +53,7 @@
List<Intent> validInheritableIntents = new ArrayList<Intent>();
//expand profile intents in inherited intents
- expandProfileIntents(inheritableIntents);
+ PolicyComputationUtils.expandProfileIntents(inheritableIntents);
//validate if inherited intent applies to the attachpoint (binding / implementation) and
//only add such intents to the attachpoint (binding / implementation)
@@ -72,18 +73,9 @@
return validInheritableIntents;
}
- protected void expandProfileIntents(List<Intent> intents) {
- List<Intent> expandedIntents = null;
- if ( intents.size() > 0 ) {
- expandedIntents = findAndExpandProfileIntents(intents);
- intents.clear();
- intents.addAll(expandedIntents);
- }
- }
-
protected void normalizeIntents(IntentAttachPoint intentAttachPoint) {
//expand profile intents specified in the attachpoint (binding / implementation)
- expandProfileIntents(intentAttachPoint.getRequiredIntents());
+ PolicyComputationUtils.expandProfileIntents(intentAttachPoint.getRequiredIntents());
//remove duplicates and ...
//where qualified form of intent exists retain it and remove the qualifiable intent
@@ -118,7 +110,7 @@
boolean found = false;
for ( ConfiguredOperation confOp : opConfigurator.getConfiguredOperations() ) {
//expand profile intents specified on operations
- expandProfileIntents(confOp.getRequiredIntents());
+ PolicyComputationUtils.expandProfileIntents(confOp.getRequiredIntents());
//validateIntents(confOp, attachPointType);
@@ -142,7 +134,16 @@
}
if ( !found ) {
- attachPointOpIntents.add(anIntent);
+ boolean conflict = false;
+ for (Intent excluded : anIntent.getExcludedIntents()) {
+ if (confOp.getRequiredIntents().contains(excluded)) {
+ conflict = true;
+ break;
+ }
+ }
+ if (!conflict) {
+ attachPointOpIntents.add(anIntent);
+ }
}
}
@@ -195,7 +196,7 @@
//expand profile intents
for ( PolicySet policySet : policySetAttachPoint.getPolicySets() ) {
- expandProfileIntents(policySet.getProvidedIntents());
+ PolicyComputationUtils.expandProfileIntents(policySet.getProvidedIntents());
}
}
@@ -251,7 +252,7 @@
//expand profile intents
for ( PolicySet policySet : confOp.getPolicySets() ) {
- expandProfileIntents(policySet.getProvidedIntents());
+ PolicyComputationUtils.expandProfileIntents(policySet.getProvidedIntents());
}
}
}
@@ -268,9 +269,30 @@
IntentAttachPointType intentAttachPointType) {
if (policySetAttachPoint.getRequiredIntents().size() > 0) {
+
+ // form a list of all intents required by the attach point
+ List<Intent> combinedTargetIntents = new ArrayList<Intent>();
+ combinedTargetIntents.addAll(policySetAttachPoint.getRequiredIntents());
+ for (PolicySet targetPolicySet : policySetAttachPoint.getPolicySets()) {
+ combinedTargetIntents.addAll(PolicyComputationUtils.findAndExpandProfileIntents(targetPolicySet.getProvidedIntents()));
+ }
+
//since the set of applicable policysets for this attachpoint is known
//we only need to check in that list if there is a policyset that matches
for (PolicySet policySet : applicablePolicySets) {
+ // do not use the policy set if it provides intents that conflict with required intents
+ boolean conflict = false;
+ List<Intent> providedIntents = PolicyComputationUtils.findAndExpandProfileIntents(policySet.getProvidedIntents());
+ checkConflict: for (Intent intent : providedIntents) {
+ for (Intent excluded : intent.getExcludedIntents()) {
+ if (combinedTargetIntents.contains(excluded)) {
+ conflict = true;
+ break checkConflict;
+ }
+ }
+ }
+ if (conflict)
+ continue;
int prevSize = policySetAttachPoint.getRequiredIntents().size();
trimProvidedIntents(policySetAttachPoint.getRequiredIntents(), policySet);
// if any intent was trimmed off, then this policyset must
@@ -280,20 +302,6 @@
}
}
}
- }
-
- private List<Intent> findAndExpandProfileIntents(List<Intent> intents) {
- List<Intent> expandedIntents = new ArrayList<Intent>();
- for ( Intent intent : intents ) {
- if ( intent instanceof ProfileIntent ) {
- ProfileIntent profileIntent = (ProfileIntent)intent;
- List<Intent> requiredIntents = profileIntent.getRequiredIntents();
- expandedIntents.addAll(findAndExpandProfileIntents(requiredIntents));
- } else {
- expandedIntents.add(intent);
- }
- }
- return expandedIntents;
}
private boolean isProvidedInherently(IntentAttachPointType attachPointType, Intent intent) {
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org