Services and versions

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Services and versions

Erik Gollot
Hello,

first, thanks for your work in the OSGI  world !

This is my first question about Aries.

So, when we publish a service, we can specify a version number, ok ?
So, now, if I've published 2 versions of the "same service", how a
client can specify the version he needs when a "IntialContext.lookup" is
performed ? Do we need an OSGIfied JNDI ?

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Services and versions

Lin Sun
Hi

When you publish a service, you could specify the version info in
service property, for example, publishing a service using blueprint
XML:

<service ref="myMessageDrivenBean" interface="javax.jms.MessageListener">
   <service-properties>
        <entry key="version" value="1.0" />
   </service-properties>
</service>

Or you could do similar thing without using blueprint, using
context.registerService

        Dictionary dict = new Hashtable();
        dict.put(Constants.VERSION_ATTRIBUTE, "1.0");
        sr = context.registerService(MessageListener.class.getName(),
new MyMessageDrivenBean(context), dict);

A client can use filter to specify the exact query it wants, for
example something like below -

String fiter = "(" + Constants.VERSION_ATTRIBUTE + "=1.0")";

Then pass the filter into context.getServiceReferences(clazz, filter)
to get the service reference for the service you are interested.

HTH

Lin



On Thu, Jun 24, 2010 at 8:16 AM, Erik Gollot <[hidden email]> wrote:

> Hello,
>
> first, thanks for your work in the OSGI  world !
>
> This is my first question about Aries.
>
> So, when we publish a service, we can specify a version number, ok ?
> So, now, if I've published 2 versions of the "same service", how a client
> can specify the version he needs when a "IntialContext.lookup" is performed
> ? Do we need an OSGIfied JNDI ?
>
> Thanks
>
Reply | Threaded
Open this post in threaded view
|

Re: Services and versions

Bartosz Kowalewski
Hi Erik,

Continuing Lin's guide:

You should be now able to use something similar to:
"aries:services/javax.jms.MessageListener/(" +
Constants.VERSION_ATTRIBUTE + "=1.0)"
when doing JNDI lookup.

I hope I'm not misstating anything.

Best regards,
  Bartek

2010/6/25 Lin Sun <[hidden email]>:

> Hi
>
> When you publish a service, you could specify the version info in
> service property, for example, publishing a service using blueprint
> XML:
>
> <service ref="myMessageDrivenBean" interface="javax.jms.MessageListener">
>   <service-properties>
>        <entry key="version" value="1.0" />
>   </service-properties>
> </service>
>
> Or you could do similar thing without using blueprint, using
> context.registerService
>
>        Dictionary dict = new Hashtable();
>        dict.put(Constants.VERSION_ATTRIBUTE, "1.0");
>        sr = context.registerService(MessageListener.class.getName(),
> new MyMessageDrivenBean(context), dict);
>
> A client can use filter to specify the exact query it wants, for
> example something like below -
>
> String fiter = "(" + Constants.VERSION_ATTRIBUTE + "=1.0")";
>
> Then pass the filter into context.getServiceReferences(clazz, filter)
> to get the service reference for the service you are interested.
>
> HTH
>
> Lin
>
>
>
> On Thu, Jun 24, 2010 at 8:16 AM, Erik Gollot <[hidden email]> wrote:
>> Hello,
>>
>> first, thanks for your work in the OSGI  world !
>>
>> This is my first question about Aries.
>>
>> So, when we publish a service, we can specify a version number, ok ?
>> So, now, if I've published 2 versions of the "same service", how a client
>> can specify the version he needs when a "IntialContext.lookup" is performed
>> ? Do we need an OSGIfied JNDI ?
>>
>> Thanks
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Services and versions

Jeremy Hughes
In reply to this post by Erik Gollot
I was thinking of a different solution. It depends whether you want
your client to have visibility to both versions of the service at
runtime. If you only need one then you can specify a version range in
the Import-Package header of the client which covers only the version
of the service you want. The client bundle will only be wired to the
bundle that exports the version of the service you want, so the other
version of the service, although registered in the service registry,
won't be visible to your client. Under the covers, OSGi figures out
which services are with the 'class space' of your client and only
gives you ones that you can see.

HTH,
Jeremy

On 24 June 2010 13:16, Erik Gollot <[hidden email]> wrote:

> Hello,
>
> first, thanks for your work in the OSGI  world !
>
> This is my first question about Aries.
>
> So, when we publish a service, we can specify a version number, ok ?
> So, now, if I've published 2 versions of the "same service", how a client
> can specify the version he needs when a "IntialContext.lookup" is performed
> ? Do we need an OSGIfied JNDI ?
>
> Thanks
>
Reply | Threaded
Open this post in threaded view
|

Re: Services and versions

