You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by Jared Ladner <ja...@gmail.com> on 2009/01/15 17:42:08 UTC

Dynamic Service Binding

Hi,

I have been reviewing Tuscany SCA for a couple of days and I am trying to
determine if it will suit my requirements for dynamically locating services
(dynamically meaning using a config file and no code changes).

I have an application that needs to locate new service implementations of a
non remote Java Interface.  The Implementation is simply a JAR that is
dropped into the classpath.  I would like to only add the new service/JAR as
a config entry into the Tuscany '*.composite' file without making any code
changes.  A server restart is acceptable.  Is this possible?

Sequence
1. Input to 'core' application is Web Service (does not need to be
associated with Tuscany SCA)
2. Core app will find available services loadded from the Tuscany SCA
3. Make API calls (from non remote Interface) to all available services.

The Services are simple Java Interfaces.  Currently they are NOT web
services or even remote, but will only be JAR file added to the classpath.

The examples that I have seen define the services as a reference in the
'*.composite' file.  This is fine but the implemenation code that uses the
reference is hard coded to have a matching reference member variable.  I
need this to be dynamic.

Please help!

Thanks,
Jared
SCJD,SCWCD,SCBCD

Re: Dynamic Service Binding

Posted by Jared Ladner <ja...@gmail.com>.
Thanks for the help.  The example you provide is very close to what I want.
This will get me started.

On Fri, Jan 16, 2009 at 8:23 AM, ant elder <an...@gmail.com> wrote:

>
>
> On Fri, Jan 16, 2009 at 2:09 PM, Simon Laws <si...@googlemail.com>wrote:
>
>>
>>
>> On Thu, Jan 15, 2009 at 4:42 PM, Jared Ladner <ja...@gmail.com>wrote:
>>
>>> Hi,
>>>
>>> I have been reviewing Tuscany SCA for a couple of days and I am trying to
>>> determine if it will suit my requirements for dynamically locating services
>>> (dynamically meaning using a config file and no code changes).
>>>
>>> I have an application that needs to locate new service implementations of
>>> a non remote Java Interface.  The Implementation is simply a JAR that is
>>> dropped into the classpath.  I would like to only add the new service/JAR as
>>> a config entry into the Tuscany '*.composite' file without making any code
>>> changes.  A server restart is acceptable.  Is this possible?
>>>
>>> Sequence
>>> 1. Input to 'core' application is Web Service (does not need to be
>>> associated with Tuscany SCA)
>>> 2. Core app will find available services loadded from the Tuscany SCA
>>> 3. Make API calls (from non remote Interface) to all available services.
>>>
>>> The Services are simple Java Interfaces.  Currently they are NOT web
>>> services or even remote, but will only be JAR file added to the classpath.
>>>
>>> The examples that I have seen define the services as a reference in the
>>> '*.composite' file.  This is fine but the implemenation code that uses the
>>> reference is hard coded to have a matching reference member variable.  I
>>> need this to be dynamic.
>>>
>>> Please help!
>>>
>>> Thanks,
>>> Jared
>>> SCJD,SCWCD,SCBCD
>>>
>>>
>> Hi Jared, Welcome.
>>
>> It would be possible to add a new service to a SCA composite in the way
>> that you describe, i.e. add jar to classpath, update composite file, restart
>> node. However you would need to wire something to the service to make use of
>> it.
>>
>> I've had a similar question before (or at least I think it's similar to
>> your case). Someone wanted to implement a scheduler component which could
>> talk to a dynamic number of worker nodes. I made a quick example to give an
>> idea of how this dynamic behaviour can work [1]. Take a look and see if this
>> matches your defintion of dynamic. If the code doesn't make sense I can talk
>> you through it.
>>
>> The schedler code might not be completely right for you but if we can
>> agree what the question is we might be able to come up with an approach.
>>
>> Hope that helps
>>
>> Simon
>>
>> [1]  http://svn.apache.org/repos/asf/tuscany/sandbox/slaws/scheduler/
>>
>
> Hi Jared, agree with what Simon said (who bet me to it while I was in the
> middle of replying), but i'll continue with an alternative - you could also
> use a dynamic language like JavaScript or Groovy which enables what I think
> you're asking for without needing any hardcoding in the core implementation.
> I think from what you said you don't want to hard code the reference names
> in you core application but have it pick up whatever references are defined
> in the .composite? So this way your core application would use Tuscany to
> call into a JavaScript component which can dynamically query what references
> are wired to it and invoke the services as necessary. I can give you a few
> pointers if thats what you are trying to do.
>
>    ...ant
>
>

Re: Dynamic Service Binding

Posted by ant elder <an...@gmail.com>.
On Fri, Jan 16, 2009 at 2:09 PM, Simon Laws <si...@googlemail.com>wrote:

