Rationalize the interfaceContracts on Endpoint/EndpointReference
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@881438 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9639aa77eb
commit
c6b987877e
12 changed files with 34 additions and 63 deletions
|
|
@ -102,6 +102,9 @@ public class EndpointImpl implements Endpoint {
|
|||
|
||||
public InterfaceContract getInterfaceContract() {
|
||||
resolve();
|
||||
if (interfaceContract == null && service != null) {
|
||||
interfaceContract = service.getInterfaceContract();
|
||||
}
|
||||
return interfaceContract;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -125,6 +125,9 @@ public class EndpointReferenceImpl implements EndpointReference {
|
|||
|
||||
public InterfaceContract getInterfaceContract() {
|
||||
resolve();
|
||||
if (interfaceContract == null && reference != null) {
|
||||
interfaceContract = reference.getInterfaceContract();
|
||||
}
|
||||
return interfaceContract;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue