You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by Jean-Sebastien Delfino <js...@apache.org> on 2010/08/29 20:29:38 UTC

Sample component implementation extension

I've committed a new sample [1] to help people understand how to extend 
Tuscany 2.x with a new component implementation type.

The sample extends Tuscany with a fictitious component implementation 
and shows how to:
- read/write SCDL and resolve WSDL and Java in an ArtifactProcessor;
- manage the lifecycle of a component in an ImplementationProvider;
- support both WSDL and Java interfaces;
- flow component invocations through Invokers and Proxies;
- represent data using Java and DOM data bindings;
- run components in a Junit test case.

I'm still working on it and will try to document these aspects in the 
sample README. I'm also going to add a test case or two showing how to 
code the construction of a SCDL in-memory model and run off of it.

Hope this helps.
[1] 
http://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/samples/implementation-extension/
-- 
Jean-Sebastien

Re: Sample component implementation extension

Posted by Jean-Sebastien Delfino <js...@apache.org>.
Jean-Sebastien Delfino wrote:
> Jean-Sebastien Delfino wrote:
>> Jean-Sebastien Delfino wrote:
>>> Jean-Sebastien Delfino wrote:
>>>> I've committed a new sample [1] to help people understand how to 
>>>> extend Tuscany 2.x with a new component implementation type.
>>>>
>>>> The sample extends Tuscany with a fictitious component 
>>>> implementation and shows how to:
>>>> - read/write SCDL and resolve WSDL and Java in an ArtifactProcessor;
>>>> - manage the lifecycle of a component in an ImplementationProvider;
>>>> - support both WSDL and Java interfaces;
>>>> - flow component invocations through Invokers and Proxies;
>>>> - represent data using Java and DOM data bindings;
>>>> - run components in a Junit test case.
>>>>
>>>> I'm still working on it and will try to document these aspects in 
>>>> the sample README. I'm also going to add a test case or two showing 
>>>> how to code the construction of a SCDL in-memory model and run off 
>>>> of it.
>>>
>>> I've improved the sample a bit and added code that shows how to:
>>>
>>> 1) create contribution and SCDL composite models programmatically;
>>>
>>> 2) register a ProviderFactory instance (as it may be more convenient 
>>> than having it loaded and instantiated by the runtime, if for example 
>>> you want to pass something to it);
>>>
>>> 3) bootstrap and run a Tuscany Node out of that.
>>>
>>> For (3) I had to add a new NodeFactory.createNode() method taking a 
>>> list of pre-built contribution models, matching the existing 
>>> NodeImpl( NodeFactoryImpl manager, NodeConfiguration configuration, 
>>> List< Contribution> contributions) constructor.
>>
>> Next step, I'm going to add Web service bindings to the sample, to 
>> show how that works, and how multiple databindings can be used in an 
>> app (DOM in the component impl, and AXIOM with Axis2).
> 
> Done in SVN revision r992153. I've added a component with a service and 
> reference configured with <binding.ws> to test.composite [2], and a test 
> case that communicates with it over SOAP [3].
> 
> As a side comment, the test case shows how easy it is to call and 
> implement a simple SOAP Web Service with barebones java.net.Socket and 
> javax.servlet.http.HttpServlet :)
> 
>>
>> Quick question: if I need multiple databindings on an interface, do I 
>> need to clone that interface model in my SCDL processor (one per 
>> databinding), or can multiple databindings co-exist on the same instance?
> 
> After digging through the data binding code, looks like the answer is 
> that the interface must be cloned. I adjusted the sample SCDL processor 
> to do that.
> 

I've made a few more changes in SVN r996622. EmbedUtil is now using a 
builder pattern and closures to pass a node factory context around 
instead of keeping it in static variables. Each JUnit test case is now 
getting a new node factory, extension point registry etc, which is 
cleaner too.

Hope this helps.

>>>> [1] 
>>>> http://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/samples/implementation-extension/ 
> 
> 
> [2] 
> http://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/samples/implementation-extension/src/test/resources/test.composite 
> 
> [3] 
> http://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/samples/implementation-extension/src/test/java/sample/impl/RunWSTestCase.java 
> 
-- 
Jean-Sebastien

Re: Sample component implementation extension

Posted by Simon Laws <si...@googlemail.com>.
>
>>
>> Quick question: if I need multiple databindings on an interface, do I need
>> to clone that interface model in my SCDL processor (one per databinding), or
>> can multiple databindings co-exist on the same instance?
>
> After digging through the data binding code, looks like the answer is that
> the interface must be cloned. I adjusted the sample SCDL processor to do
> that.
>

Slow answer (sorry about that): yes you have to clone I believe. The
databinding required at the binding is set into the interface by the
binding so each binding needs it's own copy of the interface. When the
DatabindingRuntimeWireProcessor (see core-databinding) looks at each
wire (there is a wire per service interface operation per binding) it
compares the binding interface databinding with the implementation
interface databinding and adds a databinding inteceptor accordingly.

Regards

Simon

-- 
Apache Tuscany committer: tuscany.apache.org
Co-author of a book about Tuscany and SCA: tuscanyinaction.com

Re: Sample component implementation extension

