You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2007/04/13 01:06:05 UTC
svn commit: r528280 - in
/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/util:
CompositeUtil.java ReferenceUtil.java
Author: jsdelfino
Date: Thu Apr 12 16:06:05 2007
New Revision: 528280
URL: http://svn.apache.org/viewvc?view=rev&rev=528280
Log:
Fixed algorithm checking that references are either wired or promoted. This needed to move to the wiring phase as references can be wired by standalone wires, not necessarily inlined in the reference itself.
Modified:
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/util/CompositeUtil.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/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=528280&r1=528279&r2=528280
==============================================================================
--- 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 Thu Apr 12 16:06:05 2007
@@ -20,8 +20,10 @@
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.tuscany.assembly.AssemblyFactory;
import org.apache.tuscany.assembly.Base;
@@ -62,10 +64,8 @@
public void configure(List<Base> problems) {
if (problems == null) {
problems = new ArrayList<Base>() {
-
- //FIXME Print problems to help with debugging, will need to
- // hook this with monitoring later
-
+ private static final long serialVersionUID = 4819831446590718923L;
+
@Override
public boolean add(Base o) {
System.err.println("Composite configuration problem:");
@@ -74,7 +74,7 @@
}
};
}
- init(problems);
+ initialize(problems);
wire(problems);
}
@@ -85,7 +85,7 @@
}
}
- private void initializePropsSvcRefs(Component component,
+ private void initializePropertiesServicesAndReferences(Component component,
Map<String, Service> implServices,
Map<String, Reference> implReferences,
Map<String, Property> implProperties,
@@ -177,10 +177,6 @@
componentReference.getTargets().addAll(reference.getTargets());
componentReference.setInterfaceContract(reference.getInterfaceContract());
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) {
@@ -205,12 +201,7 @@
if (compRef.getTargets().isEmpty()) {
compRef.getTargets().addAll(reference.getTargets());
- if (!ReferenceUtil.validateMultiplicityAndTargets(compRef.getMultiplicity(),
- compRef.getTargets())) {
- problems.add(compRef);
- }
}
-
}
}
}
@@ -245,7 +236,7 @@
}
}
- private void init(List<Base> problems) {
+ private void initialize(List<Base> problems) {
Map<String, Service> implServices = null;
Map<String, Reference> implReferences = null;
Map<String, Property> implProperties = null;
@@ -275,7 +266,7 @@
problems.add(implementation);
}
- initializePropsSvcRefs(component,
+ initializePropertiesServicesAndReferences(component,
implServices,
implReferences,
implProperties,
@@ -297,6 +288,7 @@
// Index and bind all component services and references
Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>();
Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>();
+ Set<ComponentReference> promotedComponentReferences = new HashSet<ComponentReference>();
for (Component component : composite.getComponents()) {
int i =0;
@@ -356,6 +348,7 @@
componentReferences.get(componentReference.getName());
if (resolved != null) {
promotedReferences.set(i, resolved);
+ promotedComponentReferences.add(resolved);
} else {
problems.add(compositeReference);
}
@@ -431,6 +424,19 @@
}
}
+
+ // Validate that references are wired or promoted, according
+ // to their multiplicity
+ for (ComponentReference componentReference : componentReferences.values()) {
+ boolean promoted = promotedComponentReferences.contains(componentReference);
+ if (!ReferenceUtil.validateMultiplicityAndTargets(
+ componentReference.getMultiplicity(),
+ componentReference.getTargets(),
+ promoted)) {
+ problems.add(componentReference);
+ }
+ }
+
// Clear wires
composite.getWires().clear();
}
Modified: 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=diff&rev=528280&r1=528279&r2=528280
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/util/ReferenceUtil.java (original)
+++ incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/util/ReferenceUtil.java Thu Apr 12 16:06:05 2007
@@ -43,8 +43,19 @@
}
public static boolean validateMultiplicityAndTargets(Multiplicity multiplicity,
- List<?> targets) {
+ List<?> targets, boolean promoted) {
+
+ // Count targets
int count = targets.size();
+ if (promoted) {
+ if (count == 0) {
+ // A promoted reference counts as one target
+ count = 1;
+ } else {
+ // A reference cannot be promoted and wired at the same time
+ return false;
+ }
+ }
switch (multiplicity) {
case ZERO_N:
break;
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org