Hi Raymond,

Good point.  I refactored a bit and now in r1151710, we only build the
WSDL if we need it.    Haven't run all the itests yet but I think I
got it right so committed it.

Scott

On Wed, Jul 27, 2011 at 10:20 PM, Raymond Feng <enjoyj...@gmail.com> wrote:
> Hi,
> I have some concerns about the WSDL generation for all remotable interfaces.
> It's pretty expensive to generate the WSDL from a Java interface. As more
> and more web APIs move toward REST/JSON these days, I'm not sure why we need
> to pay the penalty if we'll never use the WSDL SOAP WS.
> Can we make it optional (or maybe we should only do thing for binding.ws)?
> Thanks,
> Raymond
> ________________________________________________________________
> Raymond Feng
> rf...@apache.org
> Apache Tuscany PMC member and committer: tuscany.apache.org
> Co-author of Tuscany SCA In Action book: www.tuscanyinaction.com
> Personal Web Site: www.enjoyjava.com
> ________________________________________________________________
> On Jul 27, 2011, at 2:20 PM, scottk...@apache.org wrote:
>
> Author: scottkurz
> Date: Wed Jul 27 21:20:22 2011
> New Revision: 1151632
>
> URL: http://svn.apache.org/viewvc?rev=1151632&view=rev
> Log:
> TUSCANY-3894.  Refactor local sca binding so that the exact details of the
> data copy can be plugged in via the BindingProviderFactory extension point,
> while keeping a core, base portion of the binding to do things like
> calculate whether to do the pass-by-reference optimization and establish
> other aspects of the invoker/interceptor chain.   The data handling is
> factored into a BindingSCATransformer class.  The default impl will continue
> to use MediatorImpl.copyXXX methods, and will use Java-serialization first
> then XML/JAXB-serialization.   The second impl included uses XML
> serialization and calculates a WSDL interfaceContract.
>
> Added:
>    tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/DefaultLocalSCAReferenceBindingProvider.java
>      - copied, changed from r1151463,
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/LocalSCAReferenceBindingProvider.java
>    tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCABindingProviderFactory.java
>    tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCAReferenceBindingProvider.java
>    tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/
>    tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/BindingSCATransformer.java
>    tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/DefaultBindingSCATransformer.java
>    tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/XMLWFBindingSCATransformer.java
> Removed:
>    tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/LocalSCAReferenceBindingProvider.java
> Modified:
>    tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/META-INF/MANIFEST.MF
>    tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/pom.xml
>    tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/LocalSCABindingInvoker.java
>    tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/LocalSCABindingProviderFactory.java
>    tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DelegatingSCAReferenceBindingProvider.java
>    tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
>
> Modified:
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/META-INF/MANIFEST.MF
> URL:
> http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/META-INF/MANIFEST.MF?rev=1151632&r1=1151631&r2=1151632&view=diff
> ==============================================================================
> ---
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/META-INF/MANIFEST.MF
> (original)
> +++
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/META-INF/MANIFEST.MF
> Wed Jul 27 21:20:22 2011
> @@ -19,9 +19,11 @@ Import-Package: javax.xml.namespace,
>  org.apache.tuscany.sca.core;version="2.0.0",
>  org.apache.tuscany.sca.core.invocation;version="2.0.0",
>  org.apache.tuscany.sca.databinding;version="2.0.0",
> + org.apache.tuscany.sca.databinding.xml;version="2.0.0",
>  org.apache.tuscany.sca.definitions;version="2.0.0",
>  org.apache.tuscany.sca.extensibility;version="2.0.0",
>  org.apache.tuscany.sca.interfacedef;version="2.0.0",
> + 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";resolution:=optional,
>  org.apache.tuscany.sca.policy;version="2.0.0",
>
> Modified: tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/pom.xml
> URL:
> http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/pom.xml?rev=1151632&r1=1151631&r2=1151632&view=diff
> ==============================================================================
> --- tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/pom.xml
> (original)
> +++ tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/pom.xml Wed Jul
> 27 21:20:22 2011
> @@ -46,6 +46,13 @@
>
>         <dependency>
>             <groupId>org.apache.tuscany.sca</groupId>
> +            <artifactId>tuscany-binding-ws-wsdlgen</artifactId>
> +            <version>2.0-SNAPSHOT</version>
> +            <scope>runtime</scope>
> +        </dependency>
> +
> +        <dependency>
> +            <groupId>org.apache.tuscany.sca</groupId>
>             <artifactId>tuscany-core-spi</artifactId>
>             <version>2.0-SNAPSHOT</version>
>         </dependency>
>
> Copied:
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/DefaultLocalSCAReferenceBindingProvider.java
> (from r1151463,
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/LocalSCAReferenceBindingProvider.java)
> URL:
> http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/DefaultLocalSCAReferenceBindingProvider.java?p2=tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/DefaultLocalSCAReferenceBindingProvider.java&p1=tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/LocalSCAReferenceBindingProvider.java&r1=1151463&r2=1151632&rev=1151632&view=diff
> ==============================================================================
> ---
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/LocalSCAReferenceBindingProvider.java
> (original)
> +++
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/DefaultLocalSCAReferenceBindingProvider.java
> Wed Jul 27 21:20:22 2011
> @@ -22,13 +22,18 @@ package org.apache.tuscany.sca.binding.l
> import org.apache.tuscany.sca.assembly.Endpoint;
> import org.apache.tuscany.sca.assembly.Reference;
> import org.apache.tuscany.sca.binding.local.LocalSCABindingInvoker;
> +import org.apache.tuscany.sca.binding.sca.transform.BindingSCATransformer;
> +import
> org.apache.tuscany.sca.binding.sca.transform.DefaultBindingSCATransformer;
> import org.apache.tuscany.sca.core.ExtensionPointRegistry;
> import org.apache.tuscany.sca.core.UtilityExtensionPoint;
> import org.apache.tuscany.sca.databinding.Mediator;
> +import org.apache.tuscany.sca.databinding.xml.DOMDataBinding;
> import org.apache.tuscany.sca.interfacedef.Compatibility;
> +import
> org.apache.tuscany.sca.interfacedef.IncompatibleInterfaceContractException;
> import org.apache.tuscany.sca.interfacedef.InterfaceContract;
> import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
> import org.apache.tuscany.sca.interfacedef.Operation;
> +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
> import org.apache.tuscany.sca.invocation.InvocationChain;
> import org.apache.tuscany.sca.invocation.Invoker;
> import org.apache.tuscany.sca.provider.EndpointReferenceAsyncProvider;
> @@ -36,42 +41,85 @@ import org.apache.tuscany.sca.provider.S
> import org.apache.tuscany.sca.runtime.RuntimeComponentService;
> import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
> import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
> +import org.oasisopen.sca.ServiceRuntimeException;
> import org.oasisopen.sca.ServiceUnavailableException;
>
> -public class LocalSCAReferenceBindingProvider implements
> EndpointReferenceAsyncProvider {
> +public class DefaultLocalSCAReferenceBindingProvider implements
> EndpointReferenceAsyncProvider {
>     private RuntimeEndpointReference endpointReference;
>
> -    private InterfaceContractMapper interfaceContractMapper;
> -    private ExtensionPointRegistry extensionPoints;
> -    private Mediator mediator;
> +    protected InterfaceContractMapper interfaceContractMapper;
> +    protected ExtensionPointRegistry extensionPoints;
> +    protected Mediator mediator;
> +    protected InterfaceContract wsdlBindingInterfaceContract;
>
> -    public LocalSCAReferenceBindingProvider(ExtensionPointRegistry
> extensionPoints, RuntimeEndpointReference endpointReference,
> SCABindingMapper mapper) {
> +    public DefaultLocalSCAReferenceBindingProvider(ExtensionPointRegistry
> extensionPoints, RuntimeEndpointReference endpointReference,
> SCABindingMapper mapper) {
>         this.extensionPoints = extensionPoints;
>         UtilityExtensionPoint utilities =
> extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
> -        this.interfaceContractMapper =
> utilities.getUtility(InterfaceContractMapper.class);
> +        this.interfaceContractMapper =
> utilities.getUtility(InterfaceContractMapper.class);
>         this.mediator = utilities.getUtility(Mediator.class);
>
>         this.endpointReference = endpointReference;
>     }
> +
> +    protected String getDataBinding() {
> +        return DOMDataBinding.NAME;
> +    }
> +
> +    private InterfaceContract getWSDLInterfaceContract(InterfaceContract
> interfaceContract) {
> +        InterfaceContract wsdlInterfaceContract =
> (WSDLInterfaceContract)endpointReference.getGeneratedWSDLContract(interfaceContract);
> +
> +        // Validation may be unnecessary.  This check may already be
> guaranteed at this point, not sure.
> +        Endpoint target = endpointReference.getTargetEndpoint();
> +        InterfaceContract targetInterfaceContract =
> target.getComponentServiceInterfaceContract();
> +        try {
> +
>            interfaceContractMapper.checkCompatibility(wsdlInterfaceContract,
> targetInterfaceContract,
> +
>                                                       Compatibility.SUBSET,
> true, false);
> +        } catch (IncompatibleInterfaceContractException exc) {
> +            throw new ServiceRuntimeException(exc);
> +        }
> +
> +        String dataBinding = getDataBinding();
> +
> +        // Clone
> +        try {
> +            wsdlInterfaceContract =
> (WSDLInterfaceContract)wsdlInterfaceContract.clone();
> +        } catch (CloneNotSupportedException exc) {
> +            throw new ServiceRuntimeException(exc);
> +        }
> +
> +        if (wsdlInterfaceContract.getInterface() != null) {
> +
>            wsdlInterfaceContract.getInterface().resetDataBinding(dataBinding);
> +        }
> +        if (wsdlInterfaceContract.getCallbackInterface() != null) {
> +
>            wsdlInterfaceContract.getCallbackInterface().resetDataBinding(dataBinding);
> +        }
> +        return wsdlInterfaceContract;
> +
> +    }
>
>     @Override
>     public InterfaceContract getBindingInterfaceContract() {
> -        RuntimeEndpoint endpoint = (RuntimeEndpoint)
> endpointReference.getTargetEndpoint();
> -        if (endpoint != null) {
> -            return endpoint.getComponentTypeServiceInterfaceContract();
> -        } else {
> -            return
> endpointReference.getComponentTypeReferenceInterfaceContract();
> +        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;
>     }
>
> +
> +
>     @Override
>     public Invoker createInvoker(Operation operation) {
>         Invoker result = null;
> -
> +        BindingSCATransformer bindingTransformer = null;
> +
>         Endpoint target = endpointReference.getTargetEndpoint();
>         if (target != null) {
>             RuntimeComponentService service = (RuntimeComponentService)
> target.getService();
>             if (service != null) { // not a callback wire
> +
>                 InvocationChain chain = ((RuntimeEndpoint)
> target).getInvocationChain(operation);
>
>                 boolean passByValue = false;
> @@ -90,15 +138,19 @@ public class LocalSCAReferenceBindingPro
>                         passByValue = false;
>                     } else if
> (interfaceContractMapper.isCompatibleWithoutUnwrapByValue(operation,
> targetOp, Compatibility.SUBSET)) {
>                         passByValue = true;
> +                    } else {
> +                        throw new IllegalStateException();
>                     }
> +                    bindingTransformer = getBindingTransformer(operation,
> chain);
>                 }
> +
>                 // it turns out that the chain source and target operations
> are
>                 // the same, and are the operation
>                 // from the target, not sure if thats by design or a bug.
> The
>                 // SCA binding invoker needs to know
>                 // the source and target class loaders so pass in the real
>                 // source operation in the constructor
> -                result = chain == null ? null : new
> LocalSCABindingInvoker(chain, operation, mediator, passByValue,
> endpointReference, extensionPoints);
> +                result = chain == null ? null : new
> LocalSCABindingInvoker(chain, operation, passByValue, endpointReference,
> extensionPoints, bindingTransformer);
>             }
>         }
>
> @@ -109,6 +161,10 @@ public class LocalSCAReferenceBindingPro
>
>         return result;
>     }
> +
> +    protected BindingSCATransformer getBindingTransformer(Operation
> operation, InvocationChain chain) {
> +        return new DefaultBindingSCATransformer(mediator, operation,
> chain);
> +    }
>
>     @Override
>     public boolean supportsOneWayInvocation() {
> @@ -143,4 +199,6 @@ public class LocalSCAReferenceBindingPro
>     public void setEndpointReference(RuntimeEndpointReference
> endpointReference){
>         this.endpointReference = endpointReference;
>     }
> +
> +
> }
>
> Modified:
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/LocalSCABindingInvoker.java
> URL:
> http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/LocalSCABindingInvoker.java?rev=1151632&r1=1151631&r2=1151632&view=diff
> ==============================================================================
> ---
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/LocalSCABindingInvoker.java
> (original)
> +++
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/LocalSCABindingInvoker.java
> Wed Jul 27 21:20:22 2011
> @@ -19,6 +19,7 @@
>
> package org.apache.tuscany.sca.binding.local;
>
> +import org.apache.tuscany.sca.binding.sca.transform.BindingSCATransformer;
> import org.apache.tuscany.sca.core.ExtensionPointRegistry;
> import org.apache.tuscany.sca.core.FactoryExtensionPoint;
> import org.apache.tuscany.sca.core.invocation.AsyncResponseInvoker;
> @@ -41,28 +42,26 @@ import org.apache.tuscany.sca.runtime.Ru
>  */
> public class LocalSCABindingInvoker extends InterceptorAsyncImpl {
>     private InvocationChain chain;
> -    private Mediator mediator;
> -    private Operation sourceOperation;
> -    private Operation targetOperation;
>     private boolean passByValue;
>     private RuntimeEndpointReference epr;
>     private RuntimeEndpoint ep;
>     private ExtensionPointRegistry registry;
> +    private BindingSCATransformer bindingSCATransformer;
>
>     /**
>      * Construct a SCABindingInvoker that delegates to the service
> invocation chain
>      */
> -    public LocalSCABindingInvoker(InvocationChain chain, Operation
> sourceOperation, Mediator mediator,
> -     boolean passByValue, RuntimeEndpointReference epr,
> ExtensionPointRegistry registry) {
> +    public LocalSCABindingInvoker(InvocationChain chain, Operation
> sourceOperation,
> +                                  boolean passByValue,
> RuntimeEndpointReference epr, ExtensionPointRegistry registry,
> +                                  BindingSCATransformer
> bindingSCATransformer) {
>         super();
>         this.chain = chain;
> -        this.mediator = mediator;
> -        this.sourceOperation = sourceOperation;
> -        this.targetOperation = chain.getTargetOperation();
> +
>         this.passByValue = passByValue;
>         this.epr = epr;
>         this.ep = (RuntimeEndpoint)epr.getTargetEndpoint();
>         this.registry = registry;
> +        this.bindingSCATransformer = bindingSCATransformer;
>     }
>
>     /**
> @@ -78,35 +77,36 @@ public class LocalSCABindingInvoker exte
>     public void setNext(Invoker next) {
>         // NOOP
>     }
> -
> +
>     public Message processRequest(Message msg){
>         if (passByValue) {
> -            msg.setBody(mediator.copyInput(msg.getBody(), sourceOperation,
> targetOperation));
> +            Object transformedBody =
> bindingSCATransformer.transformInput(msg.getBody());
> +            msg.setBody(transformedBody);
>         } // end if
> -
> +
>         ep.getInvocationChains();
>         if ( !ep.getCallbackEndpointReferences().isEmpty() ) {
>             RuntimeEndpointReference asyncEPR = (RuntimeEndpointReference)
> ep.getCallbackEndpointReferences().get(0);
>             // Place a link to the callback EPR into the message headers...
>             msg.getHeaders().put("ASYNC_CALLBACK", asyncEPR );
>         } // end if
> -
> +
>         if( ep.isAsyncInvocation() ) {
>             // Get the message ID
>             String msgID = (String)msg.getHeaders().get("MESSAGE_ID");
> -
> +
>             String operationName = msg.getOperation().getName();
> -
> +
>             // Create a response invoker and add it to the message headers
>             AsyncResponseInvoker<RuntimeEndpointReference> respInvoker =
>
> -             new AsyncResponseInvoker<RuntimeEndpointReference>(ep, null,
> epr, msgID, operationName, getMessageFactory());
> +                new AsyncResponseInvoker<RuntimeEndpointReference>(ep,
> null, epr, msgID, operationName, getMessageFactory());
>             respInvoker.setBindingType("SCA_LOCAL");
>             msg.getHeaders().put("ASYNC_RESPONSE_INVOKER", respInvoker);
>         } // end if
> -
> +
>         return msg;
>     } // end method processRequest
> -
> +
>     /**
>      * Regular (sync) processing of response message
>      */
> @@ -114,54 +114,54 @@ public class LocalSCABindingInvoker exte
>         if (passByValue) {
>             // Note source and target operation swapped so result is in
> source class loader
>             if (msg.isFault()) {
> -                msg.setFaultBody(mediator.copyFault(msg.getBody(),
> sourceOperation, targetOperation));
> +                Object transformedFault =
> bindingSCATransformer.transformFault(msg.getBody());
> +                msg.setFaultBody(transformedFault);
>             } else {
> -                if (sourceOperation.getOutputType() != null) {
> -                    msg.setBody(mediator.copyOutput(msg.getBody(),
> sourceOperation, targetOperation));
> -                } // end if
> +                Object transformedOutput =
> bindingSCATransformer.transformOutput(msg.getBody());
> +                msg.setBody(transformedOutput);
>             } // end if
>         } // end if
> -
> +
>         return msg;
>     } // end method processResponse
> -
> +
>     public void invokeAsyncRequest(Message msg) throws Throwable {
> -     try{
> -        msg = processRequest(msg);
> -        InvokerAsyncRequest theNext = (InvokerAsyncRequest)getNext();
> -        if( theNext != null ) theNext.invokeAsyncRequest(msg);
> -        postProcessRequest(msg);
> -     } catch (Throwable e) {
> -     postProcessRequest(msg, e);
> -     } // end try
> +        try{
> +            msg = processRequest(msg);
> +            InvokerAsyncRequest theNext = (InvokerAsyncRequest)getNext();
> +            if( theNext != null ) theNext.invokeAsyncRequest(msg);
> +            postProcessRequest(msg);
> +        } catch (Throwable e) {
> +            postProcessRequest(msg, e);
> +        } // end try
>     } // end method invokeAsyncRequest
> -
> +
>     public void invokeAsyncResponse(Message msg) {
>         msg = processResponse(msg);
> -
> +
>         // Handle async response Relates_To message ID value
>         @SuppressWarnings("unchecked")
> - AsyncResponseInvoker<RuntimeEndpointReference> respInvoker =
> -
> (AsyncResponseInvoker<RuntimeEndpointReference>)msg.getHeaders().get("ASYNC_RESPONSE_INVOKER");
> +        AsyncResponseInvoker<RuntimeEndpointReference> respInvoker =
> +
>            (AsyncResponseInvoker<RuntimeEndpointReference>)msg.getHeaders().get("ASYNC_RESPONSE_INVOKER");
>         // TODO - this deals with the Local case only - not distributed
>         if( respInvoker != null &&
> "SCA_LOCAL".equals(respInvoker.getBindingType()) ) {
> -        RuntimeEndpointReference responseEPR =
> respInvoker.getResponseTargetAddress();
> -        msg.setFrom(responseEPR);
> -         String msgID = respInvoker.getRelatesToMsgID();
> -        msg.getHeaders().put("RELATES_TO", msgID);
> +            RuntimeEndpointReference responseEPR =
> respInvoker.getResponseTargetAddress();
> +            msg.setFrom(responseEPR);
> +            String msgID = respInvoker.getRelatesToMsgID();
> +            msg.getHeaders().put("RELATES_TO", msgID);
>         } // end if
> -
> +
>         InvokerAsyncResponse thePrevious =
> (InvokerAsyncResponse)getPrevious();
>         if (thePrevious != null ) thePrevious.invokeAsyncResponse(msg);
>     } // end method invokeAsyncResponse
> -
> +
>     public boolean isLocalSCABIndingInvoker() {
>         return true;
>     }
> -
> - private MessageFactory getMessageFactory() {
> - FactoryExtensionPoint modelFactories =
> registry.getExtensionPoint(FactoryExtensionPoint.class);
> - return modelFactories.getFactory(MessageFactory.class);
> - } // end method getMessageFactory
> +
> +    private MessageFactory getMessageFactory() {
> +        FactoryExtensionPoint modelFactories =
> registry.getExtensionPoint(FactoryExtensionPoint.class);
> +        return modelFactories.getFactory(MessageFactory.class);
> +    } // end method getMessageFactory
>
> }
>
> Modified:
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/LocalSCABindingProviderFactory.java
> URL:
> http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/LocalSCABindingProviderFactory.java?rev=1151632&r1=1151631&r2=1151632&view=diff
> ==============================================================================
> ---
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/LocalSCABindingProviderFactory.java
> (original)
> +++
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/LocalSCABindingProviderFactory.java
> Wed Jul 27 21:20:22 2011
> @@ -40,7 +40,7 @@ public class LocalSCABindingProviderFact
>
>     @Override
>     public ReferenceBindingProvider
> createReferenceBindingProvider(RuntimeEndpointReference endpointReference) {
> -        return new LocalSCAReferenceBindingProvider(extensionPoints,
> endpointReference, scaBindingMapper);
> +        return new DefaultLocalSCAReferenceBindingProvider(extensionPoints,
> endpointReference, scaBindingMapper);
>     }
>
>     @Override
>
> Added:
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCABindingProviderFactory.java
> URL:
> http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCABindingProviderFactory.java?rev=1151632&view=auto
> ==============================================================================
> ---
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCABindingProviderFactory.java
> (added)
> +++
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCABindingProviderFactory.java
> Wed Jul 27 21:20:22 2011
> @@ -0,0 +1,56 @@
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements.  See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership.  The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License.  You may obtain a copy of the License at
> + *
> + *   http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied.  See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + */
> +
> +package org.apache.tuscany.sca.binding.local;
> +
> +import org.apache.tuscany.sca.core.ExtensionPointRegistry;
> +import org.apache.tuscany.sca.core.UtilityExtensionPoint;
> +import org.apache.tuscany.sca.provider.BindingProviderFactory;
> +import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
> +import org.apache.tuscany.sca.provider.SCABindingMapper;
> +import org.apache.tuscany.sca.provider.ServiceBindingProvider;
> +import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
> +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
> +
> +public class XMLWFLocalSCABindingProviderFactory implements
> BindingProviderFactory<LocalSCABinding> {
> +    private ExtensionPointRegistry extensionPoints;
> +    private SCABindingMapper scaBindingMapper;
> +
> +    public XMLWFLocalSCABindingProviderFactory(ExtensionPointRegistry
> extensionPoints) {
> +        this.extensionPoints = extensionPoints;
> +        UtilityExtensionPoint utilities =
> extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
> +        this.scaBindingMapper =
> utilities.getUtility(SCABindingMapper.class);
> +    }
> +
> +    @Override
> +    public ReferenceBindingProvider
> createReferenceBindingProvider(RuntimeEndpointReference endpointReference) {
> +        return new XMLWFLocalSCAReferenceBindingProvider(extensionPoints,
> endpointReference, scaBindingMapper);
> +    }
> +
> +    @Override
> +    public ServiceBindingProvider
> createServiceBindingProvider(RuntimeEndpoint endpoint) {
> +        return new LocalSCAServiceBindingProvider(endpoint,
> scaBindingMapper);
> +    }
> +
> +    @Override
> +    public Class<LocalSCABinding> getModelType() {
> +        return LocalSCABinding.class;
> +    }
> +
> +}
>
> Added:
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCAReferenceBindingProvider.java
> URL:
> http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCAReferenceBindingProvider.java?rev=1151632&view=auto
> ==============================================================================
> ---
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCAReferenceBindingProvider.java
> (added)
> +++
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCAReferenceBindingProvider.java
> Wed Jul 27 21:20:22 2011
> @@ -0,0 +1,43 @@
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements.  See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership.  The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License.  You may obtain a copy of the License at
> + *
> + *   http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied.  See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + */
> +
> +package org.apache.tuscany.sca.binding.local;
> +
> +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.Operation;
> +import org.apache.tuscany.sca.invocation.InvocationChain;
> +import org.apache.tuscany.sca.provider.SCABindingMapper;
> +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
> +
> +public class XMLWFLocalSCAReferenceBindingProvider extends
> DefaultLocalSCAReferenceBindingProvider {
> +
> +    public XMLWFLocalSCAReferenceBindingProvider(ExtensionPointRegistry
> extensionPoints,
> +                                                 RuntimeEndpointReference
> endpointReference,
> +                                                 SCABindingMapper mapper) {
> +        super(extensionPoints, endpointReference, mapper);
> +    }
> +
> +    protected BindingSCATransformer getBindingTransformer(Operation
> operation, InvocationChain chain) {
> +        Operation wsdlBindingOperation =
> interfaceContractMapper.map(wsdlBindingInterfaceContract.getInterface(),
> operation);
> +        return new XMLWFBindingSCATransformer(mediator, operation,
> wsdlBindingOperation, chain);
> +    }
> +}
>
> Modified:
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DelegatingSCAReferenceBindingProvider.java
> URL:
> http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DelegatingSCAReferenceBindingProvider.java?rev=1151632&r1=1151631&r2=1151632&view=diff
> ==============================================================================
> ---
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DelegatingSCAReferenceBindingProvider.java
> (original)
> +++
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DelegatingSCAReferenceBindingProvider.java
> Wed Jul 27 21:20:22 2011
> @@ -20,7 +20,7 @@
> package org.apache.tuscany.sca.binding.sca.provider;
>
> import org.apache.tuscany.sca.assembly.SCABinding;
> -import
> org.apache.tuscany.sca.binding.local.LocalSCAReferenceBindingProvider;
> +import
> org.apache.tuscany.sca.binding.local.DefaultLocalSCAReferenceBindingProvider;
> import org.apache.tuscany.sca.interfacedef.InterfaceContract;
> import org.apache.tuscany.sca.interfacedef.Operation;
> import org.apache.tuscany.sca.invocation.Invoker;
> @@ -47,8 +47,8 @@ public class DelegatingSCAReferenceBindi
>
>             // reset the EPR to binding.sca EPR because the local
> optimization assumes
>             // this to be the case.
> -            if (provider instanceof LocalSCAReferenceBindingProvider){
> -
>                ((LocalSCAReferenceBindingProvider)provider).setEndpointReference(endpointReference);
> +            if (provider instanceof
> DefaultLocalSCAReferenceBindingProvider){
> +
>                ((DefaultLocalSCAReferenceBindingProvider)provider).setEndpointReference(endpointReference);
>             }
>         }
>     }
>
> Added:
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/BindingSCATransformer.java
> URL:
> http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/BindingSCATransformer.java?rev=1151632&view=auto
> ==============================================================================
> ---
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/BindingSCATransformer.java
> (added)
> +++
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/BindingSCATransformer.java
> Wed Jul 27 21:20:22 2011
> @@ -0,0 +1,26 @@
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements.  See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership.  The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License.  You may obtain a copy of the License at
> + *
> + *   http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied.  See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + */
> +
> +package org.apache.tuscany.sca.binding.sca.transform;
> +
> +public interface BindingSCATransformer {
> +    Object transformInput(Object body);
> +    Object transformOutput(Object body);
> +    Object transformFault(Object body);
> +}
>
> Added:
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/DefaultBindingSCATransformer.java
> URL:
> http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/DefaultBindingSCATransformer.java?rev=1151632&view=auto
> ==============================================================================
> ---
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/DefaultBindingSCATransformer.java
> (added)
> +++
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/DefaultBindingSCATransformer.java
> Wed Jul 27 21:20:22 2011
> @@ -0,0 +1,54 @@
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements.  See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership.  The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License.  You may obtain a copy of the License at
> + *
> + *   http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied.  See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + */
> +
> +package org.apache.tuscany.sca.binding.sca.transform;
> +
> +import org.apache.tuscany.sca.databinding.Mediator;
> +import org.apache.tuscany.sca.interfacedef.Operation;
> +import org.apache.tuscany.sca.invocation.InvocationChain;
> +
> +public class DefaultBindingSCATransformer implements BindingSCATransformer
> {
> +
> +    private Mediator mediator;
> +    private Operation sourceOperation;
> +    private Operation targetOperation;
> +
> +    public DefaultBindingSCATransformer(Mediator mediator, Operation
> sourceOperation, InvocationChain chain) {
> +        this.mediator = mediator;
> +        this.sourceOperation = sourceOperation;
> +        this.targetOperation = chain.getTargetOperation();
> +    }
> +
> +    @Override
> +    public Object transformInput(Object body) {
> +        return mediator.copyInput(body, sourceOperation, targetOperation);
> +    }
> +
> +    @Override
> +    public Object transformOutput(Object body) {
> +        return mediator.copyOutput(body, sourceOperation, targetOperation);
> +    }
> +
> +    @Override
> +    public Object transformFault(Object body) {
> +        return mediator.copyFault(body, sourceOperation, targetOperation);
> +    }
> +
> +}
> +
>
> Added:
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/XMLWFBindingSCATransformer.java
> URL:
> http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/XMLWFBindingSCATransformer.java?rev=1151632&view=auto
> ==============================================================================
> ---
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/XMLWFBindingSCATransformer.java
> (added)
> +++
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/XMLWFBindingSCATransformer.java
> Wed Jul 27 21:20:22 2011
> @@ -0,0 +1,74 @@
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements.  See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership.  The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License.  You may obtain a copy of the License at
> + *
> + *   http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied.  See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + */
> +
> +package org.apache.tuscany.sca.binding.sca.transform;
> +
> +import java.util.HashMap;
> +import java.util.Map;
> +
> +import org.apache.tuscany.sca.databinding.Mediator;
> +import org.apache.tuscany.sca.interfacedef.Operation;
> +import org.apache.tuscany.sca.invocation.InvocationChain;
> +
> +public class XMLWFBindingSCATransformer implements BindingSCATransformer {
> +
> +    private Mediator mediator;
> +    private Operation sourceOperation;
> +    private Operation wsdlBindingOperation;
> +    private Operation targetOperation;
> +
> +    public XMLWFBindingSCATransformer(Mediator mediator, Operation
> sourceOperation, Operation wsdlBindingOperation, InvocationChain chain) {
> +        this.mediator = mediator;
> +        this.sourceOperation = sourceOperation;
> +        this.wsdlBindingOperation = wsdlBindingOperation;
> +        this.targetOperation = chain.getTargetOperation();
> +    }
> +
> +    @Override
> +    public Object transformInput(Object body) {
> +        Map<String, Object> map1 = new HashMap<String, Object>();
> +        Object intermediate = mediator.mediateInput(body, sourceOperation,
> wsdlBindingOperation, map1);
> +        Map<String, Object> map2 = new HashMap<String, Object>();
> +        Object result  = mediator.mediateInput(intermediate,
> wsdlBindingOperation, targetOperation, map2);
> +        return result;
> +    }
> +
> +    @Override
> +    public Object transformOutput(Object body) {
> +        Map<String, Object> map1 = new HashMap<String, Object>();
>
> +        Object intermediate  = mediator.mediateOutput(body,
> wsdlBindingOperation, targetOperation, map1);
> +        Map<String, Object> map2 = new HashMap<String, Object>();
> +        Object result = mediator.mediateOutput(intermediate,
> sourceOperation, wsdlBindingOperation, map2);
> +
> +        return result;
> +
> +    }
> +
> +    @Override
> +    public Object transformFault(Object body) {
> +        Map<String, Object> map1 = new HashMap<String, Object>();
> +        Object intermediate = mediator.mediateFault(body,
> wsdlBindingOperation, targetOperation, map1);
> +        Map<String, Object> map2 = new HashMap<String, Object>();
> +        Object result  = mediator.mediateFault(intermediate,
> sourceOperation, wsdlBindingOperation, map2);
> +        return result;
> +
> +    }
> +
> +}
> +
>
> Modified:
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
> URL:
> http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory?rev=1151632&r1=1151631&r2=1151632&view=diff
> ==============================================================================
> ---
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
> (original)
> +++
> tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
> Wed Jul 27 21:20:22 2011
> @@ -17,4 +17,5 @@
>
> # Implementation class for the binding extension
> org.apache.tuscany.sca.binding.sca.provider.RuntimeSCABindingProviderFactory;model=org.apache.tuscany.sca.assembly.SCABinding
> +#org.apache.tuscany.sca.binding.local.XMLWFLocalSCABindingProviderFactory;model=org.apache.tuscany.sca.binding.local.LocalSCABinding
> org.apache.tuscany.sca.binding.local.LocalSCABindingProviderFactory;model=org.apache.tuscany.sca.binding.local.LocalSCABinding
>
>
>
>

Reply via email to