You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Frédéric POULET <fr...@magellium.fr> on 2014/03/13 13:12:56 UTC
Cellar and remote services
Hi,
I'm testing cellar and I'm asking myself the following question : Is it possible to access a remote service without use blueprint ? Because when I execute this below code, I not see my service.
final ServiceReference[] serviceReferences = Service1Impl.this.context.getServiceReferences(null, null);
if (serviceReferences != null) {
for (int i = 0; i < serviceReferences.length; i++) {
String[] a = (String[]) serviceReferences[i].getProperty("objectClass");
for (int j = 0; j < a.length; j++) {
if (a[j].contains("cluster")) {
System.out.println(a[j]);
}
}
}
}
Thank you for your help
Re: Cellar and remote services
Posted by Scott Lewis <sl...@composent.com>.
Hi Frederic,
On 3/13/2014 5:12 AM, Frédéric POULET wrote:
>
> Hi,
>
> I'm testing cellar and I'm asking myself thefollowing question : Is
> it possibleto access a remote service without use blueprint ?
>
The general/spec answer to this is 'yes'...following just the OSGi
Remote Services specification (no particular impl) it should be/is
possible to access a remote services without using blueprint. In the
same way that any OSGi service can be accessed in multiple ways (via
blueprint, ServiceTracker, declarative services, via
BundleContext/ServiceReference as per your code), according to the RS
specification (chapter 100) a remote service (once discovered and
imported) can similarly be accessed and used.
Now...of course there are different impls of the RS specification, and I
can't speak for them all (i.e. whether they require use of blueprint).
Actually, I can only speak for one [1]. But in that one we test
many/multiple ways of accessing a remote service (on the consumer) to
verify spec compliance.
Scott
[1] http://www.eclipse.org/ecf
> Because when I execute this below code, I not see my service.
>
> final ServiceReference[] serviceReferences =
> Service1Impl.this.context.getServiceReferences(null, null);
>
> if (serviceReferences != null) {
>
> for (int i = 0; i < serviceReferences.length; i++) {
>
> String[] a = (String[])
> serviceReferences[i].getProperty("objectClass");
>
> for (int j = 0; j < a.length; j++) {
>
> if (a[j].contains("cluster")) {
>
> System.out.println(a[j]);
>
> }
>
> }
>
> }
>
> }
>
> Thank you for your help
>