Author: svkrish
Date: Wed Mar 12 05:09:58 2008
New Revision: 636290

URL: http://svn.apache.org/viewvc?rev=636290&view=rev
Log:
cleaning up policy computation and fixing holes in policy inheritance in 
operations

Modified:
    
incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
    
incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
    
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
    
incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/sca/implementation/java/xml/ReadTestCase.java
    
incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions.xml
    
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationUtils.java

Modified: 
incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java?rev=636290&r1=636289&r2=636290&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
 Wed Mar 12 05:09:58 2008
@@ -254,8 +254,7 @@
                             
PolicyValidationUtils.validateIntents(policiedImpl, policiedImpl.getType());
                             
                             resolvePolicySets(policiedImpl.getPolicySets(), 
resolver);
-                            
PolicyValidationUtils.validatePolicySets(policiedImpl, 
-                                                                     
policiedImpl.getApplicablePolicySets());
+                            
PolicyValidationUtils.validatePolicySets(policiedImpl);
                             
                             if ( implementation instanceof 
OperationsConfigurator ) {
                                 OperationsConfigurator opsConfigurator = 
(OperationsConfigurator)implementation;
@@ -264,7 +263,9 @@
                                     
PolicyValidationUtils.validateIntents(implOp, policiedImpl.getType());
                                     
                                     resolvePolicySets(implOp.getPolicySets(), 
resolver);
-                                    
PolicyValidationUtils.validatePolicySets(implOp, 
policiedImpl.getApplicablePolicySets());
+                                    
PolicyValidationUtils.validatePolicySets(implOp, 
+                                                                             
policiedImpl.getType(),
+                                                                             
policiedImpl.getApplicablePolicySets());
                                 }
                             }
                             
@@ -389,7 +390,7 @@
                             //applies to the binding as well
                             
addInheritedPolicySets(((PolicySetAttachPoint)binding).getApplicablePolicySets(),
 
                                                    
confOp.getApplicablePolicySets());
-                            PolicyValidationUtils.validatePolicySets(confOp);
+                            PolicyValidationUtils.validatePolicySets(confOp, 
((PolicySetAttachPoint)binding).getType());
                             
                             
addInheritedIntents(((PolicySetAttachPoint)binding).getRequiredIntents(), 
                                                 confOp.getRequiredIntents());
@@ -442,7 +443,7 @@
                                 //applies to the binding as well
                                 
addInheritedPolicySets(((PolicySetAttachPoint)binding).getApplicablePolicySets(),
 
                                                        
confOp.getApplicablePolicySets());
-                                
PolicyValidationUtils.validatePolicySets(confOp);
+                                
PolicyValidationUtils.validatePolicySets(confOp, 
((PolicySetAttachPoint)binding).getType());
                             }
                         }
                     }

Modified: 
incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java?rev=636290&r1=636289&r2=636290&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
 Wed Mar 12 05:09:58 2008
@@ -887,7 +887,7 @@
                     //add the inherited applicablePolicysets
                     
addInheritedPolicySets(policiedImpl.getApplicablePolicySets(), 
implConfOp.getApplicablePolicySets());
                     
-                    PolicyValidationUtils.validatePolicySets(implConfOp);
+                    PolicyValidationUtils.validatePolicySets(implConfOp, 
policiedImpl.getType());
                     
                     
addInheritedIntents(((PolicySetAttachPoint)implementation).getRequiredIntents(),
 
                                         implConfOp.getRequiredIntents());

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=636290&r1=636289&r2=636290&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
 Wed Mar 12 05:09:58 2008
@@ -20,6 +20,7 @@
 package org.apache.tuscany.sca.assembly.builder.impl;
 
 import java.util.ArrayList;
+import java.util.Hashtable;
 import java.util.List;
 
 import javax.xml.namespace.QName;
