diff options
author | scottkurz <scottkurz@13f79535-47bb-0310-9956-ffa450edef68> | 2011-07-28 03:21:39 +0000 |
---|---|---|
committer | scottkurz <scottkurz@13f79535-47bb-0310-9956-ffa450edef68> | 2011-07-28 03:21:39 +0000 |
commit | 6e4a2a67a4009146322093012bddf923881f933d (patch) | |
tree | 9803505ac25edb73d7b865de251b158a721b77d8 | |
parent | f96ec6839ec75b5ab807f224c548549066753186 (diff) |
TUSCANY-3894. Refactor WSDL InterfaceContract generation so it's only done if the BindingSCATransformer calls for it.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1151710 13f79535-47bb-0310-9956-ffa450edef68
2 files changed, 20 insertions, 13 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/DefaultLocalSCAReferenceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/DefaultLocalSCAReferenceBindingProvider.java index 209ebedd8c..49aa6eb33f 100644 --- a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/DefaultLocalSCAReferenceBindingProvider.java +++ b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/DefaultLocalSCAReferenceBindingProvider.java @@ -50,8 +50,9 @@ public class DefaultLocalSCAReferenceBindingProvider implements EndpointReferenc protected InterfaceContractMapper interfaceContractMapper;
protected ExtensionPointRegistry extensionPoints;
protected Mediator mediator;
- protected InterfaceContract wsdlBindingInterfaceContract;
-
+ protected InterfaceContract componentTypeRefInterfaceContract;
+ protected InterfaceContract wsdlBindingInterfaceContract; // Computed lazily
+
public DefaultLocalSCAReferenceBindingProvider(ExtensionPointRegistry extensionPoints, RuntimeEndpointReference endpointReference, SCABindingMapper mapper) {
this.extensionPoints = extensionPoints;
UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
@@ -65,8 +66,12 @@ public class DefaultLocalSCAReferenceBindingProvider implements EndpointReferenc return DOMDataBinding.NAME;
}
- private InterfaceContract getWSDLInterfaceContract(InterfaceContract interfaceContract) {
- InterfaceContract wsdlInterfaceContract = (WSDLInterfaceContract)endpointReference.getGeneratedWSDLContract(interfaceContract);
+ protected InterfaceContract getWSDLBindingInterfaceContract() {
+ if (this.wsdlBindingInterfaceContract != null) {
+ return this.wsdlBindingInterfaceContract;
+ }
+
+ InterfaceContract wsdlInterfaceContract = (WSDLInterfaceContract)endpointReference.getGeneratedWSDLContract(componentTypeRefInterfaceContract);
// Validation may be unnecessary. This check may already be guaranteed at this point, not sure.
Endpoint target = endpointReference.getTargetEndpoint();
@@ -93,19 +98,16 @@ public class DefaultLocalSCAReferenceBindingProvider implements EndpointReferenc if (wsdlInterfaceContract.getCallbackInterface() != null) {
wsdlInterfaceContract.getCallbackInterface().resetDataBinding(dataBinding);
}
+ this.wsdlBindingInterfaceContract = wsdlInterfaceContract;
+
return wsdlInterfaceContract;
-
}
@Override
public InterfaceContract getBindingInterfaceContract() {
- InterfaceContract componentTypeRefIC = endpointReference.getComponentTypeReferenceInterfaceContract();
- if (componentTypeRefIC.getInterface().isRemotable()) {
- this.wsdlBindingInterfaceContract = getWSDLInterfaceContract(componentTypeRefIC);
- }
-
// Since we want to disable DataTransformationInterceptor and handle copy in the binding
- return componentTypeRefIC;
+ this.componentTypeRefInterfaceContract = endpointReference.getComponentTypeReferenceInterfaceContract();
+ return componentTypeRefInterfaceContract;
}
diff --git a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCAReferenceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCAReferenceBindingProvider.java index 2c5b4f73e1..170908c82d 100644 --- a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCAReferenceBindingProvider.java +++ b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCAReferenceBindingProvider.java @@ -23,6 +23,7 @@ import org.apache.tuscany.sca.binding.sca.transform.BindingSCATransformer; import org.apache.tuscany.sca.binding.sca.transform.DefaultBindingSCATransformer;
import org.apache.tuscany.sca.binding.sca.transform.XMLWFBindingSCATransformer;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.InvocationChain;
import org.apache.tuscany.sca.provider.SCABindingMapper;
@@ -36,8 +37,12 @@ public class XMLWFLocalSCAReferenceBindingProvider extends DefaultLocalSCARefere super(extensionPoints, endpointReference, mapper);
}
- protected BindingSCATransformer getBindingTransformer(Operation operation, InvocationChain chain) {
- Operation wsdlBindingOperation = interfaceContractMapper.map(wsdlBindingInterfaceContract.getInterface(), operation);
+ protected BindingSCATransformer getBindingTransformer(Operation operation, InvocationChain chain) {
+ InterfaceContract bindingInterfaceContract = getWSDLBindingInterfaceContract();
+ if (!bindingInterfaceContract.getInterface().isRemotable()) {
+ throw new IllegalStateException("This method should only have been called for a remotable interface.");
+ }
+ Operation wsdlBindingOperation = interfaceContractMapper.map(bindingInterfaceContract.getInterface(), operation);
return new XMLWFBindingSCATransformer(mediator, operation, wsdlBindingOperation, chain);
}
}
|