>
>
> On Thu, Jan 15, 2009 at 4:42 PM, Jared Ladner <ja...@gmail.com>wrote:
>
>> Hi,
>>
>> I have been reviewing Tuscany SCA for a couple of days and I am trying to
>> determine if it will suit my requirements for dynamically locating services
>> (dynamically meaning using a config file and no code changes).
>>
>> I have an application that needs to locate new service implementations of
>> a non remote Java Interface.  The Implementation is simply a JAR that is
>> dropped into the classpath.  I would like to only add the new service/JAR as
>> a config entry into the Tuscany '*.composite' file without making any code
>> changes.  A server restart is acceptable.  Is this possible?
>>
>> Sequence
>> 1. Input to 'core' application is Web Service (does not need to be
>> associated with Tuscany SCA)
>> 2. Core app will find available services loadded from the Tuscany SCA
>> 3. Make API calls (from non remote Interface) to all available services.
>>
>> The Services are simple Java Interfaces.  Currently they are NOT web
>> services or even remote, but will only be JAR file added to the classpath.
>>
>> The examples that I have seen define the services as a reference in the
>> '*.composite' file.  This is fine but the implemenation code that uses the
>> reference is hard coded to have a matching reference member variable.  I
>> need this to be dynamic.
>>
>> Please help!
>>
>> Thanks,
>> Jared
>> SCJD,SCWCD,SCBCD
>>
>>
> Hi Jared, Welcome.
>
> It would be possible to add a new service to a SCA composite in the way
> that you describe, i.e. add jar to classpath, update composite file, restart
> node. However you would need to wire something to the service to make use of
> it.
>
> I've had a similar question before (or at least I think it's similar to
> your case). Someone wanted to implement a scheduler component which could
> talk to a dynamic number of worker nodes. I made a quick example to give an
> idea of how this dynamic behaviour can work [1]. Take a look and see if this
> matches your defintion of dynamic. If the code doesn't make sense I can talk
> you through it.
>
> The schedler code might not be completely right for you but if we can agree
> what the question is we might be able to come up with an approach.
>
> Hope that helps
>
> Simon
>
> [1]  http://svn.apache.org/repos/asf/tuscany/sandbox/slaws/scheduler/
>

Hi Jared, agree with what Simon said (who bet me to it while I was in the
middle of replying), but i'll continue with an alternative - you could also
use a dynamic language like JavaScript or Groovy which enables what I think
you're asking for without needing any hardcoding in the core implementation.
I think from what you said you don't want to hard code the reference names
in you core application but have it pick up whatever references are defined
in the .composite? So this way your core application would use Tuscany to
call into a JavaScript component which can dynamically query what references
are wired to it and invoke the services as necessary. I can give you a few
pointers if thats what you are trying to do.

   ...ant

Re: Dynamic Service Binding

Posted by Simon Laws <si...@googlemail.com>.
On Thu, Jan 15, 2009 at 4:42 PM, Jared Ladner <ja...@gmail.com>wrote:

> Hi,
>
> I have been reviewing Tuscany SCA for a couple of days and I am trying to
> determine if it will suit my requirements for dynamically locating services
> (dynamically meaning using a config file and no code changes).
>
> I have an application that needs to locate new service implementations of a
> non remote Java Interface.  The Implementation is simply a JAR that is
> dropped into the classpath.  I would like to only add the new service/JAR as
> a config entry into the Tuscany '*.composite' file without making any code
> changes.  A server restart is acceptable.  Is this possible?
>
> Sequence
> 1. Input to 'core' application is Web Service (does not need to be
> associated with Tuscany SCA)
> 2. Core app will find available services loadded from the Tuscany SCA
> 3. Make API calls (from non remote Interface) to all available services.
>
> The Services are simple Java Interfaces.  Currently they are NOT web
> services or even remote, but will only be JAR file added to the classpath.
>
> The examples that I have seen define the services as a reference in the
> '*.composite' file.  This is fine but the implemenation code that uses the
> reference is hard coded to have a matching reference member variable.  I
> need this to be dynamic.
>
> Please help!
>
> Thanks,
> Jared
> SCJD,SCWCD,SCBCD
>
>
Hi Jared, Welcome.

It would be possible to add a new service to a SCA composite in the way that
you describe, i.e. add jar to classpath, update composite file, restart
node. However you would need to wire something to the service to make use of
it.

I've had a similar question before (or at least I think it's similar to your
case). Someone wanted to implement a scheduler component which could talk to
a dynamic number of worker nodes. I made a quick example to give an idea of
how this dynamic behaviour can work [1]. Take a look and see if this matches
your defintion of dynamic. If the code doesn't make sense I can talk you
through it.

The schedler code might not be completely right for you but if we can agree
what the question is we might be able to come up with an approach.

Hope that helps

Simon

[1]  http://svn.apache.org/repos/asf/tuscany/sandbox/slaws/scheduler/