@@ -35,6 +36,7 @@
 import org.apache.tuscany.sca.policy.IntentAttachPointType;
 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;
 
 /**
@@ -47,63 +49,63 @@
     }
     
     public void computeBindingIntentsAndPolicySets(Contract contract)  throws 
PolicyValidationException {
-        computeIntents(contract.getBindings(), contract.getRequiredIntents());
-        computePolicySets(contract.getApplicablePolicySets(), 
contract.getBindings(), contract.getPolicySets());
-        
-        /*for ( Binding binding : contract.getBindings() ) {
-            if ( binding instanceof IntentAttachPoint ) {
-                computeIntentsForOperations((IntentAttachPoint)binding);
-            }
-            
-            if ( binding instanceof PolicySetAttachPoint ) {
-                
computePolicySetsForOperations(((PolicySetAttachPoint)binding).getApplicablePolicySets(),
 
-                                               (PolicySetAttachPoint)binding);
+        for (Binding binding : contract.getBindings()) {
+            if (binding instanceof PolicySetAttachPoint) {
+                computeIntents((IntentAttachPoint)binding, 
contract.getRequiredIntents());
+                
+                
aggregateAndPruneApplicablePolicySets(contract.getApplicablePolicySets(), 
+                                                      
((PolicySetAttachPoint)binding).getApplicablePolicySets());
+
+                computePolicySets((PolicySetAttachPoint)binding, 
contract.getPolicySets());
+                
+                if ( binding instanceof OperationsConfigurator && 
+                        contract instanceof OperationsConfigurator ) {
+                    //add or merge service operations to the binding
+                    
addInheritedOpConfOnBindings((OperationsConfigurator)contract,
+                                                 
(OperationsConfigurator)binding,
+                                                 
(PolicySetAttachPoint)binding);
+                
+                    computeIntentsForOperations((IntentAttachPoint)binding);
+                    
computePolicySetsForOperations(contract.getApplicablePolicySets(), 
+                                                   
(PolicySetAttachPoint)binding);
+                }
             }
-        }*/
+        }
         
         if ( contract.getCallback() != null ) {
-            computeIntents(contract.getCallback().getBindings(), 
-                           contract.getCallback().getRequiredIntents());
-            computePolicySets(contract.getApplicablePolicySets(), 
-                              contract.getCallback().getBindings(), 
-                              contract.getCallback().getPolicySets());
+            for (Binding binding : contract.getCallback().getBindings()) {
+                if (binding instanceof PolicySetAttachPoint) {
+                    computeIntents((IntentAttachPoint)binding, 
contract.getCallback().getRequiredIntents());
+            
+                    
aggregateAndPruneApplicablePolicySets(contract.getApplicablePolicySets(), 
+                                                          
((PolicySetAttachPoint)binding).getApplicablePolicySets());
+
+                    computePolicySets((PolicySetAttachPoint)binding, 
contract.getCallback().getPolicySets());
+                }
+            }
         }
     }
     
