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/27 07:36:04 UTC
svn commit: r532969 - in
/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/util:
CompositeUtil.java InterfaceUtil.java
Author: jsdelfino
Date: Thu Apr 26 22:36:03 2007
New Revision: 532969
URL: http://svn.apache.org/viewvc?view=rev&rev=532969
Log:
Added checks to match interfaces on references and target services.
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/InterfaceUtil.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=532969&r1=532968&r2=532969
==============================================================================
--- 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 26 22:36:03 2007
@@ -33,6 +33,7 @@
import org.apache.tuscany.assembly.CompositeReference;
import org.apache.tuscany.assembly.CompositeService;
import org.apache.tuscany.assembly.Implementation;
+import org.apache.tuscany.assembly.Multiplicity;
import org.apache.tuscany.assembly.Property;
import org.apache.tuscany.assembly.Reference;
import org.apache.tuscany.assembly.SCABinding;
@@ -61,7 +62,7 @@
}
public void configure(List<Base> problems) {
- if (problems == null) {
+ if (true || problems == null) {
problems = new ArrayList<Base>() {
private static final long serialVersionUID = 4819831446590718923L;
@@ -164,8 +165,8 @@
// Reconcile interface
if (componentService.getInterfaceContract() != null) {
if (!componentService.getInterfaceContract().equals(service.getInterfaceContract())) {
- if (!InterfaceUtil.checkInterfaceCompatibility(service.getInterfaceContract(),
- componentService.getInterfaceContract())) {
+ if (!InterfaceUtil.checkInterfaceCompatibility(componentService.getInterfaceContract(),
+ service.getInterfaceContract())) {
problems.add(componentService);
}
}
@@ -239,6 +240,11 @@
} else {
componentReference.setInterfaceContract(reference.getInterfaceContract());
}
+
+ // Propagate autowire setting from the component
+ if (component.isAutowire()) {
+ componentReference.setAutowire(true);
+ }
// Reconcile targets
if (componentReference.getTargets().isEmpty()) {
@@ -350,6 +356,11 @@
Map<String, Reference> references = new HashMap<String, Reference>();
Map<String, Property> properties = new HashMap<String, Property>();
+ // Propagate the autowire flag from the composite to components
+ if (composite.isAutowire()) {
+ component.setAutowire(true);
+ }
+
// Check that the component has a resolved implementation
Implementation implementation = component.getImplementation();
if (implementation == null) {
@@ -527,13 +538,45 @@
for (ComponentReference componentReference : componentReferences.values()) {
List<ComponentService> targets = componentReference.getTargets();
- if (!targets.isEmpty()) {
+
+ if (componentReference.isAutowire()) {
+
+ // Find suitable targets in the current composite for an autowired
+ // reference
+ Multiplicity multiplicity = componentReference.getMultiplicity();
+ for (Component component: composite.getComponents()) {
+ for (ComponentService componentService: component.getServices()) {
+ if (componentReference.getInterfaceContract() == null ||
+ InterfaceUtil.checkInterfaceCompatibility(componentReference.getInterfaceContract(),
+ componentService.getInterfaceContract())) {
+
+ targets.add(componentService);
+ if (multiplicity == Multiplicity.ZERO_ONE || multiplicity == Multiplicity.ONE_ONE) {
+ break;
+ }
+ }
+ }
+ }
+
+ } else if (!targets.isEmpty()) {
+
+ // Resolve targets specified on the component reference
for (int i = 0, n = targets.size(); i < n; i++) {
ComponentService target = targets.get(i);
if (target.isUnresolved()) {
ComponentService resolved = componentServices.get(target.getName());
if (resolved != null) {
- targets.set(i, resolved);
+
+ // Check that the target component service provides a superset of
+ // the component reference interface
+ if (componentReference.getInterfaceContract() ==null ||
+ InterfaceUtil.checkInterfaceCompatibility(componentReference.getInterfaceContract(),
+ resolved.getInterfaceContract())) {
+
+ targets.set(i, resolved);
+ } else {
+ problems.add(target);
+ }
} else {
problems.add(target);
}
@@ -541,13 +584,23 @@
}
} else if (componentReference.getReference() != null) {
- // Wire reference targets from the corresponding reference in
- // the componentType
+ // Resolve targets from the corresponding reference in the
+ // componentType
for (ComponentService target : componentReference.getReference().getTargets()) {
if (target.isUnresolved()) {
ComponentService resolved = componentServices.get(target.getName());
if (resolved != null) {
- targets.add(resolved);
+
+ // Check that the target component service provides a superset of
+ // the component reference interface
+ if (componentReference.getInterfaceContract() == null ||
+ InterfaceUtil.checkInterfaceCompatibility(componentReference.getInterfaceContract(),
+ resolved.getInterfaceContract())) {
+
+ targets.add(resolved);
+ } else {
+ problems.add(target);
+ }
} else {
problems.add(target);
}
Modified: 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=diff&rev=532969&r1=532968&r2=532969
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/util/InterfaceUtil.java (original)
+++ incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/assembly/util/InterfaceUtil.java Thu Apr 26 22:36:03 2007
@@ -33,18 +33,23 @@
Interface source = sourceContract.getInterface();
Interface target = targetContract.getInterface();
if (source != target) {
- Operation targetOperation = null;
for (Operation sourceOperation : source.getOperations()) {
+ Operation targetOperation = null;
for (Operation anOperation : target.getOperations()) {
- if (targetOperation.getName().equals(sourceOperation.getName())) {
+ if (anOperation.getName().equals(sourceOperation.getName())) {
targetOperation = anOperation;
break;
}
}
if (targetOperation == null) {
isCompatible = false;
+
} else if (!sourceOperation.equals(targetOperation)) {
- isCompatible = false;
+// FIXME Work around the fact that OperationImpl.equals() returns false
+// in some cases when the two operations have compatible but
+// not identical input types. Uncomment the following line after
+// OperationImpl gets fixed.
+// isCompatible = false;
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org