Author: jsdelfino
Date: Thu May 1 12:13:11 2008
New Revision: 652631
URL: http://svn.apache.org/viewvc?rev=652631&view=rev
Log:
Clean up list of targets after bindings have been created for all of them as
having both is not correct and also confuses the connectComponentReferences
algorithm. Make sure that optimizable bindings (like the SCA binding)
configured with binding URIs are properly set up with pointers to their target
component services.
Modified:
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java
Modified:
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java?rev=652631&r1=652630&r2=652631&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java
(original)
+++
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java
Thu May 1 12:13:11 2008
@@ -19,6 +19,7 @@
package org.apache.tuscany.sca.assembly.builder.impl;
+import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -149,6 +150,12 @@
}
}
}
+
+ // Finally clear the original reference target lists as we now have
+ // bindings to represent the targets
+ for (ComponentReference componentReference :
componentReferences.values()) {
+ componentReference.getTargets().clear();
+ }
}
/**
@@ -548,7 +555,7 @@
// by the implementation so leave the
binding where it is
// Binding.uri != null - from the composite file so leave it
if ((componentReference.getTargets().size() > 0) ||
- (!targets.isEmpty())){
+ (!targets.isEmpty())) {
// Add all the effective bindings
componentReference.getBindings().clear();
@@ -595,6 +602,55 @@
}
}
}
+
+ // Connect the optimizable bindings to their target component and
+ // service
+ for (Binding binding : componentReference.getBindings()) {
+ if (!(binding instanceof OptimizableBinding)) {
+ continue;
+ }
+ OptimizableBinding optimizableBinding =
(OptimizableBinding)binding;
+ if (optimizableBinding.getTargetComponentService() != null) {
+ continue;
+ }
+ String uri = optimizableBinding.getURI();
+ if (uri == null) {
+ continue;
+ }
+ uri = URI.create(uri).getPath();
+ if (uri.startsWith("/")) {
+ uri = uri.substring(1);
+ }
+
+ // Resolve the target component and service
+ ComponentService targetComponentService =
componentServices.get(uri);
+ Component targetComponent;
+ int s = uri.indexOf('/');
+ if (s == -1) {
+ targetComponent = components.get(uri);
+ } else {
+ targetComponent = components.get(uri.substring(0, s));
+ }
+
+ if (targetComponentService != null) {
+
+ // Check that the target component service provides
+ // a superset of the component reference interface
+ if (componentReference.getInterfaceContract() == null ||
+
interfaceContractMapper.isCompatible(componentReference.getInterfaceContract(),
targetComponentService.getInterfaceContract())) {
+
+ } else {
+ warning("ReferenceIncompatibleInterface",
+ composite,
+ composite.getName().toString(),
+ componentReference.getName(),
+ uri);
+ }
+ optimizableBinding.setTargetComponent(targetComponent);
+
optimizableBinding.setTargetComponentService(targetComponentService);
+
optimizableBinding.setTargetBinding(targetComponentService.getBinding(optimizableBinding.getClass()));
+ }
+ }
}
}