summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java4
-rw-r--r--sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ExtensibleDomainRegistryFactory.java (renamed from sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ExtensibleDomainRegistry.java)14
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java4
-rw-r--r--sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java4
-rw-r--r--sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java4
-rw-r--r--sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java4
-rw-r--r--sca-java-2.x/trunk/modules/sca-client-impl/META-INF/MANIFEST.MF1
-rw-r--r--sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java43
-rw-r--r--sca-java-2.x/trunk/modules/sca-client-rmi/src/main/java/org/apache/tuscany/sca/client/rmi/SCAClientFactoryImpl.java4
-rw-r--r--sca-java-2.x/trunk/modules/sca-client-rmi/src/main/java/org/apache/tuscany/sca/client/rmi/SCAClientProxyHandler.java2
10 files changed, 51 insertions, 33 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java
index 84e69a79a4..59e787e2d4 100644
--- a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java
+++ b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java
@@ -34,7 +34,7 @@ import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
import org.apache.tuscany.sca.provider.ServiceBindingProvider;
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.RuntimeComponentService;
import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
@@ -103,7 +103,7 @@ public class RuntimeSCAServiceBindingProvider implements ServiceBindingProvider
// find if the node config is for distributed endpoints
// TODO: temp, need a much better way to do this
if (distributedProviderFactory != null) {
- DomainRegistryFactory domainRegistryFactory = new ExtensibleDomainRegistry(extensionPoints);
+ DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionPoints);
Collection<EndpointRegistry> eprs = domainRegistryFactory.getEndpointRegistries();
if (eprs.size() > 0) {
String eprName = eprs.iterator().next().getClass().getName();
diff --git a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ExtensibleDomainRegistry.java b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ExtensibleDomainRegistryFactory.java
index 7b96903dae..91d223bdaf 100644
--- a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ExtensibleDomainRegistry.java
+++ b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ExtensibleDomainRegistryFactory.java
@@ -26,21 +26,27 @@ import java.util.Collection;
import java.util.List;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
import org.oasisopen.sca.ServiceRuntimeException;
/**
- *
+ * A delegating DomainRegistryFactory
*/
-public class ExtensibleDomainRegistry implements DomainRegistryFactory {
+public class ExtensibleDomainRegistryFactory implements DomainRegistryFactory {
private final DomainRegistryFactoryExtensionPoint factories;
- public ExtensibleDomainRegistry(ExtensionPointRegistry registry) {
+ public ExtensibleDomainRegistryFactory(ExtensionPointRegistry registry) {
this.factories = registry.getExtensionPoint(DomainRegistryFactoryExtensionPoint.class);
}
- public ExtensibleDomainRegistry(DomainRegistryFactoryExtensionPoint factories) {
+ public ExtensibleDomainRegistryFactory(DomainRegistryFactoryExtensionPoint factories) {
this.factories = factories;
}
+
+ public static ExtensibleDomainRegistryFactory getInstance(ExtensionPointRegistry registry) {
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ return utilities.getUtility(ExtensibleDomainRegistryFactory.class);
+ }
public void addListener(EndpointListener listener) {
for (DomainRegistryFactory factory : factories.getDomainRegistryFactories()) {
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java
index a1f5550ab0..caf3caf00a 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java
@@ -33,7 +33,7 @@ import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
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.oasisopen.sca.NoSuchDomainException;
import org.oasisopen.sca.NoSuchServiceException;
import org.oasisopen.sca.client.SCAClientFactory;
@@ -116,7 +116,7 @@ public class DomainNode {
List<String> serviceNames = new ArrayList<String>();
if (nodes.size() > 0) {
ExtensionPointRegistry extensionsRegistry = ((NodeImpl)nodes.values().iterator().next()).getExtensionPoints();
- DomainRegistryFactory domainRegistryFactory = new ExtensibleDomainRegistry(extensionsRegistry);
+ DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionsRegistry);
EndpointRegistry endpointRegistry = domainRegistryFactory.getEndpointRegistry(getDomainConfigURI(), getDomainName());
for (Endpoint endpoint : endpointRegistry.getEndpoints()) {
// Would be nice if Endpoint.getURI() returned this:
diff --git a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java
index c61e2f4ca6..34c72933e9 100644
--- a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java
+++ b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java
@@ -31,7 +31,7 @@ import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
import org.apache.tuscany.sca.runtime.EndpointListener;
import org.apache.tuscany.sca.runtime.EndpointRegistry;
-import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistry;
+import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistryFactory;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.service.remoteserviceadmin.EndpointDescription;
@@ -49,7 +49,7 @@ public class DomainDiscoveryService extends AbstractDiscoveryService implements
public void start() {
super.start();
- this.domainRegistryFactory = new ExtensibleDomainRegistry(registry);
+ this.domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(registry);
domainRegistryFactory.addListener(this);
// [rfeng] Starting of the endpoint registry takes a long time and it leaves the bundle
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 9741abeeee..32aaf91b23 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
@@ -80,7 +80,7 @@ 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.runtime.ExtensibleDomainRegistry;
+import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistryFactory;
import org.apache.tuscany.sca.work.WorkScheduler;
import org.oasisopen.sca.ServiceRuntimeException;
@@ -301,7 +301,7 @@ public class NodeFactoryImpl extends NodeFactory {
// autowire which still relies on matching in the builder
private void postBuildEndpointReferenceMatching(Composite composite){
EndpointReferenceBinder endpointReferenceBinder = registry.getExtensionPoint(EndpointReferenceBinder.class);
- DomainRegistryFactory domainRegistryFactory = new ExtensibleDomainRegistry(registry);
+ DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(registry);
// create temporary local registry for all available local endpoints
// TODO - need a better way of getting a local registry
diff --git a/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java b/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
index f55f102807..938fa54f6c 100644
--- a/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
+++ b/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
@@ -51,7 +51,7 @@ import org.apache.tuscany.sca.runtime.ActivationException;
import org.apache.tuscany.sca.runtime.CompositeActivator;
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.RuntimeComponentContext;
import org.apache.tuscany.sca.runtime.RuntimeComponentService;
@@ -108,7 +108,7 @@ public class NodeImpl implements Node {
manager.addNode(configuration, this);
this.proxyFactory = manager.proxyFactory;
- DomainRegistryFactory domainRegistryFactory = new ExtensibleDomainRegistry(manager.registry);
+ DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(manager.registry);
EndpointRegistry endpointRegistry =
domainRegistryFactory.getEndpointRegistry(configuration.getDomainRegistryURI(), configuration
.getDomainURI());
diff --git a/sca-java-2.x/trunk/modules/sca-client-impl/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/sca-client-impl/META-INF/MANIFEST.MF
index ae6fcb3ce3..d63aa101f1 100644
--- a/sca-java-2.x/trunk/modules/sca-client-impl/META-INF/MANIFEST.MF
+++ b/sca-java-2.x/trunk/modules/sca-client-impl/META-INF/MANIFEST.MF
@@ -8,6 +8,7 @@ Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-Description: Apache Tuscany SCA Client Impl
Import-Package: org.apache.tuscany.sca.assembly;version="2.0.0",
org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.context;version="2.0.0",
org.apache.tuscany.sca.node;version="2.0.0",
org.apache.tuscany.sca.node.impl;version="2.0.0",
org.apache.tuscany.sca.runtime;version="2.0.0",
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();
- }
}
diff --git a/sca-java-2.x/trunk/modules/sca-client-rmi/src/main/java/org/apache/tuscany/sca/client/rmi/SCAClientFactoryImpl.java b/sca-java-2.x/trunk/modules/sca-client-rmi/src/main/java/org/apache/tuscany/sca/client/rmi/SCAClientFactoryImpl.java
index b77f75a514..a51e844ac1 100644
--- a/sca-java-2.x/trunk/modules/sca-client-rmi/src/main/java/org/apache/tuscany/sca/client/rmi/SCAClientFactoryImpl.java
+++ b/sca-java-2.x/trunk/modules/sca-client-rmi/src/main/java/org/apache/tuscany/sca/client/rmi/SCAClientFactoryImpl.java
@@ -32,7 +32,7 @@ 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.oasisopen.sca.NoSuchDomainException;
import org.oasisopen.sca.NoSuchServiceException;
import org.oasisopen.sca.client.SCAClientFactory;
@@ -55,7 +55,7 @@ public class SCAClientFactoryImpl extends SCAClientFactory {
this.extensionsRegistry = nodeFactory.getExtensionPoints();
if (extensionsRegistry != null) {
this.extensionsRegistry = nodeFactory.getExtensionPoints();
- DomainRegistryFactory domainRegistryFactory = new ExtensibleDomainRegistry(extensionsRegistry);
+ DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionsRegistry);
this.endpointRegistry = domainRegistryFactory.getEndpointRegistry(getRegistryURI(), getDomainName());
}
}
diff --git a/sca-java-2.x/trunk/modules/sca-client-rmi/src/main/java/org/apache/tuscany/sca/client/rmi/SCAClientProxyHandler.java b/sca-java-2.x/trunk/modules/sca-client-rmi/src/main/java/org/apache/tuscany/sca/client/rmi/SCAClientProxyHandler.java
index 1e5727bec3..c8c60edd53 100644
--- a/sca-java-2.x/trunk/modules/sca-client-rmi/src/main/java/org/apache/tuscany/sca/client/rmi/SCAClientProxyHandler.java
+++ b/sca-java-2.x/trunk/modules/sca-client-rmi/src/main/java/org/apache/tuscany/sca/client/rmi/SCAClientProxyHandler.java
@@ -80,7 +80,7 @@ public class SCAClientProxyHandler implements InvocationHandler {
DomainRegistryFactoryExtensionPoint factoriesx = extensionsRegistry.getExtensionPoint(DomainRegistryFactoryExtensionPoint.class);
for (DomainRegistryFactory factory : factoriesx.getDomainRegistryFactories()) {
for (EndpointRegistry endpointRegistry : factory.getEndpointRegistries()) {
- if (endpointRegistry.getDomainName().equals(domainURI)) {
+ if (endpointRegistry.getDomainURI().equals(domainURI)) {
this.endpointRegistry = endpointRegistry;
}
}