-    private void computeIntents(List<Binding> bindings, List<Intent> 
inheritedIntents) throws PolicyValidationException {
-        for (Binding binding : bindings) {
-            if (binding instanceof IntentAttachPoint) {
-                IntentAttachPoint policiedBinding = (IntentAttachPoint)binding;
-                //since the parent component could also contain intents that 
apply to implementation
-                //and binding elements within, we filter out only those that 
apply to this binding type
-                List<Intent> prunedIntents = 
computeInheritableIntents(policiedBinding.getType(), 
-                                                                       
inheritedIntents);
-                policiedBinding.getRequiredIntents().addAll(prunedIntents);
-                
-                normalizeIntents(policiedBinding);
-                
-                
computeIntentsForOperations((IntentAttachPoint)policiedBinding);
-            }
-        }
+    
+    private void computeIntents(IntentAttachPoint policiedBinding, 
List<Intent> inheritedIntents) 
+                                                                    throws 
PolicyValidationException {
+            //since the parent component could also contain intents that apply 
to implementation
+            //and binding elements within, we filter out only those that apply 
to this binding type
+            List<Intent> prunedIntents = 
computeInheritableIntents(policiedBinding.getType(), 
+                                                                   
inheritedIntents);
+            policiedBinding.getRequiredIntents().addAll(prunedIntents);
+            
+            normalizeIntents(policiedBinding);
     }
     
-    private void computePolicySets(List<PolicySet> applicablePolicySets,
-                                   List<Binding> bindings,
+    
+    private void computePolicySets(PolicySetAttachPoint policiedBinding,
                                    List<PolicySet> inheritedPolicySets) throws 
PolicyValidationException {
-        for (Binding binding : bindings) {
-            if ( binding instanceof PolicySetAttachPoint ) {
-                PolicySetAttachPoint policiedBinding = 
(PolicySetAttachPoint)binding;
-                
-                
policiedBinding.getApplicablePolicySets().addAll(applicablePolicySets);
-                List<PolicySet> prunedPolicySets = 
computeInheritablePolicySets(policiedBinding,
-                                                                               
 inheritedPolicySets,
-                                                                               
 policiedBinding.getApplicablePolicySets());
-                policiedBinding.getPolicySets().addAll(prunedPolicySets);
-                normalizePolicySets(policiedBinding);
-                computePolicySetsForOperations(applicablePolicySets, 
policiedBinding);
-
-            }
-        }
+                
+        List<PolicySet> prunedPolicySets = 
computeInheritablePolicySets(inheritedPolicySets,
+                                                                        
policiedBinding.getApplicablePolicySets());
+        policiedBinding.getPolicySets().addAll(prunedPolicySets);
+        normalizePolicySets(policiedBinding);
     }
     
     public void determineApplicableBindingPolicySets(Contract source, Contract 
target) throws PolicyComputationException {
@@ -207,5 +209,57 @@
                 }
             }
         //}
+    }
+    
+    private void addInheritedOpConfOnBindings(OperationsConfigurator source, 
+                                              OperationsConfigurator target,
+                                              PolicySetAttachPoint 
attachPoint) throws PolicyValidationException {
+        boolean found = false;
+        
+        List<ConfiguredOperation> additionalOperations = new 
ArrayList<ConfiguredOperation>();
+        for ( ConfiguredOperation sourceConfOp : 
source.getConfiguredOperations() ) {
+            for ( ConfiguredOperation targetConfOp : 
target.getConfiguredOperations() ) {
+                if ( sourceConfOp.getName().equals(targetConfOp.getName())) {
+                    List<Intent> prunedIntents = 
computeInheritableIntents(attachPoint.getType(), 
+                                                                           
sourceConfOp.getRequiredIntents());
+                    PolicyComputationUtils.addInheritedIntents(prunedIntents, 
+                                                               
targetConfOp.getRequiredIntents());
+                    
+                    List<PolicySet> prunedPolicySets  = 
computeInheritablePolicySets(sourceConfOp.getPolicySets(), 
+                                                                               
      attachPoint.getApplicablePolicySets());
+                    
PolicyComputationUtils.addInheritedPolicySets(prunedPolicySets, 
targetConfOp.getPolicySets(), true);
+                    found = true;
+                    break;
+                }
+            }
+            
+            if ( !found ) {
+                additionalOperations.add(sourceConfOp);
+            }
+        }
+        
+        if ( !additionalOperations.isEmpty() ) {
+            target.getConfiguredOperations().addAll(additionalOperations);
+        }
+    }
+    
+    /*private void addInheritedOpConfOnBindings(Contract contract) {      
+        for ( Binding binding : contract.getBindings() ) {
+            if ( binding instanceof OperationsConfigurator ) {
+                addInheritedOperationConfigurations(contract, 
(OperationsConfigurator)binding);
+            }
+        }
+    }*/
+    
+    private void aggregateAndPruneApplicablePolicySets(List<PolicySet> source, 
List<PolicySet> target) {
+        target.addAll(source);
+        //strip duplicates
+        Hashtable<QName, PolicySet> policySetTable = new Hashtable<QName, 
PolicySet>();
+        for ( PolicySet policySet : target ) {
+            policySetTable.put(policySet.getName(), policySet);
+        }
+        
+        target.clear();
+        target.addAll(policySetTable.values());
     }
 }

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=636290&r1=636289&r2=636290&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
 Wed Mar 12 05:09:58 2008
