You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by Rajini Sivaram <ra...@googlemail.com> on 2007/10/04 16:35:09 UTC

Using Tuscany as a library

Hello,

I would like to use Tuscany as a library (rather than a runtime) to parse a
reference or service definition containing bindings, and obtain a proxy to a
service.

At the moment, I create a composite containing a dummy component with a
reference, and then create an SCA domain, add a contribution containing the
composite, and then obtain the reference and get a proxy through the
runtimeWire. Apart from being very messy, this requires a large number of
Tuscany modules to be in the classpath.

Is there a better way for me to use the modules in Tuscany - specifically
the bindings modules?

Thank you...

Regards,

Rajini

Re: Using Tuscany as a library

Posted by Simon Laws <si...@googlemail.com>.
Some more comments in line.

Regards

Simon

On 10/5/07, Rajini Sivaram <ra...@googlemail.com> wrote:
>
> Simon,
>
> Thank you for your reply.
>
> I haven't looked at the node APIs yet, so I will take a look.
>
> I think I will be able to use SCADomainFinder in the scenario that I have
> at
> the moment, where an OSGi service is exposed as a remote service through
> SCA, and a remote reference is obtained in another OSGi runtime also using
> SCA. But in the general case, I might (I think) want  to use SCA to create
> a
> proxy to a remote web service where the service itself  is not exposed
> through SCA.  If I want to use SCADomainFinder to obtain the domain and
> then
> use it to find the web service, presumably I have to create an SCA domain
> with a service definition for the webservice. Or a reference definition.
> But


Yes. The interfaces we have for creating service references, whether  to
local or remote services, rely on the referenced service being available in
the SCA domain. If you are trying to create a service reference to a service
that is not in the SCA Domain then you need to be able to describe
sufficient information about where the service is and what binding is
required, for example, using your SCDL,

           <component name="HelloWorldServiceComponent">
                  <implementation.java class="helloworld.DummyImpl" />
                  <reference name="helloWorldService">
                       <interface.java interface="
helloworld.HelloWorldService" />
                       <binding.ws wsdlElement="
http://helloworld#wsdl.port(HelloWorldService/HelloWorldSoapPort)<http://helloworld/#wsdl.port%28HelloWorldService/HelloWorldSoapPort%29>
"/<http://helloworld/#wsdl.port(HelloWorldService/HelloWorldSoapPort)<http://helloworld/#wsdl.port%28HelloWorldService/HelloWorldSoapPort%29>
"/>
>
                  </reference>
           </component>

This is not something you can do using the domain interface so yes you would
need to create a composite to hold this information. I would actually like
to see some of this capability. I have come across a situation where I
wanted to create a blank reference and then configure it with binding and
endpoint information. I wanted to do this just to remove the necessity for
me to write, in my case, Axis client API code. Not something we can do
today.


I am not sure how that domain could be created with these definitions
> without a component definition. I am obviously confused, so I will look at
> the node APIs before asking stupid questions.


Has my answer above made things clearer?

