tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r827880 - in /tuscany/java/sca: modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java otest/newlayout/tuscany-test-runner/src/test/resources/tuscany-oasis-sca-tests-errors.properties
Date Wed, 21 Oct 2009 03:28:52 GMT
Author: rfeng
Date: Wed Oct 21 03:28:51 2009
New Revision: 827880

URL: http://svn.apache.org/viewvc?rev=827880&view=rev
Log:
Fix for ASM_6031, ASM_6032

Modified:
    tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java
    tuscany/java/sca/otest/newlayout/tuscany-test-runner/src/test/resources/tuscany-oasis-sca-tests-errors.properties

Modified: tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java?rev=827880&r1=827879&r2=827880&view=diff
==============================================================================
--- tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java
(original)
+++ tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java
Wed Oct 21 03:28:51 2009
@@ -21,6 +21,7 @@
 
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 
 import javax.xml.namespace.QName;
@@ -66,11 +67,9 @@
         return "org.apache.tuscany.sca.assembly.builder.CompositePolicyBuilder";
     }
 
-    public Composite build(Composite composite, BuilderContext context)
-        throws CompositeBuilderException {
-        Definitions definitions = context.getDefinitions();
-        computePolicies(composite, definitions, context);
-        buildPolicies(composite, definitions, context);
+    public Composite build(Composite composite, BuilderContext context) throws CompositeBuilderException
{
+        computePolicies(composite, context);
+        buildPolicies(composite, context);
         return composite;
     }
 
@@ -103,7 +102,7 @@
             return false;
         }
         for (Intent i1 : subject1.getRequiredIntents()) {
-            for (Intent i2 : subject1.getRequiredIntents()) {
+            for (Intent i2 : subject2.getRequiredIntents()) {
                 if (i1.getExcludedIntents().contains(i2) || i2.getExcludedIntents().contains(i1))
{
                     error(context.getMonitor(), "MutuallyExclusiveIntents", new Object[]
{subject1, subject2}, i1, i2);
                     return true;
@@ -112,15 +111,19 @@
         }
         return false;
     }
-    
-    private boolean checkMutualExclusion(PolicySubject subject, BuilderContext context) {
+
+    private boolean resolveAndCheck(PolicySubject subject, BuilderContext context) {
         if (subject == null) {
             return false;
         }
-        // FIXME: [rfeng] When should the intents be resolved?
-        resolveAndNormalize(subject, context.getDefinitions(), context);
-        for (Intent i1 : subject.getRequiredIntents()) {
-            for (Intent i2 : subject.getRequiredIntents()) {
+        // FIXME: [rfeng] Should we resolve the intents during the "build" phase?
+        resolveAndNormalize(subject, context);
+        List<Intent> intents = subject.getRequiredIntents();
+        int size = intents.size();
+        for (int i = 0; i < size; i++) {
+            for (int j = i + 1; j < size; j++) {
+                Intent i1 = intents.get(i);
+                Intent i2 = intents.get(j);
                 if (i1 != i2 && i1.getExcludedIntents().contains(i2) || i2.getExcludedIntents().contains(i1))
{
                     error(context.getMonitor(), "MutuallyExclusiveIntents", subject, i1,
i2);
                     return true;
@@ -224,8 +227,8 @@
         return null;
     }
 
-    private void resolveAndNormalize(PolicySubject subject, Definitions definitions, BuilderContext
context) {
-
+    private void resolveAndNormalize(PolicySubject subject, BuilderContext context) {
+        Definitions definitions = context.getDefinitions();
         Set<Intent> intents = new HashSet<Intent>();
         if (definitions != null) {
             for (Intent i : subject.getRequiredIntents()) {
@@ -314,34 +317,47 @@
 
     }
 
-    protected void computePolicies(Composite composite, Definitions definitions, BuilderContext
context) {
-        checkMutualExclusion(composite, context);
-        
-        // compute policies recursively
-        for (Component component : composite.getComponents()) {
-            Implementation implementation = component.getImplementation();
-            if (implementation instanceof Composite) {
-                computePolicies((Composite)implementation, definitions, context);
+    protected void computePolicies(Composite composite, BuilderContext context) {
+        resolveAndCheck(composite, context);
+
+        for (Service service : composite.getServices()) {
+            CompositeService compositeService = (CompositeService)service;
+            checkMutualExclusion(compositeService, compositeService.getPromotedService(),
context);
+        }
+
+        for (Reference reference : composite.getReferences()) {
+            CompositeReference compositeReference = (CompositeReference)reference;
+            for (Reference promoted : compositeReference.getPromotedReferences()) {
+                checkMutualExclusion(compositeReference, promoted, context);
             }
         }
 
+        // compute policies recursively
         for (Component component : composite.getComponents()) {
-            checkMutualExclusion(component, context);
-            checkMutualExclusion(component.getImplementation(), context);
-            
+            Implementation implementation = component.getImplementation();
+            resolveAndCheck(component, context);
+
             // Check component against implementation
             checkMutualExclusion(component, component.getImplementation(), context);
 
             for (ComponentService componentService : component.getServices()) {
-                checkMutualExclusion(componentService, context);
-                checkMutualExclusion(componentService.getService(), context);
+                resolveAndCheck(componentService, context);
+                resolveAndCheck(componentService.getService(), context);
 
                 // Check component/service against componentType/service 
                 checkMutualExclusion(componentService, componentService.getService(), context);
 
                 if (componentService.getInterfaceContract() != null && componentService.getService()
!= null) {
+                    resolveAndCheck(componentService.getInterfaceContract().getInterface(),
context);
+                    resolveAndCheck(componentService.getService().getInterfaceContract().getInterface(),
context);
+
                     checkMutualExclusion(componentService.getInterfaceContract().getInterface(),
componentService
                         .getService().getInterfaceContract().getInterface(), context);
+
+                    resolveAndCheck(componentService.getInterfaceContract().getCallbackInterface(),
context);
+                    resolveAndCheck(componentService.getService().getInterfaceContract().getCallbackInterface(),
+                                    context);
+
                     checkMutualExclusion(componentService.getInterfaceContract().getCallbackInterface(),
                                          componentService.getService().getInterfaceContract().getCallbackInterface(),
                                          context);
@@ -361,7 +377,7 @@
                     // Find the corresponding binding in the componentType and inherit the
intents/policySets
                     if (componentService.getService() != null) {
                         for (Binding binding : componentService.getService().getBindings())
{
-                            checkMutualExclusion((PolicySubject) binding, context);
+                            resolveAndCheck((PolicySubject)binding, context);
                             if (isEqual(ep.getBinding().getName(), binding.getName()) &&
(binding instanceof PolicySubject)) {
                                 checkMutualExclusion((PolicySubject)ep.getBinding(), (PolicySubject)binding,
context);
                                 // Inherit from componentType.service.binding
@@ -379,20 +395,28 @@
                     // Remove the intents whose @contraints do not include the current element
                     // Replace unqualified intents if there is a qualified intent in the
list
                     // Replace qualifiable intents with the default qualied intent
-                    resolveAndNormalize(ep, definitions, context);
+                    resolveAndNormalize(ep, context);
                 }
             }
 
             for (ComponentReference componentReference : component.getReferences()) {
-                checkMutualExclusion(componentReference, context);
-                checkMutualExclusion(componentReference.getReference(), context);
+                resolveAndCheck(componentReference, context);
+                resolveAndCheck(componentReference.getReference(), context);
 
                 // Check component/reference against componentType/reference
                 checkMutualExclusion(componentReference, componentReference.getReference(),
context);
 
                 if (componentReference.getInterfaceContract() != null && componentReference.getReference()
!= null) {
+                    resolveAndCheck(componentReference.getInterfaceContract().getInterface(),
context);
+                    resolveAndCheck(componentReference.getReference().getInterfaceContract().getInterface(),
context);
+
                     checkMutualExclusion(componentReference.getInterfaceContract().getInterface(),
componentReference
                         .getReference().getInterfaceContract().getInterface(), context);
+
+                    resolveAndCheck(componentReference.getInterfaceContract().getCallbackInterface(),
context);
+                    resolveAndCheck(componentReference.getReference().getInterfaceContract().getCallbackInterface(),
+                                    context);
+
                     checkMutualExclusion(componentReference.getInterfaceContract().getCallbackInterface(),
                                          componentReference.getReference().getInterfaceContract()
                                              .getCallbackInterface(),
@@ -416,7 +440,7 @@
                         for (Binding binding : componentReference.getReference().getBindings())
{
                             if (epr.getBinding() != null && isEqual(epr.getBinding().getName(),
binding.getName())
                                 && (binding instanceof PolicySubject)) {
-                                checkMutualExclusion((PolicySubject) binding, context);
+                                resolveAndCheck((PolicySubject)binding, context);
                                 checkMutualExclusion((PolicySubject)epr.getBinding(), (PolicySubject)binding,
context);
                                 // Inherit from componentType.reference.binding
                                 inherit(epr, binding);
@@ -432,18 +456,23 @@
                     // Remove the intents whose @contraints do not include the current element
                     // Replace unqualified intents if there is a qualified intent in the
list
                     // Replace qualifiable intents with the default qualied intent
-                    resolveAndNormalize(epr, definitions, context);
+                    resolveAndNormalize(epr, context);
                 }
             }
-
-            Implementation implementation = component.getImplementation();
-            if (implementation != null) {
+            
+            if (implementation instanceof Composite) {
                 inherit(implementation, component, composite);
+                computePolicies((Composite)implementation, context);
+            } else {
+                resolveAndCheck(implementation, context);
+                if (implementation != null) {
+                    inherit(implementation, component, composite);
+                }
             }
-            // How to deal with implementation level policySets/intents
         }
+
     }
-    
+
     private Set<QName> getPolicyNames(PolicySubject subject) {
         if (subject == null) {
             return Collections.emptySet();
@@ -456,14 +485,14 @@
         }
         return names;
     }
-    
-    protected void buildPolicies(Composite composite, Definitions definitions, BuilderContext
context) {
+
+    protected void buildPolicies(Composite composite, BuilderContext context) {
 
         // compute policies recursively
         for (Component component : composite.getComponents()) {
             Implementation implementation = component.getImplementation();
             if (implementation instanceof Composite) {
-                buildPolicies((Composite)implementation, definitions, context);
+                buildPolicies((Composite)implementation, context);
             }
         }
 

Modified: tuscany/java/sca/otest/newlayout/tuscany-test-runner/src/test/resources/tuscany-oasis-sca-tests-errors.properties
URL: http://svn.apache.org/viewvc/tuscany/java/sca/otest/newlayout/tuscany-test-runner/src/test/resources/tuscany-oasis-sca-tests-errors.properties?rev=827880&r1=827879&r2=827880&view=diff
==============================================================================
--- tuscany/java/sca/otest/newlayout/tuscany-test-runner/src/test/resources/tuscany-oasis-sca-tests-errors.properties
(original)
+++ tuscany/java/sca/otest/newlayout/tuscany-test-runner/src/test/resources/tuscany-oasis-sca-tests-errors.properties
Wed Oct 21 03:28:51 2009
@@ -44,7 +44,7 @@
 ASM_6006=org.oasisopen.sca.ServiceRuntimeException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200903},
Component: TestComponent1, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite20]
- Promoted component reference not found: Composite = {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite20
Reference = Composite20Componentz/Reference1
 ASM_6008=org.oasisopen.sca.ServiceRuntimeException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200903},
Component: TEST_ASM_6008Component1, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite22]
- Interface of composite reference Reference1 must be compatible with the interface declared
by promoted component reference. Operation not found on target
 ASM_6012=org.oasisopen.sca.ServiceRuntimeException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200903},
Component: TEST_ASM_6012TestComponent1] - Duplicate property name: Component = TEST_ASM_6012TestComponent1
Property = propertyName
-ASM_6016=Needs policy matching 
+ASM_6016=Need Policy Check
 ASM_6020=org.oasisopen.sca.ServiceRuntimeException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200903},
Component: TestComponent1, Reference: Reference1] - No target services found for the component
reference to be autowired: Reference1
 ASM_6021=org.oasisopen.sca.ServiceRuntimeException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200903},
Component: TEST_ASM_6021TestComponent1, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite31]
- Promoted component service not found: Composite = {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite31
Service = Not_A_URI_of_a_Component
 ASM_6022=org.oasisopen.sca.ServiceRuntimeException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200903},
Component: TestComponent1, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite32,
Component: TestComponent1] - No targets for reference: Composite = {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite32
Reference = Reference1
@@ -54,8 +54,8 @@
 ASM_6028=org.apache.tuscany.sca.contribution.processor.ContributionReadException: Error:
property has both @type and @element attribute values - InvalidProperty
 ASM_6029=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: Error:
Composite {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TEST_ASM_6029 can only include
another composite with the identical @local attribute value
 ASM_6030=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: Error:
Composite {http://docs.oasis-open.org/ns/opencsa/scatests/200903}Invalid_composite_name is
not a valid composite within the domain
-ASM_6031=Needs policy matching
-ASM_6032=Needs policy matching
+ASM_6031=[POL40009] Intent {http://docs.oasis-open.org/ns/opencsa/sca/200903}suspendsTransaction
and {http://docs.oasis-open.org/ns/opencsa/sca/200903}propagatesTransaction are mutually exclusive
+ASM_6032=[POL40009] Intent {http://docs.oasis-open.org/ns/opencsa/sca/200903}propagatesTransaction
and {http://docs.oasis-open.org/ns/opencsa/sca/200903}suspendsTransaction are mutually exclusive
 ASM_6033=Looks right but need to check what the wording of the error message should be
 ASM_8001=TODO
 ASM_8004=org.apache.tuscany.sca.interfacedef.InvalidCallbackException: Callback org.oasisopen.sca.test.Service6Callback
must be remotable on remotable interface org.oasisopen.sca.test.Service6



Mime
View raw message