Erik Gollot
Yes if your client is in the same VM it's the normal OSGI way
But if my client is in another VM than the service and the service is lookup through InitialContext.lookup, is the Import-Package list used by JNDI ?

Jeremy Hughes a écrit :
I was thinking of a different solution. It depends whether you want
your client to have visibility to both versions of the service at
runtime. If you only need one then you can specify a version range in
the Import-Package header of the client which covers only the version
of the service you want. The client bundle will only be wired to the
bundle that exports the version of the service you want, so the other
version of the service, although registered in the service registry,
won't be visible to your client. Under the covers, OSGi figures out
which services are with the 'class space' of your client and only
gives you ones that you can see.

HTH,
Jeremy

On 24 June 2010 13:16, Erik Gollot [hidden email] wrote:
  
Hello,

first, thanks for your work in the OSGI  world !

This is my first question about Aries.

So, when we publish a service, we can specify a version number, ok ?
So, now, if I've published 2 versions of the "same service", how a client
can specify the version he needs when a "IntialContext.lookup" is performed
? Do we need an OSGIfied JNDI ?

Thanks

    

  

Reply | Threaded
Open this post in threaded view
|

Re: Services and versions

Erik Gollot
In reply to this post by Bartosz Kowalewski

So filters with the version attribute works with JNDI ! Great !!!

Thanks

Bartosz Kowalewski a écrit :
Hi Erik,

Continuing Lin's guide:

You should be now able to use something similar to:
"aries:services/javax.jms.MessageListener/(" +
Constants.VERSION_ATTRIBUTE + "=1.0)"
when doing JNDI lookup.

I hope I'm not misstating anything.

Best regards,
  Bartek

2010/6/25 Lin Sun [hidden email]:
  
Hi

When you publish a service, you could specify the version info in
service property, for example, publishing a service using blueprint
XML:

<service ref="myMessageDrivenBean" interface="javax.jms.MessageListener">
  <service-properties>
       <entry key="version" value="1.0" />
  </service-properties>
</service>

Or you could do similar thing without using blueprint, using
context.registerService

       Dictionary dict = new Hashtable();
       dict.put(Constants.VERSION_ATTRIBUTE, "1.0");
       sr = context.registerService(MessageListener.class.getName(),
new MyMessageDrivenBean(context), dict);

A client can use filter to specify the exact query it wants, for
example something like below -

String fiter = "(" + Constants.VERSION_ATTRIBUTE + "=1.0")";

Then pass the filter into context.getServiceReferences(clazz, filter)
to get the service reference for the service you are interested.

HTH

Lin



On Thu, Jun 24, 2010 at 8:16 AM, Erik Gollot [hidden email] wrote:
    
Hello,

first, thanks for your work in the OSGI  world !

This is my first question about Aries.

So, when we publish a service, we can specify a version number, ok ?
So, now, if I've published 2 versions of the "same service", how a client
can specify the version he needs when a "IntialContext.lookup" is performed
? Do we need an OSGIfied JNDI ?

Thanks

      

  

Reply | Threaded
Open this post in threaded view
|

Re: Services and versions

Erik Gollot
In reply to this post by Lin Sun
Thanks
Lin Sun a écrit :
Hi

When you publish a service, you could specify the version info in
service property, for example, publishing a service using blueprint
XML:

<service ref="myMessageDrivenBean" interface="javax.jms.MessageListener">
   <service-properties>
	<entry key="version" value="1.0" />
   </service-properties>
</service>

Or you could do similar thing without using blueprint, using
context.registerService

        Dictionary dict = new Hashtable();
        dict.put(Constants.VERSION_ATTRIBUTE, "1.0");
        sr = context.registerService(MessageListener.class.getName(),
new MyMessageDrivenBean(context), dict);

A client can use filter to specify the exact query it wants, for
example something like below -

String fiter = "(" + Constants.VERSION_ATTRIBUTE + "=1.0")";

Then pass the filter into context.getServiceReferences(clazz, filter)
to get the service reference for the service you are interested.

HTH

Lin



On Thu, Jun 24, 2010 at 8:16 AM, Erik Gollot [hidden email] wrote:
  
Hello,

first, thanks for your work in the OSGI  world !

This is my first question about Aries.

So, when we publish a service, we can specify a version number, ok ?
So, now, if I've published 2 versions of the "same service", how a client
can specify the version he needs when a "IntialContext.lookup" is performed
? Do we need an OSGIfied JNDI ?

Thanks

    

  

Reply | Threaded
Open this post in threaded view
|

RE: Services and versions

Timothy Ward
In reply to this post by Erik Gollot


Hi Erik, filters do work,

One warning though, if the service property used to represent the version is an org.osgi.framework.Version, then it will have different equals and comparison behaviour than if it is a java.lang.String.