Thank you...
>
> Regards,
>
> Rajini
>
>
> On 10/5/07, Simon Laws <si...@googlemail.com> wrote:
> >
> > On 10/5/07, Rajini Sivaram <ra...@googlemail.com> wrote:
> > >
> > > Simon,
> > >
> > > The service that the reference is wired to is not in the same JVM. At
> > the
> > > moment, the component definition looks like this:
> > >
> > >     <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
> > >             targetNamespace="http://osgidistribution"
> > >             name="helloworldreference">
> > >
> > >             <component name="HelloWorldServiceComponent">
> > >                    <implementation.java class="helloworld.DummyImpl"
> />
> > >                    <reference name="helloWorldService">
> > >                         <interface.java interface="
> > > helloworld.HelloWorldService" />
> > >                         <binding.ws wsdlElement="
> > > http://helloworld#wsdl.port(HelloWorldService/HelloWorldSoapPort)"/<
> > > http://helloworld/#wsdl.port(HelloWorldService/HelloWorldSoapPort)"/>
> > > >
> > >                    </reference>
> > >             </component>
> > >
> > >    </composite>
> > > I would like to get hold of the proxy corresponding to the reference
> and
> > > add
> > > it to the OSGi registry so that an OSGi bundle which has no knowledge
> of
> > > SCA
> > > can lookup the proxy in its OSGi registry and invoke the service
> through
> > > this proxy. The OSGi bundle which wants to use this reference is not
> > > running
> > > in an SCA runtime. It is running in an OSGi runtime and uses its
> normal
> > > OSGi
> > > registry lookup (with no remote service support) to resolve its
> > > references.
> > > We would like to use Tuscany to parse the metadata corresponding to
> the
> > > reference element above and create a proxy for the remote service
> which
> > is
> > > then registered with the OSGi registry.
> > >
> > > Which code in Tuscany should I look at to create a reference on the
> fly?
> > >
> > >
> > > Thank you...
> > >
> > > Regards,
> > >
> > > Rajini
> > >
> > >
> > > On 10/5/07, Simon Laws <si...@googlemail.com> wrote:
> > > >
> > > > On 10/4/07, Rajini Sivaram <ra...@googlemail.com> wrote:
> > > > >
> > > > > Hello,
> > > > >
> > > > > I would like to use Tuscany as a library (rather than a runtime)
> to
> > > > parse
> > > > > a
> > > > > reference or service definition containing bindings, and obtain a
> > > proxy
> > > > to
> > > > > a
> > > > > service.
> > > > >
> > > > > At the moment, I create a composite containing a dummy component
> > with
> > > a
> > > > > reference, and then create an SCA domain, add a contribution
> > > containing
> > > > > the
> > > > > composite, and then obtain the reference and get a proxy through
> the
> > > > > runtimeWire. Apart from being very messy, this requires a large
> > number
> > > > of
> > > > > Tuscany modules to be in the classpath.
> > > > >
> > > > > Is there a better way for me to use the modules in Tuscany -
> > > > specifically
> > > > > the bindings modules?
> > > > >
> > > > > Thank you...
> > > > >
> > > > > Regards,
> > > > >
> > > > > Rajini
> > > > >
> > > > Hi Rajini
> > > >
> > > > Is the service you are trying to get a reference to local to the JVM
> > you
> > > > are
> > > > running in?
> > > >
> > > > If yes, what runtime is the component/service running it?
> > > >
> > > > If no,  then the tuscany code should already be able to construct a
> > > > reference on the fly for you without you having to go through the
> > > process
> > > > of
> > > > creating the dummy component. The code in getService looks in the
> > local
> > > > model and if it can't find the required service creates a unresolved
> > > > reference which will be resolved when you try to use it. This relies
> > on
> > > > using the distributed domain support.
> > > >
> > > > Can you say a bit more about the scenario you are working with?
> > > >
> > > > Regards
> > > >
> > > > Simon
> > > >
> > >
> > I'm going to talk in terms of the new domain and node apis. Within a
> given
> > domain I would expect you to be able to get hold of the domain and ask
> it
> > for a reference to a service that exists in the domain. The reference
> > returned with hide whether that service is local or remote.  So that is
> > the
> > intention, if you look at some of the code in the node implementation
> you
> > can see this at work..
> >
> >
> >
> http://svn.apache.org/repos/asf/incubator/tuscany/java/sca/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeDrivenTestCase.java
> >
> > Here you see that a number of nodes are created and contributions are
> > added
> > and toward the end you see local references being extracted. Right at
> the
> > end you see a reference being retrieved for a service that is not in the
> > node being asked.
> >
> > addServiceB = nodeA.getDomain().getService(AddService.class,
> > "AddServiceComponentB");
> >
> >
> > The domain that the node belongs to is retrieved from the node and the
> > domain is asked for a reference to the required service. In this case
> the
> > AddServiceComponentB is not in nodeA so a remote reference is created.
> >
> > Now this doesn;t necessarily meet your requirements as I had to create a
> > node here. As part of the new interfaces there is a domain finder
> > mechanism
> >
> > SCADomainFinder domainFinder = SCADomainFinder.newInstance();
> > SCADomain domain = domainFinder.getDomain(domainName);
> >
> > This provides an SCADomain interface that you can then call getService
> on.
> > The resulting reference can be stored somewhere (your OSGi registry) for
> > future use. The slight drawback is that this doesn't work properly just
> > yet
> > (a little more work required). However if it did work would this fit the
> > bill?
> >
> > Regards
> >
> > Simon
> >
>

Re: Using Tuscany as a library

Posted by Rajini Sivaram <ra...@googlemail.com>.
Simon,

Thank you for your reply.

I haven't looked at the node APIs yet, so I will take a look.

I think I will be able to use SCADomainFinder in the scenario that I have at
the moment, where an OSGi service is exposed as a remote service through
SCA, and a remote reference is obtained in another OSGi runtime also using
SCA. But in the general case, I might (I think) want  to use SCA to create a
proxy to a remote web service where the service itself  is not exposed
through SCA.  If I want to use SCADomainFinder to obtain the domain and then
use it to find the web service, presumably I have to create an SCA domain
with a service definition for the webservice. Or a reference definition. But
I am not sure how that domain could be created with these definitions
without a component definition. I am obviously confused, so I will look at
the node APIs before asking stupid questions.