Posted by Jean-Sebastien Delfino <js...@apache.org>.
Jean-Sebastien Delfino wrote:
> Jean-Sebastien Delfino wrote:
>> Jean-Sebastien Delfino wrote:
>>> I've committed a new sample [1] to help people understand how to 
>>> extend Tuscany 2.x with a new component implementation type.
>>>
>>> The sample extends Tuscany with a fictitious component implementation 
>>> and shows how to:
>>> - read/write SCDL and resolve WSDL and Java in an ArtifactProcessor;
>>> - manage the lifecycle of a component in an ImplementationProvider;
>>> - support both WSDL and Java interfaces;
>>> - flow component invocations through Invokers and Proxies;
>>> - represent data using Java and DOM data bindings;
>>> - run components in a Junit test case.
>>>
>>> I'm still working on it and will try to document these aspects in the 
>>> sample README. I'm also going to add a test case or two showing how 
>>> to code the construction of a SCDL in-memory model and run off of it.
>>
>> I've improved the sample a bit and added code that shows how to:
>>
>> 1) create contribution and SCDL composite models programmatically;
>>
>> 2) register a ProviderFactory instance (as it may be more convenient 
>> than having it loaded and instantiated by the runtime, if for example 
>> you want to pass something to it);
>>
>> 3) bootstrap and run a Tuscany Node out of that.
>>
>> For (3) I had to add a new NodeFactory.createNode() method taking a 
>> list of pre-built contribution models, matching the existing NodeImpl( 
>> NodeFactoryImpl manager, NodeConfiguration configuration, List< 
>> Contribution> contributions) constructor.
> 
> Next step, I'm going to add Web service bindings to the sample, to show 
> how that works, and how multiple databindings can be used in an app (DOM 
> in the component impl, and AXIOM with Axis2).

Done in SVN revision r992153. I've added a component with a service and 
reference configured with <binding.ws> to test.composite [2], and a test 
case that communicates with it over SOAP [3].

As a side comment, the test case shows how easy it is to call and 
implement a simple SOAP Web Service with barebones java.net.Socket and 
javax.servlet.http.HttpServlet :)

> 
> Quick question: if I need multiple databindings on an interface, do I 
> need to clone that interface model in my SCDL processor (one per 
> databinding), or can multiple databindings co-exist on the same instance?

After digging through the data binding code, looks like the answer is 
that the interface must be cloned. I adjusted the sample SCDL processor 
to do that.

>>
>>> Hope this helps.
>>> [1] 
>>> http://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/samples/implementation-extension/ 

[2] 
http://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/samples/implementation-extension/src/test/resources/test.composite
[3] 
http://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/samples/implementation-extension/src/test/java/sample/impl/RunWSTestCase.java

-- 
Jean-Sebastien

Re: Sample component implementation extension

Posted by Jean-Sebastien Delfino <js...@apache.org>.
Jean-Sebastien Delfino wrote:
> Jean-Sebastien Delfino wrote:
>> I've committed a new sample [1] to help people understand how to 
>> extend Tuscany 2.x with a new component implementation type.
>>
>> The sample extends Tuscany with a fictitious component implementation 
>> and shows how to:
>> - read/write SCDL and resolve WSDL and Java in an ArtifactProcessor;
>> - manage the lifecycle of a component in an ImplementationProvider;
>> - support both WSDL and Java interfaces;
>> - flow component invocations through Invokers and Proxies;
>> - represent data using Java and DOM data bindings;
>> - run components in a Junit test case.
>>
>> I'm still working on it and will try to document these aspects in the 
>> sample README. I'm also going to add a test case or two showing how to 
>> code the construction of a SCDL in-memory model and run off of it.
> 
> I've improved the sample a bit and added code that shows how to:
> 
> 1) create contribution and SCDL composite models programmatically;
> 
> 2) register a ProviderFactory instance (as it may be more convenient 
> than having it loaded and instantiated by the runtime, if for example 
> you want to pass something to it);
> 
> 3) bootstrap and run a Tuscany Node out of that.
> 
> For (3) I had to add a new NodeFactory.createNode() method taking a list 
> of pre-built contribution models, matching the existing NodeImpl( 
> NodeFactoryImpl manager, NodeConfiguration configuration, List< 
> Contribution> contributions) constructor.

Next step, I'm going to add Web service bindings to the sample, to show 
how that works, and how multiple databindings can be used in an app (DOM 
in the component impl, and AXIOM with Axis2).

Quick question: if I need multiple databindings on an interface, do I 
need to clone that interface model in my SCDL processor (one per 
databinding), or can multiple databindings co-exist on the same instance?

> 
>> Hope this helps.
>> [1] 
>> http://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/samples/implementation-extension/ 
-- 
Jean-Sebastien

Re: Sample component implementation extension

Posted by Jean-Sebastien Delfino <js...@apache.org>.
Jean-Sebastien Delfino wrote:
> I've committed a new sample [1] to help people understand how to extend 
> Tuscany 2.x with a new component implementation type.
> 
> The sample extends Tuscany with a fictitious component implementation 
> and shows how to:
> - read/write SCDL and resolve WSDL and Java in an ArtifactProcessor;
> - manage the lifecycle of a component in an ImplementationProvider;
> - support both WSDL and Java interfaces;
> - flow component invocations through Invokers and Proxies;
> - represent data using Java and DOM data bindings;
> - run components in a Junit test case.
> 
> I'm still working on it and will try to document these aspects in the 
> sample README. I'm also going to add a test case or two showing how to 
> code the construction of a SCDL in-memory model and run off of it.

I've improved the sample a bit and added code that shows how to:

1) create contribution and SCDL composite models programmatically;

2) register a ProviderFactory instance (as it may be more convenient 
than having it loaded and instantiated by the runtime, if for example 
you want to pass something to it);

3) bootstrap and run a Tuscany Node out of that.

For (3) I had to add a new NodeFactory.createNode() method taking a list 
of pre-built contribution models, matching the existing NodeImpl( 
NodeFactoryImpl manager, NodeConfiguration configuration, List< 
Contribution> contributions) constructor.

> Hope this helps.
> [1] 
> http://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/samples/implementation-extension/ 
> 
-- 
Jean-Sebastien