views:

567

answers:

4

Hi ,

I am new to programming with OSGI. Can anyone provide me a working example of a client/server osgi service invocation.

I have been trying to acheve this for the last 2 weeks without any success.

My service is being discovered and executed by an eclipse instance in the same machine, but when I try the same thing from another machine it fails.

Any help will be appreciated.

Thanks.

+3  A: 

In OSGi platform (Release 4 Version 4.1) services discovered through OSGi service registry are local services available only inside single OSGi framework instance (i.e. single JVM). You can not expect to execute an OSGi service running on a different machine.

If you want to call OSGi services across multiple framework instances (i.e. multiple JVMs / multiple machines) you should take a look at Distributed OSGi Specification (RFC 119) that will be part of upcoming OSGi specification (Release 4 Version 4.2) with CXF as a reference implementation.

Update: Another way to call remote OSGi services is to use R-OSGi. It is a middleware that provides an almost transparent way to access services on remote OSGi platforms.

Pavol Juhos
The CXF page has a bunch of samples at the bottom of the page.
hbunny
A: 

Unless you are playing with either CXF's or Eclipse's Distributed OSGi implementations, there's nothing related to remoting in OSGi. You should be able to make any remoting implementation work between 2 OSGi-based processes.

What I will say is you will probably have class loader issues if you try and use RMI or any of the RPC patterns available in Spring's remoting. This is solvable, but requires a good understanding of OSGi and class loaders.

Does your code work if you run it outside of OSGi? Are you using a firewall? Can you run any network-based service on your PC that is visible to other PCs on the network?

As described, the problem looks more network-related than OSGi-related.

Also, you didn't mention what failure you get when running across different PCs.

hbunny
A: 

OSGi services are intra-vm, not inter-vm, unless you add distributing on the top.

You might want to look at Brian's tutorial which does a good job of showing how OSGi services can be exported and use ECF to perform the remote distribution. There's quite a few bundles involved but he does a good job in explaining it.

AlBlue
A: 

The Riena platform of the eclipse foundation provides OSGi remote services by publishing the services as web-service endpoints.

James