Thank you...

Regards,

Rajini


On 10/5/07, Simon Laws <si...@googlemail.com> wrote:
>
> On 10/5/07, Rajini Sivaram <ra...@googlemail.com> wrote:
> >
> > Simon,
> >
> > The service that the reference is wired to is not in the same JVM. At
> the
> > moment, the component definition looks like this:
> >
> >     <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
> >             targetNamespace="http://osgidistribution"
> >             name="helloworldreference">
> >
> >             <component name="HelloWorldServiceComponent">
> >                    <implementation.java class="helloworld.DummyImpl" />
> >                    <reference name="helloWorldService">
> >                         <interface.java interface="
> > helloworld.HelloWorldService" />
> >                         <binding.ws wsdlElement="
> > http://helloworld#wsdl.port(HelloWorldService/HelloWorldSoapPort)"/<
> > http://helloworld/#wsdl.port(HelloWorldService/HelloWorldSoapPort)"/>
> > >
> >                    </reference>
> >             </component>
> >
> >    </composite>
> > I would like to get hold of the proxy corresponding to the reference and
> > add
> > it to the OSGi registry so that an OSGi bundle which has no knowledge of
> > SCA
> > can lookup the proxy in its OSGi registry and invoke the service through
> > this proxy. The OSGi bundle which wants to use this reference is not
> > running
> > in an SCA runtime. It is running in an OSGi runtime and uses its normal
> > OSGi
> > registry lookup (with no remote service support) to resolve its
> > references.
> > We would like to use Tuscany to parse the metadata corresponding to the
> > reference element above and create a proxy for the remote service which
> is
> > then registered with the OSGi registry.
> >
> > Which code in Tuscany should I look at to create a reference on the fly?
> >
> >
> > Thank you...
> >
> > Regards,
> >
> > Rajini
> >
> >
> > On 10/5/07, Simon Laws <si...@googlemail.com> wrote:
> > >
> > > On 10/4/07, Rajini Sivaram <ra...@googlemail.com> wrote:
> > > >
> > > > Hello,
> > > >
> > > > I would like to use Tuscany as a library (rather than a runtime) to
> > > parse
> > > > a
> > > > reference or service definition containing bindings, and obtain a
> > proxy
> > > to
> > > > a
> > > > service.
> > > >
> > > > At the moment, I create a composite containing a dummy component
> with
> > a
> > > > reference, and then create an SCA domain, add a contribution
> > containing
> > > > the
> > > > composite, and then obtain the reference and get a proxy through the
> > > > runtimeWire. Apart from being very messy, this requires a large
> number
> > > of
> > > > Tuscany modules to be in the classpath.
> > > >
> > > > Is there a better way for me to use the modules in Tuscany -
> > > specifically
> > > > the bindings modules?
> > > >
> > > > Thank you...
> > > >
> > > > Regards,
> > > >
> > > > Rajini
> > > >
> > > Hi Rajini
> > >
> > > Is the service you are trying to get a reference to local to the JVM
> you
> > > are
> > > running in?
> > >
> > > If yes, what runtime is the component/service running it?
> > >
> > > If no,  then the tuscany code should already be able to construct a
> > > reference on the fly for you without you having to go through the
> > process
> > > of
> > > creating the dummy component. The code in getService looks in the
> local
> > > model and if it can't find the required service creates a unresolved
> > > reference which will be resolved when you try to use it. This relies
> on
> > > using the distributed domain support.
> > >
> > > Can you say a bit more about the scenario you are working with?
> > >
> > > Regards
> > >
> > > Simon
> > >
> >
> I'm going to talk in terms of the new domain and node apis. Within a given
> domain I would expect you to be able to get hold of the domain and ask it
> for a reference to a service that exists in the domain. The reference
> returned with hide whether that service is local or remote.  So that is
> the
> intention, if you look at some of the code in the node implementation you
> can see this at work..
>
>
> http://svn.apache.org/repos/asf/incubator/tuscany/java/sca/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeDrivenTestCase.java
>
> Here you see that a number of nodes are created and contributions are
> added
> and toward the end you see local references being extracted. Right at the
> end you see a reference being retrieved for a service that is not in the
> node being asked.
>
> addServiceB = nodeA.getDomain().getService(AddService.class,
> "AddServiceComponentB");
>
>
> The domain that the node belongs to is retrieved from the node and the
> domain is asked for a reference to the required service. In this case the
> AddServiceComponentB is not in nodeA so a remote reference is created.
>
> Now this doesn;t necessarily meet your requirements as I had to create a
> node here. As part of the new interfaces there is a domain finder
> mechanism
>
> SCADomainFinder domainFinder = SCADomainFinder.newInstance();
> SCADomain domain = domainFinder.getDomain(domainName);
>
> This provides an SCADomain interface that you can then call getService on.
> The resulting reference can be stored somewhere (your OSGi registry) for
> future use. The slight drawback is that this doesn't work properly just
> yet
> (a little more work required). However if it did work would this fit the
> bill?
>
> Regards
>
> Simon
>

