summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sca-java-2.x/trunk/modules/core/META-INF/MANIFEST.MF1
-rw-r--r--sca-java-2.x/trunk/modules/core/pom.xml6
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java61
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java58
4 files changed, 117 insertions, 9 deletions
diff --git a/sca-java-2.x/trunk/modules/core/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/core/META-INF/MANIFEST.MF
index e9fdadbd1f..95efebc96a 100644
--- a/sca-java-2.x/trunk/modules/core/META-INF/MANIFEST.MF
+++ b/sca-java-2.x/trunk/modules/core/META-INF/MANIFEST.MF
@@ -59,6 +59,7 @@ Import-Package: javax.security.auth,
org.apache.tuscany.sca.interfacedef.wsdl;version="2.0.0",
org.apache.tuscany.sca.invocation;version="2.0.0",
org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.node;version="2.0.0",
org.apache.tuscany.sca.policy;version="2.0.0",
org.apache.tuscany.sca.provider;version="2.0.0",
org.apache.tuscany.sca.runtime;version="2.0.0",
diff --git a/sca-java-2.x/trunk/modules/core/pom.xml b/sca-java-2.x/trunk/modules/core/pom.xml
index 8354a8e925..8eee896831 100644
--- a/sca-java-2.x/trunk/modules/core/pom.xml
+++ b/sca-java-2.x/trunk/modules/core/pom.xml
@@ -54,6 +54,12 @@
</dependency>
<dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2</version>
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
index 5c21041413..263ba6a8c7 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
@@ -43,6 +43,7 @@ import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.CompositeReference;
import org.apache.tuscany.sca.assembly.CompositeService;
import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.Service;
@@ -81,6 +82,7 @@ import org.apache.tuscany.sca.invocation.InvokerAsyncResponse;
import org.apache.tuscany.sca.invocation.Message;
import org.apache.tuscany.sca.invocation.MessageFactory;
import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.node.NodeFactory;
import org.apache.tuscany.sca.provider.BindingProviderFactory;
import org.apache.tuscany.sca.provider.EndpointAsyncProvider;
import org.apache.tuscany.sca.provider.EndpointProvider;
@@ -91,8 +93,10 @@ import org.apache.tuscany.sca.provider.PolicyProvider;
import org.apache.tuscany.sca.provider.PolicyProviderFactory;
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.EndpointSerializer;
+import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistryFactory;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentService;
import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
@@ -892,18 +896,63 @@ public class RuntimeEndpointImpl extends EndpointImpl implements RuntimeEndpoint
if (compositeContext != null) {
bind(compositeContext);
}
- }
+ } // end if
if (serializer != null) {
RuntimeEndpointImpl ep = (RuntimeEndpointImpl)serializer.readEndpoint(xml);
copyFrom(ep);
} else {
- // FIXME: [rfeng] What should we do here?
- }
- }
+ // In this case, we assume that we're running on a detached (non Tuscany) thread and
+ // as a result we need to connect back to the Tuscany environment...
+ for( NodeFactory factory : NodeFactory.getNodeFactories() ) {
+ ExtensionPointRegistry registry = factory.getExtensionPointRegistry();
+ if( registry != null ) {
+ this.registry = registry;
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ this.interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class);
+ this.serializer = utilities.getUtility(EndpointSerializer.class);
+ RuntimeEndpointImpl ep = (RuntimeEndpointImpl)serializer.readEndpoint(xml);
+ // Find the actual Endpoint in the EndpointRegistry
+ ep = findActualEP( ep, registry );
+
+ if( ep != null ){
+ copyFrom( ep );
+ break;
+ } // end if
+ } // end if
+ } // end for
+ } // end if
+ } // end if
super.resolve();
- }
+ } // end method resolve
+
+ /**
+ * Find the actual Endpoint in the EndpointRegistry which corresponds to the configuration described
+ * in a deserialized Endpoint
+ * @param ep The deserialized endpoint
+ * @param registry - the main extension point Registry
+ * @return the corresponding Endpoint from the EndpointRegistry, or null if no match can be found
+ */
+ private RuntimeEndpointImpl findActualEP(RuntimeEndpointImpl ep,
+ ExtensionPointRegistry registry) {
+ // Get the EndpointRegistry
+ DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(registry);
+
+ if( domainRegistryFactory == null ) return null;
+
+ // TODO: For the moment, just use the first (and only!) EndpointRegistry...
+ EndpointRegistry endpointRegistry = (EndpointRegistry) domainRegistryFactory.getEndpointRegistries().toArray()[0];
+
+ if( endpointRegistry == null ) return null;
+
+ for( Endpoint endpoint : endpointRegistry.findEndpoint(ep.getURI()) ) {
+ // TODO: For the present, simply return the first matching endpoint
+ return (RuntimeEndpointImpl) endpoint;
+ } // end for
+
+ return null;
+ } // end method findActualEP
- public InterfaceContract getBindingInterfaceContract() {
+ public InterfaceContract getBindingInterfaceContract() {
resolve();
if (bindingInterfaceContract != null) {
return bindingInterfaceContract;
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java
index f86f90c6e6..368ec0ba87 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java
@@ -38,6 +38,7 @@ import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.CompositeReference;
import org.apache.tuscany.sca.assembly.CompositeService;
import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.assembly.builder.BindingBuilder;
import org.apache.tuscany.sca.assembly.builder.BuilderContext;
@@ -70,6 +71,7 @@ import org.apache.tuscany.sca.invocation.InvokerAsyncResponse;
import org.apache.tuscany.sca.invocation.Message;
import org.apache.tuscany.sca.invocation.MessageFactory;
import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.node.NodeFactory;
import org.apache.tuscany.sca.provider.BindingProviderFactory;
import org.apache.tuscany.sca.provider.EndpointReferenceProvider;
import org.apache.tuscany.sca.provider.ImplementationAsyncProvider;
@@ -78,9 +80,11 @@ import org.apache.tuscany.sca.provider.PolicyProvider;
import org.apache.tuscany.sca.provider.PolicyProviderFactory;
import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+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.EndpointSerializer;
+import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistryFactory;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
@@ -633,11 +637,59 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen
bind(compositeContext);
}
}
- RuntimeEndpointReferenceImpl epr = (RuntimeEndpointReferenceImpl)serializer.readEndpointReference(xml);
- copyFrom(epr);
+ if (serializer != null) {
+ RuntimeEndpointReferenceImpl epr = (RuntimeEndpointReferenceImpl)serializer.readEndpointReference(xml);
+ copyFrom(epr);
+ } else {
+ // In this case, we assume that we're running on a detached (non Tuscany) thread and
+ // as a result we need to connect back to the Tuscany environment...
+ for( NodeFactory factory : NodeFactory.getNodeFactories() ) {
+ ExtensionPointRegistry registry = factory.getExtensionPointRegistry();
+ if( registry != null ) {
+ this.registry = registry;
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ this.serializer = utilities.getUtility(EndpointSerializer.class);
+ RuntimeEndpointReferenceImpl epr = (RuntimeEndpointReferenceImpl)serializer.readEndpointReference(xml);
+ // Find the actual Endpoint in the EndpointRegistry
+ epr = findActualEPR( epr, registry );
+
+ if( epr != null ){
+ copyFrom( epr );
+ break;
+ } // end if
+ } // end if
+ } // end for
+ } // end if
}
super.resolve();
- }
+ } // end method resolve
+
+ /**
+ * Find the actual EndpointReference in the EndpointRegistry which corresponds to the configuration described
+ * in a deserialized EndpointReference
+ * @param ep The deserialized endpointReference
+ * @param registry - the main extension point Registry
+ * @return the corresponding EndpointReference from the EndpointRegistry, or null if no match can be found
+ */
+ private RuntimeEndpointReferenceImpl findActualEPR(RuntimeEndpointReferenceImpl epr,
+ ExtensionPointRegistry registry) {
+ // Get the EndpointRegistry
+ DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(registry);
+ if( domainRegistryFactory == null ) return null;
+
+ // TODO: For the moment, just use the first (and only!) EndpointRegistry...
+ EndpointRegistry endpointRegistry = (EndpointRegistry) domainRegistryFactory.getEndpointRegistries().toArray()[0];
+ if( endpointRegistry == null ) return null;
+
+ for( EndpointReference epReference : endpointRegistry.getEndpointReferences() ) {
+ // TODO: For the present, simply return the first matching endpointReference
+ if( epReference.getURI().equals(epr.getURI()) ) {
+ return (RuntimeEndpointReferenceImpl) epReference;
+ } // end if
+ } // end for
+
+ return null;
+ } // end method findActualEPR
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
this.uri = in.readUTF();