tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdan...@apache.org
Subject svn commit: r964064 - in /tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl: ComponentPolicyBuilderImpl.java CompositePolicyBuilderImpl.java
Date Wed, 14 Jul 2010 14:42:16 GMT
Author: bdaniel
Date: Wed Jul 14 14:42:16 2010
New Revision: 964064

URL: http://svn.apache.org/viewvc?rev=964064&view=rev
Log:
Ignore direct policy sets when external policy sets are attached

Modified:
    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/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java

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=964064&r1=964063&r2=964064&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
Wed Jul 14 14:42:16 2010
@@ -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());
             }
         }
     }

Modified: tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java?rev=964064&r1=964063&r2=964064&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java
Wed Jul 14 14:42:16 2010
@@ -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.b
 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 
                                 // 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 
                                 // 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 
                             // 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 
         }
     }
     
-    /**
+    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
      * 



Mime
View raw message