@@ -49,6 +49,7 @@
 import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
 import org.apache.tuscany.sca.policy.Intent;
 import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.util.PolicyComputationUtils;
 
 public class CompositeWireBuilderImpl {
 
@@ -825,19 +826,19 @@
     
     private void addPoliciesFromPromotedService(CompositeService 
compositeService) {
         //inherit intents and policies from promoted service
-        
addInheritedIntents(compositeService.getPromotedService().getRequiredIntents(), 
+        
PolicyComputationUtils.addInheritedIntents(compositeService.getPromotedService().getRequiredIntents(),
 
                             compositeService.getRequiredIntents());
-        
addInheritedPolicySets(compositeService.getPromotedService().getPolicySets(), 
+        
PolicyComputationUtils.addInheritedPolicySets(compositeService.getPromotedService().getPolicySets(),
 
                                compositeService.getPolicySets(), true);
         
addInheritedOperationConfigurations(compositeService.getPromotedService(), 
compositeService);
     }
     
     private void addPoliciesFromPromotedReference(CompositeReference 
compositeReference) {
         for ( Reference promotedReference : 
compositeReference.getPromotedReferences() ) {
-           addInheritedIntents(promotedReference.getRequiredIntents(), 
+           
PolicyComputationUtils.addInheritedIntents(promotedReference.getRequiredIntents(),
 
                                compositeReference.getRequiredIntents());
        
-           addInheritedPolicySets(promotedReference.getPolicySets(), 
+           
PolicyComputationUtils.addInheritedPolicySets(promotedReference.getPolicySets(),
 
                                   compositeReference.getPolicySets(), true);
            addInheritedOperationConfigurations(promotedReference, 
compositeReference);
         }
@@ -853,7 +854,7 @@
                 //compute the intents for operations under service element
                 bindingPolicyComputer.computeIntentsForOperations(service);
                 //add or merge service operations to the binding
-                addInheritedOpConfOnBindings(service);
+                //addInheritedOpConfOnBindings(service);
                 
bindingPolicyComputer.computeBindingIntentsAndPolicySets(service);
                 
bindingPolicyComputer.determineApplicableBindingPolicySets(service, null);
             } catch ( Exception e ) {
@@ -869,12 +870,12 @@
             try {
                 //compute the intents for operations under service element
                 bindingPolicyComputer.computeIntentsForOperations(reference);
-                addInheritedOpConfOnBindings(reference);
+                //addInheritedOpConfOnBindings(reference);
                 
                 if (compReference.getCallback() != null) {
-                    addInheritedIntents(compReference.getRequiredIntents(), 
+                    
PolicyComputationUtils.addInheritedIntents(compReference.getRequiredIntents(), 
                                         
compReference.getCallback().getRequiredIntents());
-                    addInheritedPolicySets(compReference.getPolicySets(), 
+                    
PolicyComputationUtils.addInheritedPolicySets(compReference.getPolicySets(), 
                                            
compReference.getCallback().getPolicySets(), 
                                            false);
                 }
@@ -900,8 +901,8 @@
                 Service service = componentService.getService();
                 if (service != null) {
                     // reconcile intents and policysets from componentType
-                     addInheritedIntents(service.getRequiredIntents(), 
componentService.getRequiredIntents());
-                     addInheritedPolicySets(service.getPolicySets(), 
componentService.getPolicySets(), true);
+                     
PolicyComputationUtils.addInheritedIntents(service.getRequiredIntents(), 
componentService.getRequiredIntents());
+                     
PolicyComputationUtils.addInheritedPolicySets(service.getPolicySets(), 
componentService.getPolicySets(), true);
                      
                      //reconcile intents and policysets for operations 
                      boolean notFound;
@@ -910,8 +911,8 @@
                          notFound = true;
                          for ( ConfiguredOperation csConfOp : 
componentService.getConfiguredOperations() ) {
                              if ( 
csConfOp.getName().equals(ctsConfOp.getName()) ) {
-                                 
addInheritedIntents(ctsConfOp.getRequiredIntents(), 
csConfOp.getRequiredIntents());
-                                 
addInheritedPolicySets(ctsConfOp.getPolicySets(), csConfOp.getPolicySets(), 
true);
+                                 
PolicyComputationUtils.addInheritedIntents(ctsConfOp.getRequiredIntents(), 
csConfOp.getRequiredIntents());
+                                 
PolicyComputationUtils.addInheritedPolicySets(ctsConfOp.getPolicySets(), 
csConfOp.getPolicySets(), true);
                                  notFound = false;
                              } 
                          }
@@ -924,9 +925,9 @@
                 }
                 
                 if ( componentService.getCallback() != null ) {
-                    addInheritedIntents(componentService.getRequiredIntents(), 
+                    
PolicyComputationUtils.addInheritedIntents(componentService.getRequiredIntents(),
 
                                         
componentService.getCallback().getRequiredIntents());
-                    addInheritedPolicySets(componentService.getPolicySets(), 
+                    
PolicyComputationUtils.addInheritedPolicySets(componentService.getPolicySets(), 
                                            
componentService.getCallback().getPolicySets(), 
                                            false);
                 }
@@ -935,14 +936,14 @@
                     //compute the intents for operations under service element
                     
bindingPolicyComputer.computeIntentsForOperations(componentService);
                     //compute intents and policyset for each binding
-                    addInheritedOpConfOnBindings(componentService);
+                    //addInheritedOpConfOnBindings(componentService);
                     
bindingPolicyComputer.computeBindingIntentsAndPolicySets(componentService);
                     
bindingPolicyComputer.determineApplicableBindingPolicySets(componentService, 
null);
     
                     if ( componentService.getCallback() != null ) {
-                        
addInheritedIntents(componentService.getRequiredIntents(), 
+                        
PolicyComputationUtils.addInheritedIntents(componentService.getRequiredIntents(),
 
                                         
componentService.getCallback().getRequiredIntents());
-                        
addInheritedPolicySets(componentService.getPolicySets(), 
+                        
PolicyComputationUtils.addInheritedPolicySets(componentService.getPolicySets(), 
                                            
componentService.getCallback().getPolicySets(), 
                                            false);
                     }
@@ -956,14 +957,14 @@
                 Reference reference = componentReference.getReference();
                 if (reference != null) {
                     // reconcile intents and policysets
-                    addInheritedIntents(reference.getRequiredIntents(), 
componentReference.getRequiredIntents());
-                    addInheritedPolicySets(reference.getPolicySets(), 
componentReference.getPolicySets(), true);
+                    
PolicyComputationUtils.addInheritedIntents(reference.getRequiredIntents(), 
componentReference.getRequiredIntents());
+                    
PolicyComputationUtils.addInheritedPolicySets(reference.getPolicySets(), 
componentReference.getPolicySets(), true);
                 }
                 
                 if ( componentReference.getCallback() != null ) {
-                    
addInheritedIntents(componentReference.getRequiredIntents(), 
+                    
PolicyComputationUtils.addInheritedIntents(componentReference.getRequiredIntents(),
 
                                         
componentReference.getCallback().getRequiredIntents());
-                    addInheritedPolicySets(componentReference.getPolicySets(), 
+                    
PolicyComputationUtils.addInheritedPolicySets(componentReference.getPolicySets(),
 
                                            
componentReference.getCallback().getPolicySets(), 
                                            false);
                 }
@@ -972,15 +973,15 @@
                     //compute the intents for operations under reference 
element
                     
bindingPolicyComputer.computeIntentsForOperations(componentReference);
                     //compute intents and policyset for each binding
-                    addInheritedOpConfOnBindings(componentReference);
+                    //addInheritedOpConfOnBindings(componentReference);
                     
bindingPolicyComputer.computeBindingIntentsAndPolicySets(componentReference);
                     
bindingPolicyComputer.determineApplicableBindingPolicySets(componentReference, 
null);
     
                 
                     if ( componentReference.getCallback() != null ) {
-                        
addInheritedIntents(componentReference.getRequiredIntents(), 
+                        
PolicyComputationUtils.addInheritedIntents(componentReference.getRequiredIntents(),
 
                                             
componentReference.getCallback().getRequiredIntents());
-                        
addInheritedPolicySets(componentReference.getPolicySets(), 
+                        
PolicyComputationUtils.addInheritedPolicySets(componentReference.getPolicySets(),
 
                                                
componentReference.getCallback().getPolicySets(), 
                                                false);
                     }
@@ -990,50 +991,20 @@
                 }
             }
         } 
-        
-    }
-    
-    
/******************************************************************************************************/
-    /*policy computation methods common to implementation and binding types */
-    
/******************************************************************************************************/
-    private void addInheritedIntents(List<Intent> sourceList, List<Intent> 
targetList) {
-        if (sourceList != null) {
-            targetList.addAll(sourceList);
-        }
     }
     
-    private  void addInheritedPolicySets(List<PolicySet> sourceList, 
List<PolicySet> targetList, boolean checkOverrides) {
-        //check overrides is true when policysets are to be copied from 
componentType to component level
-        if ( checkOverrides ) {
-            //aggregate all the provided intents present in the target
-            List<Intent> targetProvidedIntents = new ArrayList<Intent>();
-            for ( PolicySet policySet : targetList ) {
-                targetProvidedIntents.addAll(policySet.getProvidedIntents());
-            }
-            
-            //for every policy set in the source check if it provides one of 
the intents that is 
-            //already provided by the policysets in the destination and do not 
copy them.
-            for ( PolicySet policySet : sourceList ) {
-                for ( Intent sourceProvidedIntent : 
policySet.getProvidedIntents() ) {
-                    if ( !targetProvidedIntents.contains(sourceProvidedIntent) 
) {
-                        targetList.add(policySet);
-                    }
-                }
-            }
-        } else {
-            targetList.addAll(sourceList);
-        }
-    }
-
-    private void addInheritedOperationConfigurations(OperationsConfigurator 
source, OperationsConfigurator target) {
+    private void addInheritedOperationConfigurations(OperationsConfigurator 
source, 
+                                                     OperationsConfigurator 
target) {
         boolean found = false;
         
         List<ConfiguredOperation> additionalOperations = new 
ArrayList<ConfiguredOperation>();
         for ( ConfiguredOperation sourceConfOp : 
source.getConfiguredOperations() ) {
             for ( ConfiguredOperation targetConfOp : 
target.getConfiguredOperations() ) {
                 if ( sourceConfOp.getName().equals(targetConfOp.getName())) {
-                    addInheritedIntents(sourceConfOp.getRequiredIntents(), 
targetConfOp.getRequiredIntents());
-                    addInheritedPolicySets(sourceConfOp.getPolicySets(), 
targetConfOp.getPolicySets(), true);
+                    
PolicyComputationUtils.addInheritedIntents(sourceConfOp.getRequiredIntents(), 
+                                                               
targetConfOp.getRequiredIntents());
+                    
PolicyComputationUtils.addInheritedPolicySets(sourceConfOp.getPolicySets(), 
+                                                                  
targetConfOp.getPolicySets(), true);
                     found = true;
                     break;
                 }
@@ -1049,11 +1020,4 @@
         }
     }
     
-    private void addInheritedOpConfOnBindings(Contract contract) {      
-        for ( Binding binding : contract.getBindings() ) {
-            if ( binding instanceof OperationsConfigurator ) {
-                addInheritedOperationConfigurations(contract, 
(OperationsConfigurator)binding);
-            }
-        }
-    }
 }

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=636290&r1=636289&r2=636290&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
 Wed Mar 12 05:09:58 2008
@@ -58,8 +58,7 @@
                                         parent.getRequiredIntents());
             
             
-            List<PolicySet> prunedPolicySets = 
computeInheritablePolicySets(policiedImplementation, 
-                                                                            
parent.getPolicySets(),
+            List<PolicySet> prunedPolicySets = 
computeInheritablePolicySets(parent.getPolicySets(),
                                                                             
parent.getApplicablePolicySets());
             parent.getPolicySets().clear();
             parent.getPolicySets().addAll(prunedPolicySets);

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=636290&r1=636289&r2=636290&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
 Wed Mar 12 05:09:58 2008
@@ -167,8 +167,7 @@
         }
     }
     
-    protected List<PolicySet> 
computeInheritablePolicySets(PolicySetAttachPoint policySetAttachPoint,
-                                                           List<PolicySet> 
inheritablePolicySets,
+    protected List<PolicySet> computeInheritablePolicySets(List<PolicySet> 
inheritablePolicySets,
                                                            List<PolicySet> 
applicablePolicySets) 
                                                                throws 
PolicyValidationException {
         List<PolicySet> validInheritablePolicySets = new 
ArrayList<PolicySet>();

Modified: 
incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/sca/implementation/java/xml/ReadTestCase.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/sca/implementation/java/xml/ReadTestCase.java?rev=636290&r1=636289&r2=636290&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/sca/implementation/java/xml/ReadTestCase.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/sca/implementation/java/xml/ReadTestCase.java
 Wed Mar 12 05:09:58 2008
@@ -110,7 +110,7 @@
         mapper = null;
     }
 
-    public void stestReadComposite() throws Exception {
+    public void testReadComposite() throws Exception {
         CompositeProcessor compositeProcessor = new CompositeProcessor(new 
DefaultContributionFactory(), assemblyFactory, policyFactory, staxProcessor);
         InputStream is = 
getClass().getResourceAsStream("Calculator.composite");
         XMLStreamReader reader = inputFactory.createXMLStreamReader(is);

Modified: 
incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions.xml
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions.xml?rev=636290&r1=636289&r2=636290&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions.xml
 (original)
+++ 
incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions.xml
 Wed Mar 12 05:09:58 2008
@@ -83,4 +83,18 @@
  <sca:intent name="tuscanyIntent_2.qualified" />
  <sca:intent name="tuscanyIntent_6.qualified1" />
  <sca:intent name="tuscanyIntent_6.qualified2" />
+ 
+ <sca:policySet name="tuscanyPolicySet_4"
+       provides="tuscanyIntent_6"
+       appliesTo="/sca:composite/sca:component"
+       xmlns="http://test";
+       xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy";>
+       <sca:intentMap provides="tuscanyIntent_6" default="qualified2">
+        <sca:qualifier name="qualified2">
+            <wsp:Policy>
+                <!-- policy expression and policy subject for "qualified2" 
alternative" -->
+            </wsp:Policy>
+        </sca:qualifier>
+    </sca:intentMap>
+ </sca:policySet>
 </sca:definitions>

Modified: 
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationUtils.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationUtils.java?rev=636290&r1=636289&r2=636290&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationUtils.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationUtils.java
 Wed Mar 12 05:09:58 2008
@@ -72,23 +72,33 @@
 
     public static void validatePolicySets(PolicySetAttachPoint 
policySetAttachPoint)
         throws PolicyValidationException {
-        validatePolicySets(policySetAttachPoint, 
policySetAttachPoint.getApplicablePolicySets());
+        validatePolicySets(policySetAttachPoint, 
+                           policySetAttachPoint.getType(),
+                           policySetAttachPoint.getApplicablePolicySets());
+    }
+    
+    public static void validatePolicySets(PolicySetAttachPoint 
policySetAttachPoint,
+                                          IntentAttachPointType 
attachPointType)
+        throws PolicyValidationException {
+        validatePolicySets(policySetAttachPoint,
+                           attachPointType,
+                           policySetAttachPoint.getApplicablePolicySets());
     }
 
     public static void validatePolicySets(PolicySetAttachPoint 
policySetAttachPoint,
-                                      List<PolicySet> applicablePolicySets)
+                                          IntentAttachPointType 
attachPointType,
+                                          List<PolicySet> applicablePolicySets)
         throws PolicyValidationException {
         // Since the applicablePolicySets in a policySetAttachPoint will 
already
         // have the list of policysets that might ever be applicable to this 
attachPoint,
         // just check if the defined policysets feature in the list of 
applicable
         // policysets
-        IntentAttachPointType attachPointType = policySetAttachPoint.getType();
         for (PolicySet definedPolicySet : 
policySetAttachPoint.getPolicySets()) {
             if (!definedPolicySet.isUnresolved()) {
                 if (!applicablePolicySets.contains(definedPolicySet)) {
                     throw new PolicyValidationException("Policy Set '" + 
definedPolicySet
                         .getName()
-                        + "' does not apply to binding type  "
+                        + "' does not apply to extension type  "
                         + attachPointType.getName());
                 }
             } else {



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to