summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-01-15 15:28:24 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-01-15 15:28:24 +0000
commitbddbbfc4ecf8bd9f76c17360e7050877e8e242d2 (patch)
treeda73dd5f248346e74a28e8d0ba0ac5332999b202 /sca-java-2.x
parent03fd042c47ed75f88e0af65531f7c1392e9fbc51 (diff)
The code for build time matching. To actually use this we need to create a build time registry. As it stands you get duplicate endpoint regsitration notifications.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@899664 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x')
-rw-r--r--sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java65
1 files changed, 64 insertions, 1 deletions
diff --git a/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java b/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
index e4e2386667..86da71b4b2 100644
--- a/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
+++ b/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
@@ -44,7 +44,13 @@ import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Implementation;
import org.apache.tuscany.sca.common.java.io.IOHelper;
import org.apache.tuscany.sca.contribution.Artifact;
import org.apache.tuscany.sca.contribution.Contribution;
@@ -71,6 +77,9 @@ import org.apache.tuscany.sca.node.configuration.BindingConfiguration;
import org.apache.tuscany.sca.node.configuration.ContributionConfiguration;
import org.apache.tuscany.sca.node.configuration.DeploymentComposite;
import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.EndpointReferenceBinder;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
import org.apache.tuscany.sca.work.WorkScheduler;
import org.oasisopen.sca.ServiceRuntimeException;
@@ -273,9 +282,63 @@ public class NodeFactoryImpl extends NodeFactory {
}
Composite domainComposite = deployer.build(contributions, bindingBaseURIs, monitor);
analyzeProblems(monitor);
-
+
+ // postBuildEndpointReferenceMatching(domainComposite);
+
return domainComposite;
}
+
+ // =============================================
+ // TODO - TUSCANY-3425
+ // post build endpoint reference matching. Give the matching algorithm
+ // a chance to run and report any errors for local references prior to
+ // runtime start. Not in use at the moment as we are getting away with
+ // runtime matching. Leaving here for when we come to sorting out
+ // autowire which still relies on matching in the builder
+ private void postBuildEndpointReferenceMatching(Composite composite){
+ EndpointReferenceBinder endpointReferenceBinder = registry.getExtensionPoint(EndpointReferenceBinder.class);
+ DomainRegistryFactory domainRegistryFactory = registry.getExtensionPoint(DomainRegistryFactory.class);
+
+ // create temporary local registry for all available local endpoints
+ // TODO - need a better way of getting a local registry
+ EndpointRegistry registry = domainRegistryFactory.getEndpointRegistry("vm://tmp", "local");
+
+ // populate the registry with all the endpoints that are currently present in the model
+ populateLocalRegistry(composite, registry);
+
+ // look at all the endpoint references and try to match them to
+ // any local endpoints
+ for (EndpointReference endpointReference : registry.getEndpointReferences()){
+ endpointReferenceBinder.bindBuildTime(registry, endpointReference);
+ }
+
+ // remove the local registry
+ domainRegistryFactory.getEndpointRegistries().remove(registry);
+ }
+
+ private void populateLocalRegistry(Composite composite, EndpointRegistry registry){
+ for (Component component : composite.getComponents()) {
+ // recurse for composite implementations
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ populateLocalRegistry((Composite)implementation, registry);
+ }
+
+ for (ComponentService service : component.getServices()) {
+ for (Endpoint endpoint : service.getEndpoints()){
+ registry.addEndpoint(endpoint);
+ }
+ }
+
+ for (ComponentReference reference : component.getReferences()) {
+ for (EndpointReference endpointReference : reference.getEndpointReferences()){
+ registry.addEndpointReference(endpointReference);
+ }
+ }
+ }
+ }
+
+ // =============================================
protected List<Contribution> loadContributions(NodeConfiguration configuration, ProcessorContext context) throws Throwable {
List<Contribution> contributions = new ArrayList<Contribution>();