summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-02-09 22:14:02 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-02-09 22:14:02 +0000
commit7bf07e507a391b09ecc6f0dbdcd179cd728c39e5 (patch)
tree5414409df63e91786a693aea397807f5acb91ec8 /sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org
parentfd1ca16b84cc7b14aba0bdc492051e092d7384f8 (diff)
Rename ExtensibleDomainRegistry to ExtensibleDomainRegistryFactory
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@908255 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org')
-rw-r--r--sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java43
1 files changed, 27 insertions, 16 deletions
diff --git a/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java b/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java
index 1d6937364c..94c71cb48f 100644
--- a/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java
+++ b/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java
@@ -19,12 +19,12 @@
package org.apache.tuscany.sca.client.impl;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
import java.net.URI;
import java.util.List;
+import java.util.UUID;
import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.context.CompositeContext;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.node.Node;
import org.apache.tuscany.sca.node.NodeFactory;
@@ -32,9 +32,13 @@ import org.apache.tuscany.sca.node.impl.NodeFactoryImpl;
import org.apache.tuscany.sca.node.impl.NodeImpl;
import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
import org.apache.tuscany.sca.runtime.EndpointRegistry;
-import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistry;
+import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
import org.oasisopen.sca.NoSuchDomainException;
import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.ServiceRuntimeException;
import org.oasisopen.sca.client.SCAClientFactory;
import org.oasisopen.sca.client.SCAClientFactoryFinder;
@@ -47,13 +51,14 @@ public class SCAClientFactoryImpl extends SCAClientFactory {
private ExtensionPointRegistry extensionsRegistry;
private EndpointRegistry endpointRegistry;
private NodeFactoryImpl nodeFactory;
+ private CompositeContext compositeContext;
public SCAClientFactoryImpl(URI domainURI) throws NoSuchDomainException {
super(domainURI);
this.nodeFactory = (NodeFactoryImpl)NodeFactory.getInstance();
this.extensionsRegistry = nodeFactory.getExtensionPoints();
- DomainRegistryFactory domainRegistryFactory = new ExtensibleDomainRegistry(extensionsRegistry);
+ DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionsRegistry);
this.endpointRegistry = domainRegistryFactory.getEndpointRegistry(null, getDomainURI().toString()); // TODO: shouldnt use null for reg uri
// TODO: if there is not an existing endpoint registry for the domain URI the
// this should create an endpoint registry client for the remote domain (eg hazelcast native client)
@@ -61,6 +66,9 @@ public class SCAClientFactoryImpl extends SCAClientFactory {
if (endpointRegistry == null) {
throw new NoSuchDomainException(domainURI.toString());
}
+ String client = "sca.client." + UUID.randomUUID();
+ this.compositeContext =
+ new CompositeContext(extensionsRegistry, endpointRegistry, null, domainURI.toString(), client);
}
@Override
@@ -76,27 +84,30 @@ public class SCAClientFactoryImpl extends SCAClientFactory {
if (localNode != null) {
return localNode.getService(serviceInterface, serviceName);
}
-
- InvocationHandler handler = new SCAClientProxyHandler(serviceName, extensionsRegistry, endpointRegistry);
- return (T)Proxy.newProxyInstance(serviceInterface.getClassLoader(), new Class[] {serviceInterface}, handler);
+
+ RuntimeComponent component;
+ try {
+ component = (RuntimeComponent) endpoint.getComponent().clone();
+ } catch (CloneNotSupportedException e) {
+ throw new ServiceRuntimeException(e);
+ }
+ compositeContext.bindComponent(component);
+ RuntimeEndpoint runtimeEndpoint = (RuntimeEndpoint) component.getServices().get(0).getEndpoints().get(0);
+ runtimeEndpoint.setRemote(true);
+ ServiceReference<T> serviceReference = component.getComponentContext().getServiceReference(serviceInterface, runtimeEndpoint);
+ return serviceReference.getService();
+
}
private Node findLocalNode(Endpoint endpoint) {
for (Node node : nodeFactory.getNodes().values()) {
- for (Endpoint ep : ((NodeImpl)node).getServiceEndpoints()) {
+ for (Endpoint ep : ((NodeImpl)node).getServiceEndpoints()) {
if (endpoint.getURI().equals(ep.getURI())) {
return node;
}
- }
+ }
}
return null;
}
- private String getDomainName() {
- // TODO: parse to extract just the domain name from the uri
- if (getDomainURI().getHost() != null) {
- return getDomainURI().getHost();
- }
- return getDomainURI().toString();
- }
}