For example the filter "(version=1.0.0)" will match an OSGi Version made with Version.parseVersion("1.0"), but not the String "1.0".

Regards,

Tim

________________________________

> Date: Sat, 26 Jun 2010 15:27:55 +0200
> From: [hidden email]
> To: [hidden email]
> Subject: Re: Services and versions
>
>
>
>
>
>
>
>
>
>
>
> So filters with the version attribute works with JNDI ! Great !!!
>
>
>
> Thanks
>
>
>
> Bartosz Kowalewski a écrit :
>
>
> Hi Erik,
>
> Continuing Lin's guide:
>
> You should be now able to use something similar to:
> "aries:services/javax.jms.MessageListener/(" +
> Constants.VERSION_ATTRIBUTE + "=1.0)"
> when doing JNDI lookup.
>
> I hope I'm not misstating anything.
>
> Best regards,
> Bartek
>
> 2010/6/25 Lin Sun :
>
>
>
>
> Hi
>
> When you publish a service, you could specify the version info in
> service property, for example, publishing a service using blueprint
> XML:
>
>
>
>
>
>
>
> Or you could do similar thing without using blueprint, using
> context.registerService
>
> Dictionary dict = new Hashtable();
> dict.put(Constants.VERSION_ATTRIBUTE, "1.0");
> sr = context.registerService(MessageListener.class.getName(),
> new MyMessageDrivenBean(context), dict);
>
> A client can use filter to specify the exact query it wants, for
> example something like below -
>
> String fiter = "(" + Constants.VERSION_ATTRIBUTE + "=1.0")";
>
> Then pass the filter into context.getServiceReferences(clazz, filter)
> to get the service reference for the service you are interested.
>
> HTH
>
> Lin
>
>
>
> On Thu, Jun 24, 2010 at 8:16 AM, Erik Gollot wrote:
>
>
>
>
> Hello,
>
> first, thanks for your work in the OSGI world !
>
> This is my first question about Aries.
>
> So, when we publish a service, we can specify a version number, ok ?
> So, now, if I've published 2 versions of the "same service", how a client
> can specify the version he needs when a "IntialContext.lookup" is performed
> ? Do we need an OSGIfied JNDI ?
>
> Thanks
>
>
>
>
>
>
>
>
>
>
     
_________________________________________________________________
http://clk.atdmt.com/UKM/go/197222280/direct/01/
We want to hear all your funny, exciting and crazy Hotmail stories. Tell us now
Reply | Threaded
Open this post in threaded view
|

Re: Services and versions

Erik Gollot
ok, thanks for this detail !!

Timothy Ward a écrit :
Hi Erik, filters do work,

One warning though, if the service property used to represent the version is an org.osgi.framework.Version, then it will have different equals and comparison behaviour than if it is a java.lang.String.


For example the filter "(version=1.0.0)" will match an OSGi Version made with Version.parseVersion("1.0"), but not the String "1.0".

Regards,

Tim

________________________________
  
Date: Sat, 26 Jun 2010 15:27:55 +0200
From: [hidden email]
To: [hidden email]
Subject: Re: Services and versions











So filters with the version attribute works with JNDI ! Great !!!



Thanks



Bartosz Kowalewski a écrit :


Hi Erik,

Continuing Lin's guide:

You should be now able to use something similar to:
"aries:services/javax.jms.MessageListener/(" +
Constants.VERSION_ATTRIBUTE + "=1.0)"
when doing JNDI lookup.

I hope I'm not misstating anything.

Best regards,
Bartek

2010/6/25 Lin Sun :




Hi

When you publish a service, you could specify the version info in
service property, for example, publishing a service using blueprint
XML:







Or you could do similar thing without using blueprint, using
context.registerService

Dictionary dict = new Hashtable();
dict.put(Constants.VERSION_ATTRIBUTE, "1.0");
sr = context.registerService(MessageListener.class.getName(),
new MyMessageDrivenBean(context), dict);

A client can use filter to specify the exact query it wants, for
example something like below -

String fiter = "(" + Constants.VERSION_ATTRIBUTE + "=1.0")";

Then pass the filter into context.getServiceReferences(clazz, filter)
to get the service reference for the service you are interested.

HTH

Lin



On Thu, Jun 24, 2010 at 8:16 AM, Erik Gollot wrote:




Hello,

first, thanks for your work in the OSGI world !

This is my first question about Aries.

So, when we publish a service, we can specify a version number, ok ?
So, now, if I've published 2 versions of the "same service", how a client
can specify the version he needs when a "IntialContext.lookup" is performed
? Do we need an OSGIfied JNDI ?

Thanks










    
 		 	   		  
_________________________________________________________________
http://clk.atdmt.com/UKM/go/197222280/direct/01/
We want to hear all your funny, exciting and crazy Hotmail stories. Tell us now