Re: Using Tuscany as a library

Posted by Simon Laws <si...@googlemail.com>.
On 10/5/07, Rajini Sivaram <ra...@googlemail.com> wrote:
>
> Simon,
>
> The service that the reference is wired to is not in the same JVM. At the
> moment, the component definition looks like this:
>
>     <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
>             targetNamespace="http://osgidistribution"
>             name="helloworldreference">
>
>             <component name="HelloWorldServiceComponent">
>                    <implementation.java class="helloworld.DummyImpl" />
>                    <reference name="helloWorldService">
>                         <interface.java interface="
> helloworld.HelloWorldService" />
>                         <binding.ws wsdlElement="
> http://helloworld#wsdl.port(HelloWorldService/HelloWorldSoapPort)"/<
> http://helloworld/#wsdl.port(HelloWorldService/HelloWorldSoapPort)"/>
> >
>                    </reference>
>             </component>
>
>    </composite>
> I would like to get hold of the proxy corresponding to the reference and
> add
> it to the OSGi registry so that an OSGi bundle which has no knowledge of
> SCA
> can lookup the proxy in its OSGi registry and invoke the service through
> this proxy. The OSGi bundle which wants to use this reference is not
> running
> in an SCA runtime. It is running in an OSGi runtime and uses its normal
> OSGi
> registry lookup (with no remote service support) to resolve its
> references.
> We would like to use Tuscany to parse the metadata corresponding to the
> reference element above and create a proxy for the remote service which is
> then registered with the OSGi registry.
>
> Which code in Tuscany should I look at to create a reference on the fly?
>
>
> Thank you...
>
> Regards,
>
> Rajini
>
>
> On 10/5/07, Simon Laws <si...@googlemail.com> wrote:
> >
> > On 10/4/07, Rajini Sivaram <ra...@googlemail.com> wrote:
> > >
> > > Hello,
> > >
> > > I would like to use Tuscany as a library (rather than a runtime) to
> > parse
> > > a
> > > reference or service definition containing bindings, and obtain a
> proxy
> > to
> > > a
> > > service.
> > >
> > > At the moment, I create a composite containing a dummy component with
> a
> > > reference, and then create an SCA domain, add a contribution
> containing
> > > the
> > > composite, and then obtain the reference and get a proxy through the
> > > runtimeWire. Apart from being very messy, this requires a large number
> > of
> > > Tuscany modules to be in the classpath.
> > >
> > > Is there a better way for me to use the modules in Tuscany -
> > specifically
> > > the bindings modules?
> > >
> > > Thank you...
> > >
> > > Regards,
> > >
> > > Rajini
> > >
> > Hi Rajini
> >
> > Is the service you are trying to get a reference to local to the JVM you
> > are
> > running in?
> >
> > If yes, what runtime is the component/service running it?
> >
> > If no,  then the tuscany code should already be able to construct a
> > reference on the fly for you without you having to go through the
> process
> > of
> > creating the dummy component. The code in getService looks in the local
> > model and if it can't find the required service creates a unresolved
> > reference which will be resolved when you try to use it. This relies on
> > using the distributed domain support.
> >
> > Can you say a bit more about the scenario you are working with?
> >
> > Regards
> >
> > Simon
> >
>
I'm going to talk in terms of the new domain and node apis. Within a given
domain I would expect you to be able to get hold of the domain and ask it
for a reference to a service that exists in the domain. The reference
returned with hide whether that service is local or remote.  So that is the
intention, if you look at some of the code in the node implementation you
can see this at work..

http://svn.apache.org/repos/asf/incubator/tuscany/java/sca/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeDrivenTestCase.java

Here you see that a number of nodes are created and contributions are added
and toward the end you see local references being extracted. Right at the
end you see a reference being retrieved for a service that is not in the
node being asked.

addServiceB = nodeA.getDomain().getService(AddService.class,
"AddServiceComponentB");


The domain that the node belongs to is retrieved from the node and the
domain is asked for a reference to the required service. In this case the
AddServiceComponentB is not in nodeA so a remote reference is created.

