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 2007/04/10 21:52:10 UTC

svn commit: r527264 - in /incubator/tuscany/java/sca/modules/assembly/src: main/java/org/apache/tuscany/assembly/ main/java/org/apache/tuscany/assembly/impl/ main/java/org/apache/tuscany/assembly/util/ test/java/org/apache/tuscany/assembly/

Author: svkrish
Date: Tue Apr 10 12:52:09 2007
New Revision: 527264

URL: http://svn.apache.org/viewvc?view=rev&rev=527264
Log:
minor changes to Property structure and additions to Utils, refactoring of code in CompositeUtil and enhancements to 'wire' phase logic (in progress)

Added:
    incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/util/InterfaceUtil.java
    incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/util/ReferenceUtil.java
Modified:
    incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/AbstractProperty.java
    incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/ComponentProperty.java
    incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/impl/AbstractPropertyImpl.java
    incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/impl/ComponentPropertyImpl.java
    incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/util/CompositeUtil.java
    incubator/tuscany/java/sca/modules/assembly/src/test/java/org/apache/tuscany/assembly/AssemblyFactoryTestCase.java
    incubator/tuscany/java/sca/modules/assembly/src/test/java/org/apache/tuscany/assembly/TestImplementation.java

Modified: incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/AbstractProperty.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/AbstractProperty.java?view=diff&rev=527264&r1=527263&r2=527264
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/AbstractProperty.java (original)
+++ incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/AbstractProperty.java Tue Apr 10 12:52:09 2007
@@ -49,14 +49,14 @@
      * 
      * @return the default value of ths property
      */
-    Object getDefaultValue();
+    Object getValue();
 
     /**
      * Sets the default value of the property.
      * 
      * @param defaultValue the default value of ths property
      */
-    void setDefaultValue(Object defaultValue);
+    void setValue(Object defaultValue);
 
     /**
      * Returns true if the property allows multiple values.

Modified: incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/ComponentProperty.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/ComponentProperty.java?view=diff&rev=527264&r1=527263&r2=527264
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/ComponentProperty.java (original)
+++ incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/ComponentProperty.java Tue Apr 10 12:52:09 2007
@@ -70,5 +70,4 @@
      * @param file a URI to a file containing the property value
      */
     void setFile(String file);
-
 }

