summaryrefslogtreecommitdiffstats
path: root/java/sca
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-11-17 18:54:14 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-11-17 18:54:14 +0000
commitc6b987877e4f4e0a4b77b559b77da2e397abda50 (patch)
tree63ed7db938eb97cab029dcfee6d14780f38141ab /java/sca
parent9639aa77ebe41dab0bcdc979f84db72faaf28e4f (diff)
Rationalize the interfaceContracts on Endpoint/EndpointReference
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@881438 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca')
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java3
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java3
-rw-r--r--java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java3
-rw-r--r--java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java12
-rw-r--r--java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointBuilderImpl.java3
-rw-r--r--java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java6
-rw-r--r--java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointSerializer.java9
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java4
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java26
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java15
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java10
-rw-r--r--java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java3
12 files changed, 34 insertions, 63 deletions
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java
index a22b70f609..d59c278aef 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java
@@ -102,6 +102,9 @@ public class EndpointImpl implements Endpoint {
public InterfaceContract getInterfaceContract() {
resolve();
+ if (interfaceContract == null && service != null) {
+ interfaceContract = service.getInterfaceContract();
+ }
return interfaceContract;
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java
index 4c02be42dd..19d55d597c 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java
@@ -125,6 +125,9 @@ public class EndpointReferenceImpl implements EndpointReference {
public InterfaceContract getInterfaceContract() {
resolve();
+ if (interfaceContract == null && reference != null) {
+ interfaceContract = reference.getInterfaceContract();
+ }
return interfaceContract;
}
diff --git a/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java b/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java
index f72c58287d..47c16335a5 100644
--- a/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java
+++ b/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java
@@ -164,8 +164,7 @@ public class RuntimeSCAReferenceBindingProvider implements ReferenceBindingProvi
// Check if there is a target
RuntimeEndpoint endpoint = (RuntimeEndpoint)endpointReference.getTargetEndpoint();
if (endpoint != null) {
- // Use the target binding interface contract
- return endpoint.getBindingInterfaceContract();
+ return endpoint.getServiceInterfaceContract();
} else {
return endpointReference.getReferenceInterfaceContract();
}
diff --git a/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java b/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java
index bbf785d578..15a2385c92 100644
--- a/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java
+++ b/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java
@@ -35,7 +35,6 @@ 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.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentService;
import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
@@ -48,8 +47,7 @@ import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
* @version $Rev$ $Date$
*/
public class RuntimeSCAServiceBindingProvider implements ServiceBindingProvider {
-
- private RuntimeComponent component;
+ private RuntimeEndpoint endpoint;
private RuntimeComponentService service;
private SCABinding binding;
@@ -60,7 +58,7 @@ public class RuntimeSCAServiceBindingProvider implements ServiceBindingProvider
public RuntimeSCAServiceBindingProvider(ExtensionPointRegistry extensionPoints, RuntimeEndpoint endpoint) {
- this.component = (RuntimeComponent)endpoint.getComponent();
+ this.endpoint = endpoint;
this.service = (RuntimeComponentService)endpoint.getService();
this.binding = (SCABinding)endpoint.getBinding();
@@ -120,11 +118,7 @@ public class RuntimeSCAServiceBindingProvider implements ServiceBindingProvider
if (distributedProvider != null) {
return distributedProvider.getBindingInterfaceContract();
} else {
- if (service.getService() != null) {
- return service.getService().getInterfaceContract();
- } else {
- return service.getInterfaceContract();
- }
+ return endpoint.getServiceInterfaceContract();
}
}
diff --git a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointBuilderImpl.java b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointBuilderImpl.java
index ca13532bcf..2538756227 100644
--- a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointBuilderImpl.java
+++ b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointBuilderImpl.java
@@ -111,6 +111,9 @@ public class EndpointBuilderImpl implements CompositeBuilder {
Endpoint endpoint = assemblyFactory.createEndpoint();
endpoint.setComponent(component);
endpoint.setService(service);
+ if (service != null) {
+ endpoint.setInterfaceContract(service.getInterfaceContract());
+ }
endpoint.setBinding(binding);
endpoint.setUnresolved(false);
service.getEndpoints().add(endpoint);
diff --git a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java
index be55be3bbe..445118b9f1 100644
--- a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java
+++ b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java
@@ -903,6 +903,9 @@ public class EndpointReferenceBuilderImpl {
EndpointReference endpointRef = assemblyFactory.createEndpointReference();
endpointRef.setComponent(component);
endpointRef.setReference(reference);
+ if (reference != null) {
+ endpointRef.setInterfaceContract(reference.getInterfaceContract());
+ }
endpointRef.setUnresolved(unresolved);
return endpointRef;
} // end method createEndpointRef
@@ -918,6 +921,9 @@ public class EndpointReferenceBuilderImpl {
Endpoint endpoint = createEndpoint(unresolved);
endpoint.setComponent(component);
endpoint.setService(service);
+ if (service != null) {
+ endpoint.setInterfaceContract(service.getInterfaceContract());
+ }
endpoint.setUnresolved(unresolved);
return endpoint;
} // end method createEndpoint
diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointSerializer.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointSerializer.java
index 60c05648a3..a16d8e14f7 100644
--- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointSerializer.java
+++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointSerializer.java
@@ -28,13 +28,8 @@ import org.apache.tuscany.sca.assembly.EndpointReference;
* A utility to seralize/deserialize Endpoint/EndpointReference objects
*/
public interface EndpointSerializer {
- void read(Endpoint endpoint, String xml) throws IOException;
-
- String write(Endpoint endpoint) throws IOException;
-
- void read(EndpointReference endpointReference, String xml) throws IOException;
EndpointReference readEndpointReference(String xml) throws IOException;
- Endpoint readEndpoint(String xml) throws IOException;
-
String write(EndpointReference endpointReference) throws IOException;
+ Endpoint readEndpoint(String xml) throws IOException;
+ String write(Endpoint endpoint) throws IOException;
}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java
index 9811667b17..4b1fd203fc 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java
@@ -244,7 +244,7 @@ public class CompositeActivatorImpl implements CompositeActivator {
if (targetService == null) {
targetService = service;
}
- endpoint.setInterfaceContract(targetService.getInterfaceContract().makeUnidirectional(false));
+ // endpoint.setInterfaceContract(targetService.getInterfaceContract().makeUnidirectional(false));
}
}
@@ -524,7 +524,7 @@ public class CompositeActivatorImpl implements CompositeActivator {
reference.setInterfaceContract(sourceContract);
}
- endpointReference.setInterfaceContract(sourceContract.makeUnidirectional(false));
+ // endpointReference.setInterfaceContract(sourceContract.makeUnidirectional(false));
}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java
index 2a8ce544d0..6eb392f084 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java
@@ -55,18 +55,6 @@ public class EndpointSerializerImpl implements EndpointSerializer {
refProcessor = processors.getProcessor(EndpointReference.class);
}
- public void read(Endpoint endpoint, String xml) throws IOException {
- try {
- Endpoint result = readEndpoint(xml);
- endpoint.setComponent(result.getComponent());
- endpoint.setService(result.getService());
- endpoint.setBinding(result.getBinding());
- endpoint.setInterfaceContract(result.getService().getInterfaceContract());
- } catch (Exception e) {
- throw wrap(e);
- }
-
- }
public Endpoint readEndpoint(String xml) throws IOException {
try {
@@ -98,20 +86,6 @@ public class EndpointSerializerImpl implements EndpointSerializer {
}
}
- public void read(EndpointReference endpointReference, String xml) throws IOException {
- try {
- EndpointReference result = readEndpointReference(xml);
- endpointReference.setComponent(result.getComponent());
- endpointReference.setReference(result.getReference());
- endpointReference.setBinding(result.getBinding());
- endpointReference.setInterfaceContract(result.getReference().getInterfaceContract());
- endpointReference.setTargetEndpoint(result.getTargetEndpoint());
- endpointReference.setCallbackEndpoint(result.getCallbackEndpoint());
- } catch (Exception e) {
- throw wrap(e);
- }
- }
-
public EndpointReference readEndpointReference(String xml) throws IOException {
try {
XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(xml));
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
index a9759d2e91..29262949df 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
@@ -232,7 +232,7 @@ public class RuntimeEndpointImpl extends EndpointImpl implements RuntimeEndpoint
//InterfaceContract targetContract = getInterfaceContract();
// TODO - EPR - why is this looking at the component types. The endpoint should have the right interface contract by this time
InterfaceContract targetContract = getServiceInterfaceContract();
- setInterfaceContract(targetContract);
+ // setInterfaceContract(targetContract);
for (Operation operation : sourceContract.getInterface().getOperations()) {
Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation);
if (targetOperation == null) {
@@ -480,13 +480,6 @@ public class RuntimeEndpointImpl extends EndpointImpl implements RuntimeEndpoint
@Override
public void resolve() {
- if (component == null && xml != null) {
- try {
- getSerializer().read(this, xml);
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
- }
super.resolve();
}
@@ -496,12 +489,12 @@ public class RuntimeEndpointImpl extends EndpointImpl implements RuntimeEndpoint
return bindingInterfaceContract;
}
bindingInterfaceContract = getBindingProvider().getBindingInterfaceContract();
- if (bindingInterfaceContract == null && service != null) {
- bindingInterfaceContract = service.getInterfaceContract();
- }
if (bindingInterfaceContract == null) {
bindingInterfaceContract = getInterfaceContract();
}
+ if (bindingInterfaceContract == null) {
+ bindingInterfaceContract = getServiceInterfaceContract();
+ }
return bindingInterfaceContract;
}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java
index efdbc71bbd..5b2de2f01f 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java
@@ -276,8 +276,8 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen
policyProvider.start();
}
- InterfaceContract bindingContract = getBindingInterfaceContract();
- endpoint.setInterfaceContract(bindingContract);
+ // InterfaceContract bindingContract = getBindingInterfaceContract();
+ // endpoint.setInterfaceContract(bindingContract);
}
@@ -441,12 +441,12 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen
return bindingInterfaceContract;
}
bindingInterfaceContract = getBindingProvider().getBindingInterfaceContract();
- if (bindingInterfaceContract == null && reference != null) {
- bindingInterfaceContract = reference.getInterfaceContract();
- }
if (bindingInterfaceContract == null) {
bindingInterfaceContract = getInterfaceContract();
}
+ if (bindingInterfaceContract == null) {
+ bindingInterfaceContract = getReferenceInterfaceContract();
+ }
return bindingInterfaceContract;
}
diff --git a/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java b/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java
index f2d134f7a2..421c95672b 100644
--- a/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java
+++ b/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java
@@ -148,7 +148,8 @@ public class JavaComponentContextProvider {
if (callbackReference != null) {
List<EndpointReference> wires = callbackReference.getEndpointReferences();
if (!wires.isEmpty()) {
- callbackWires.put(wires.get(0).getInterfaceContract().getInterface().toString(),
+ RuntimeEndpointReference epr = (RuntimeEndpointReference) wires.get(0);
+ callbackWires.put(epr.getReferenceInterfaceContract().getInterface().toString(),
wires);
}
}