Now this doesn;t necessarily meet your requirements as I had to create a
node here. As part of the new interfaces there is a domain finder mechanism

  SCADomainFinder domainFinder = SCADomainFinder.newInstance();
  SCADomain domain = domainFinder.getDomain(domainName);

This provides an SCADomain interface that you can then call getService on.
The resulting reference can be stored somewhere (your OSGi registry) for
future use. The slight drawback is that this doesn't work properly just yet
(a little more work required). However if it did work would this fit the
bill?

Regards

Simon

Re: Using Tuscany as a library

Posted by Rajini Sivaram <ra...@googlemail.com>.
Simon,

The service that the reference is wired to is not in the same JVM. At the
moment, the component definition looks like this:

    <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
            targetNamespace="http://osgidistribution"
            name="helloworldreference">

            <component name="HelloWorldServiceComponent">
                   <implementation.java class="helloworld.DummyImpl" />
                   <reference name="helloWorldService">
                        <interface.java interface="
helloworld.HelloWorldService" />
                        <binding.ws wsdlElement="
http://helloworld#wsdl.port(HelloWorldService/HelloWorldSoapPort)"/<http://helloworld/#wsdl.port(HelloWorldService/HelloWorldSoapPort)"/>
>
                   </reference>
            </component>

   </composite>
I would like to get hold of the proxy corresponding to the reference and add
it to the OSGi registry so that an OSGi bundle which has no knowledge of SCA
can lookup the proxy in its OSGi registry and invoke the service through
this proxy. The OSGi bundle which wants to use this reference is not running
in an SCA runtime. It is running in an OSGi runtime and uses its normal OSGi
registry lookup (with no remote service support) to resolve its references.
We would like to use Tuscany to parse the metadata corresponding to the
reference element above and create a proxy for the remote service which is
then registered with the OSGi registry.

Which code in Tuscany should I look at to create a reference on the fly?


Thank you...

Regards,

Rajini


On 10/5/07, Simon Laws <si...@googlemail.com> wrote:
>
> On 10/4/07, Rajini Sivaram <ra...@googlemail.com> wrote:
> >
> > Hello,
> >
> > I would like to use Tuscany as a library (rather than a runtime) to
> parse
> > a
> > reference or service definition containing bindings, and obtain a proxy
> to
> > a
> > service.
> >
> > At the moment, I create a composite containing a dummy component with a
> > reference, and then create an SCA domain, add a contribution containing
> > the
> > composite, and then obtain the reference and get a proxy through the
> > runtimeWire. Apart from being very messy, this requires a large number
> of
> > Tuscany modules to be in the classpath.
> >
> > Is there a better way for me to use the modules in Tuscany -
> specifically
> > the bindings modules?
> >
> > Thank you...
> >
> > Regards,
> >
> > Rajini
> >
> Hi Rajini
>
> Is the service you are trying to get a reference to local to the JVM you
> are
> running in?
>
> If yes, what runtime is the component/service running it?
>
> If no,  then the tuscany code should already be able to construct a
> reference on the fly for you without you having to go through the process
> of
> creating the dummy component. The code in getService looks in the local
> model and if it can't find the required service creates a unresolved
> reference which will be resolved when you try to use it. This relies on
> using the distributed domain support.
>
> Can you say a bit more about the scenario you are working with?
>
> Regards
>
> Simon
>

Re: Using Tuscany as a library

Posted by Simon Laws <si...@googlemail.com>.
On 10/4/07, Rajini Sivaram <ra...@googlemail.com> wrote:
>
> Hello,
>
> I would like to use Tuscany as a library (rather than a runtime) to parse
> a
> reference or service definition containing bindings, and obtain a proxy to
> a
> service.
>
> At the moment, I create a composite containing a dummy component with a
> reference, and then create an SCA domain, add a contribution containing
> the
> composite, and then obtain the reference and get a proxy through the
> runtimeWire. Apart from being very messy, this requires a large number of
> Tuscany modules to be in the classpath.
>
> Is there a better way for me to use the modules in Tuscany - specifically
> the bindings modules?
>
> Thank you...
>
> Regards,
>
> Rajini
>
Hi Rajini

Is the service you are trying to get a reference to local to the JVM you are
running in?

If yes, what runtime is the component/service running it?

If no,  then the tuscany code should already be able to construct a
reference on the fly for you without you having to go through the process of
creating the dummy component. The code in getService looks in the local
model and if it can't find the required service creates a unresolved
reference which will be resolved when you try to use it. This relies on
using the distributed domain support.

Can you say a bit more about the scenario you are working with?

Regards

Simon