Modified: incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/impl/AbstractPropertyImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/impl/AbstractPropertyImpl.java?view=diff&rev=527264&r1=527263&r2=527264
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/impl/AbstractPropertyImpl.java (original)
+++ incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/impl/AbstractPropertyImpl.java Tue Apr 10 12:52:09 2007
@@ -33,7 +33,7 @@
  * @version $Rev$ $Date$
  */
 public class AbstractPropertyImpl extends BaseImpl implements AbstractProperty {
-    private Object defaultValue;
+    private Object value;
     private String name;
     private QName xsdType;
     private QName xsdElement;
@@ -53,7 +53,7 @@
      */
     public AbstractPropertyImpl(AbstractProperty other) {
         super(other);
-        defaultValue = other.getDefaultValue();
+        value = other.getValue();
         many = other.isMany();
         mustSupply = other.isMustSupply();
         name = other.getName();
@@ -62,8 +62,8 @@
         requiredIntents.addAll(other.getRequiredIntents());
     }
 
-    public Object getDefaultValue() {
-        return defaultValue;
+    public Object getValue() {
+        return value;
     }
 
     public String getName() {
@@ -86,8 +86,8 @@
         return mustSupply;
     }
 
-    public void setDefaultValue(Object defaultValue) {
-        this.defaultValue = defaultValue;
+    public void setValue(Object defaultValue) {
+        this.value = defaultValue;
     }
 
     public void setMany(boolean many) {

Modified: incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/impl/ComponentPropertyImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/impl/ComponentPropertyImpl.java?view=diff&rev=527264&r1=527263&r2=527264
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/impl/ComponentPropertyImpl.java (original)
+++ incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/impl/ComponentPropertyImpl.java Tue Apr 10 12:52:09 2007
@@ -32,6 +32,14 @@
     private Property property;
     private String source;
 
+    public Object getValue() {
+        if (super.getValue() == null && property != null) {
+            return property.getValue();
+        } else {
+            return super.getValue();
+        }
+    }
+ 
     /**
      * Constructs a new component property.
      */

Modified: incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/util/CompositeUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/util/CompositeUtil.java?view=diff&rev=527264&r1=527263&r2=527264
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/util/CompositeUtil.java (original)
+++ incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/util/CompositeUtil.java Tue Apr 10 12:52:09 2007
@@ -26,12 +26,14 @@
 import org.apache.tuscany.assembly.AssemblyFactory;
 import org.apache.tuscany.assembly.Base;
 import org.apache.tuscany.assembly.Component;
+import org.apache.tuscany.assembly.ComponentProperty;
 import org.apache.tuscany.assembly.ComponentReference;
 import org.apache.tuscany.assembly.ComponentService;
 import org.apache.tuscany.assembly.Composite;
 import org.apache.tuscany.assembly.CompositeReference;
 import org.apache.tuscany.assembly.CompositeService;
 import org.apache.tuscany.assembly.Implementation;
+import org.apache.tuscany.assembly.Property;
 import org.apache.tuscany.assembly.Reference;
 import org.apache.tuscany.assembly.SCABinding;
 import org.apache.tuscany.assembly.Service;
@@ -66,18 +68,47 @@
     }
 
     private void collectIncludes(Composite composite, List<Composite> includes) {
-        for (Composite include: composite.getIncludes()) {
+        for (Composite include : composite.getIncludes()) {
             includes.add(include);
             collectIncludes(include, includes);
         }
     }
-    
-    private void init(List<Base> problems) {
-        
-        // Bring includes in
-        List<Composite> includes = new ArrayList<Composite>();
-        collectIncludes(composite, includes);
-        for (Composite include: includes) {
+
+    private void initializePropsSvcRefs(Component component,
+                                        Map<String, Service> implServices,
+                                        Map<String, Reference> implReferences,
+                                        Map<String, Property> implProperties,
+                                        Map<String, ComponentService> compServices,
+                                        Map<String, ComponentReference> compReferences,
+                                        Map<String, ComponentProperty> compProperties) {
+        // Index services and references
+        Implementation implementation = component.getImplementation();
+        if (implementation != null) {
+            for (Service service : implementation.getServices()) {
+                implServices.put(service.getName(), service);
+            }
+            for (Reference reference : implementation.getReferences()) {
+                implReferences.put(reference.getName(), reference);
+            }
+            for (Property property : implementation.getProperties()) {
+                implProperties.put(property.getName(), property);
+            }
+        }
+
+        for (ComponentService componentService : component.getServices()) {
+            compServices.put(componentService.getName(), componentService);
+        }
+        for (ComponentReference componentReference : component.getReferences()) {
+            compReferences.put(componentReference.getName(), componentReference);
+        }
+        for (ComponentProperty componentProperty : component.getProperties()) {
+            compProperties.put(componentProperty.getName(), componentProperty);
+        }
+
+    }
+
+    private void fuseIncludes(Composite composite, List<Composite> includes) {
+        for (Composite include : includes) {
             include = include.copy();
             composite.getComponents().addAll(include.getComponents());
             composite.getServices().addAll(include.getServices());
@@ -88,91 +119,175 @@
             composite.getRequiredIntents().addAll(include.getRequiredIntents());
         }
         composite.getIncludes().clear();
+    }
 
-        // Init all component services and references
-        for (Component component : composite.getComponents()) {
-            Map<String, Service> services = new HashMap<String, Service>();
-            Map<String, Reference> references = new HashMap<String, Reference>();
-
-            // Index services and references
-            Implementation implementation = component.getImplementation();
-            if (implementation != null) {
-                for (Service service : implementation.getServices()) {
-                    services.put(service.getName(), service);
-                }
-                for (Reference reference : implementation.getReferences()) {
-                    references.put(reference.getName(), reference);
-                }
+    private void reconcileComponentServices(Component component,
+                                            Map<String, Service> implServices,
+                                            Map<String, ComponentService> compServices,
+                                            List<Base> problems) {
+        for (ComponentService componentService : compServices.values()) {
+            Service service = implServices.get(componentService.getName());
+            if (service != null) {
+                componentService.setService(service);
+            } else {
+                problems.add(componentService);
             }
+        }
 
-            // Index component services and references
-            Map<String, ComponentService> cservices = new HashMap<String, ComponentService>();
-            Map<String, ComponentReference> creferences = new HashMap<String, ComponentReference>();
-            for (ComponentService componentService : component.getServices()) {
-                cservices.put(componentService.getName(), componentService);
+        for (Service service : implServices.values()) {
+            if (!compServices.containsKey(service.getName())) {
+                ComponentService componentService = assemblyFactory.createComponentService();
+                componentService.setName(service.getName());
+                componentService.setService(service);
+                component.getServices().add(componentService);
             }
-            for (ComponentReference componentReference : component.getReferences()) {
-                creferences.put(componentReference.getName(), componentReference);
+        }
+    }
+
+    private void reconcileComponentReferences(Component component,
+                                              Map<String, Reference> implReferences,
+                                              Map<String, ComponentReference> compReferences,
+                                              List<Base> problems) {
+        for (ComponentReference componentReference : compReferences.values()) {
+            Reference reference = implReferences.get(componentReference.getName());
+            if (reference != null) {
+                componentReference.setReference(reference);
+            } else {
+                problems.add(componentReference);
             }
+        }
 
-            // Reconcile component services/references and implementation
-            // services/references
-            for (ComponentService componentService : cservices.values()) {
-                Service service = services.get(componentService.getName());
-                if (service != null) {
-                    componentService.setService(service);
+        for (Reference reference : implReferences.values()) {
+            if (!compReferences.containsKey(reference.getName())) {
+                ComponentReference componentReference = assemblyFactory.createComponentReference();
+                componentReference.setName(reference.getName());
+                componentReference.setReference(reference);
+                componentReference.setMultiplicity(reference.getMultiplicity());
+                componentReference.getTargets().addAll(reference.getTargets());
+                componentReference.setInterface(reference.getInterface());
+                component.getReferences().add(componentReference);
+                if (!ReferenceUtil.validateMultiplicityAndTargets(componentReference.getMultiplicity(), 
+                                                                  componentReference.getTargets())) {
+                     problems.add(componentReference);
+                 }
+            } else {
+                ComponentReference compRef = compReferences.get(reference.getName());
+                if (compRef.getMultiplicity() != null) {
+                    if (!ReferenceUtil.isValidMultiplicityOverride(reference.getMultiplicity(), 
+                                                                  compRef.getMultiplicity())) {
+                        problems.add(compRef);
+                    }
                 } else {
-                    problems.add(componentService);
+                    compRef.setMultiplicity(reference.getMultiplicity());
                 }
-            }
-            for (ComponentReference componentReference : creferences.values()) {
-                Reference reference = references.get(componentReference.getName());
-                if (reference != null) {
-                    componentReference.setReference(reference);
+                
+                if (compRef.getInterface() != null) {
+                    if (!compRef.getInterface().equals(reference.getInterface())) {
+                        if (!InterfaceUtil.checkInterfaceCompatibility(reference.getInterface(), 
+                                                                       compRef.getInterface())) {
+                            problems.add(compRef);
+                        }
+                    }
                 } else {
-                    problems.add(componentReference);
+                    compRef.setInterface(reference.getInterface());
+                }
+                
+                if (compRef.getTargets().isEmpty()) {
+                    compRef.getTargets().addAll(reference.getTargets());
+                    if (!ReferenceUtil.validateMultiplicityAndTargets(compRef.getMultiplicity(), 
+                                                                     compRef.getTargets())) {
+                        problems.add(compRef);
+                    }
+                }
+                
+            }
+        }
+    }
+
+    private void reconcileComponentProperties(Component component,
+                                              Map<String, Property> implProperties,
+                                              Map<String, ComponentProperty> compProperties,
+                                              List<Base> problems) {
+        for (ComponentProperty componentProperty : compProperties.values()) {
+            Property property = implProperties.get(componentProperty.getName());
+            if (property != null) {
+                componentProperty.setProperty(property);
+                if (componentProperty.getValue() == null && property.isMustSupply()) {
+                    problems.add(componentProperty);
                 }
+            } else {
+                problems.add(componentProperty);
             }
+        }
 
-            // Create component services/references for the services/references
-            // declared by
-            // the implementation
-            for (Service service : services.values()) {
-                if (!cservices.containsKey(service.getName())) {
-                    ComponentService componentService = assemblyFactory.createComponentService();
-                    componentService.setName(service.getName());
-                    componentService.setService(service);
-                    component.getServices().add(componentService);
-                }
-            }
-            for (Reference reference : references.values()) {
-                if (!creferences.containsKey(reference.getName())) {
-                    ComponentReference componentReference = assemblyFactory.createComponentReference();
-                    componentReference.setName(reference.getName());
-                    componentReference.setReference(reference);
-                    component.getReferences().add(componentReference);
+        for (Property property : implProperties.values()) {
+            if (!compProperties.containsKey(property.getName())) {
+                if (!property.isMustSupply()) {
+                    ComponentProperty componentProperty = assemblyFactory.createComponentProperty();
+                    componentProperty.setName(property.getName());
+                    componentProperty.setProperty(property);
+                    component.getProperties().add(componentProperty);
+                } else {
+                    problems.add(property);
                 }
             }
         }
     }
 
+    private void init(List<Base> problems) {
+        Map<String, Service> implServices = null;
+        Map<String, Reference> implReferences = null;
+        Map<String, Property> implProperties = null;
+        Map<String, ComponentService> compServices = null;
+        Map<String, ComponentReference> compReferences = null;
+        Map<String, ComponentProperty> compProperties = null;
+
+        // Bring includes in
+        List<Composite> includes = new ArrayList<Composite>();
+        collectIncludes(composite, includes);
+        fuseIncludes(composite, includes);
+
+        // Init all component services and references
+        for (Component component : composite.getComponents()) {
+            implServices = new HashMap<String, Service>();
+            implReferences = new HashMap<String, Reference>();
+            implProperties = new HashMap<String, Property>();
+            compServices = new HashMap<String, ComponentService>();
+            compReferences = new HashMap<String, ComponentReference>();
+            compProperties = new HashMap<String, ComponentProperty>();
+
+            initializePropsSvcRefs(component,
+                                   implServices,
+                                   implReferences,
+                                   implProperties,
+                                   compServices,
+                                   compReferences,
+                                   compProperties);
+
+            // Reconcile component services/references/properties and implementation
+            // services/references and Create component services/references/properties
+            //for the services/references declared by the implementation
+            reconcileComponentServices(component, implServices, compServices, problems);
+            reconcileComponentReferences(component, implReferences, compReferences, problems);
+            reconcileComponentProperties(component, implProperties, compProperties, problems);
+        }
+    }
+
     private void wire(List<Base> problems) {
 
         // Index and bind all component services and references
         Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>();
-        Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>();
+        Map<String, ComponentReference> componentReferences =
+            new HashMap<String, ComponentReference>();
         for (Component component : composite.getComponents()) {
-            int i =0;
             for (ComponentService componentService : component.getServices()) {
-                
-                // Index services as component name / service name
-                String uri = component.getName() + '/' + componentService.getName();
-                componentServices.put(uri, componentService);
-                if (i ==0) {
-                    // Index the first service of a component as the component name
-                    componentServices.put(component.getName(), componentService);
+                String uri;
+                if (componentService.getName() != null) {
+                    uri = component.getName() + '/' + componentService.getName();
+                } else {
+                    uri = component.getName();
                 }
-                i++;
+                componentServices.put(uri, componentService);
 
                 // Create and configure an SCA binding for the service
                 SCABinding scaBinding = componentService.getBinding(SCABinding.class);
@@ -181,7 +296,6 @@
                     componentService.getBindings().add(scaBinding);
                 }
                 scaBinding.setURI(uri);
-                scaBinding.setComponent(component);
             }
             for (ComponentReference componentReference : component.getReferences()) {
                 String uri = component.getName() + '/' + componentReference.getName();
@@ -194,7 +308,6 @@
                     componentReference.getBindings().add(scaBinding);
                 }
                 scaBinding.setURI(uri);
-                scaBinding.setComponent(component);
             }
         }
 
@@ -213,11 +326,13 @@
         }
         for (Reference reference : composite.getReferences()) {
             CompositeReference compositeReference = (CompositeReference)reference;
-            List<ComponentReference> promotedReferences = compositeReference.getPromotedReferences();
+            List<ComponentReference> promotedReferences =
+                compositeReference.getPromotedReferences();
             for (int i = 0, n = promotedReferences.size(); i < n; i++) {
                 ComponentReference componentReference = promotedReferences.get(i);
                 if (componentReference.isUnresolved()) {
-                    ComponentReference resolved = componentReferences.get(componentReference.getName());
+                    ComponentReference resolved =
+                        componentReferences.get(componentReference.getName());
                     if (resolved != null) {
                         promotedReferences.set(i, resolved);
                     } else {
@@ -294,7 +409,7 @@
                 resolvedReference.getTargets().add(resolvedService);
             }
         }
-        
+
         // Clear wires
         composite.getWires().clear();
     }

Added: incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/util/InterfaceUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/util/InterfaceUtil.java?view=auto&rev=527264
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/util/InterfaceUtil.java (added)
+++ incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/util/InterfaceUtil.java Tue Apr 10 12:52:09 2007
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.assembly.util;
+
+import org.apache.tuscany.assembly.Contract;
+import org.apache.tuscany.interfacedef.Interface;
+import org.apache.tuscany.interfacedef.Operation;
+
+/**
+ * This class encapsulates utility methods to deal with Interface definitions
+ *
+ */
+public class InterfaceUtil {
+    public static boolean checkInterfaceCompatibility(Interface source,
+                                                      Interface target) {
+        boolean isCompatible = true;
+        if (source != target) {
+            //TODO : Fix comparisons of interaction scopes.
+            /*if (source.getInteractionScope() != target.getInteractionScope()) {
+            throw new IncompatibleOverridingServiceContractException(
+                                                           "Interaction scopes settings do not match",
+                                                           source, target);
+              }*/
+
+            Operation targetOperation = null;
+            for (Operation sourceOperation : source.getOperations()) {
+                for (Operation anOperation : target.getOperations()) {
+                    if (targetOperation.getName().equals(sourceOperation.getName())) {
+                        targetOperation = anOperation;
+                        break;
+                    }
+                }
+                if (targetOperation == null) {
+                    isCompatible = false;
+                } else if (!sourceOperation.equals(targetOperation)) {
+                    isCompatible = false;
+                }
+            }
+        }
+        return isCompatible;
+    }
+}

Added: incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/util/ReferenceUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/util/ReferenceUtil.java?view=auto&rev=527264
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/util/ReferenceUtil.java (added)
+++ incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/util/ReferenceUtil.java Tue Apr 10 12:52:09 2007
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.assembly.util;
+
+import java.util.List;
+
+import org.apache.tuscany.assembly.Multiplicity;
+
+/**
+ * This class encapsulates utility methods to deal with reference definitions
+ *
+ */
+public class ReferenceUtil {
+    public static boolean isValidMultiplicityOverride(Multiplicity definedMul, Multiplicity overridenMul) {
+        if (definedMul != overridenMul) {
+            switch (definedMul) {
+                case ZERO_N:
+                    return overridenMul == Multiplicity.ZERO_ONE;
+                case ONE_N:
+                    return overridenMul == Multiplicity.ONE_ONE;
+                default:
+                    return false;
+            }
+        } else {
+            return true;
+        }
+    }
+    
+    public static boolean validateMultiplicityAndTargets(Multiplicity multiplicity,
+                                                         List<?> targets) {
+        int count = targets.size();
+        switch (multiplicity) {
+            case ZERO_N:
+                break;
+            case ZERO_ONE:
+                if (count > 1) {
+                    return false;
+                }
+                break;
+            case ONE_ONE:
+                if (count != 1) {
+                    return false;
+                }
+                break;
+            case ONE_N:
+                if (count < 1) {
+                    return false;
+                }
+                break;
+        }
+        return true;
+    }
+}

Modified: incubator/tuscany/java/sca/modules/assembly/src/test/java/org/apache/tuscany/assembly/AssemblyFactoryTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/test/java/org/apache/tuscany/assembly/AssemblyFactoryTestCase.java?view=diff&rev=527264&r1=527263&r2=527264
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly/src/test/java/org/apache/tuscany/assembly/AssemblyFactoryTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/assembly/src/test/java/org/apache/tuscany/assembly/AssemblyFactoryTestCase.java Tue Apr 10 12:52:09 2007
@@ -105,7 +105,7 @@
 
         ComponentProperty p = factory.createComponentProperty();
         p.setName("currency");
-        p.setDefaultValue("USD");
+        p.setValue("USD");
         p.setMustSupply(true);
         p.setXSDType(new QName("", ""));
         p.setProperty(i.getProperties().get(0));
@@ -147,7 +147,7 @@
 
         Property p = factory.createProperty();
         p.setName("currency");
-        p.setDefaultValue("USD");
+        p.setValue("USD");
         p.setMustSupply(true);
         p.setXSDType(new QName("", ""));
         ctype.getProperties().add(p);
@@ -185,7 +185,7 @@
 
         AbstractProperty p = factory.createAbstractProperty();
         p.setName("currency");
-        p.setDefaultValue("USD");
+        p.setValue("USD");
         p.setMustSupply(true);
         p.setXSDType(new QName("", ""));
         ctype.getProperties().add(p);

Modified: incubator/tuscany/java/sca/modules/assembly/src/test/java/org/apache/tuscany/assembly/TestImplementation.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/test/java/org/apache/tuscany/assembly/TestImplementation.java?view=diff&rev=527264&r1=527263&r2=527264
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly/src/test/java/org/apache/tuscany/assembly/TestImplementation.java (original)
+++ incubator/tuscany/java/sca/modules/assembly/src/test/java/org/apache/tuscany/assembly/TestImplementation.java Tue Apr 10 12:52:09 2007
@@ -33,7 +33,7 @@
 
         Property p = factory.createProperty();
         p.setName("currency");
-        p.setDefaultValue("USD");
+        p.setValue("USD");
         p.setMustSupply(true);
         p.setXSDType(new QName("", ""));
         getProperties().add(p);



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org