tags:

views:

628

answers:

7

I have been trying to understand a bit more about the wider picture of OSGi without reading thru the entire specification. As with so many things, the introduction to what OSGi actually is was probably written by someone who had been working on it for a decade and perhaps wasn't best placed to put themselves in the mindset of someone who knows nothing about it :-)

Looking at Felix's example DictionaryService, I don't really understand what is going on. Is OSGi a distinct instance of a JVM into which you load bundles which can then find each other?

Obviously it is not just this because other answers on StackOverflow are explicit that OSGi can solve the dependency problem of a distributed system containing modules deployed within distinct JVMs (plus the FAQ keeps talking about networks).

In this latter case, how does a component running in one JVM interact with another component in a separate JVM? Can the two components "use" each other as if they were running within the same JVM (i.e. via local method calls), and how does OSGi manage the marshalling of data across a network (do you have to use Serializable for example)?

Or does the component author have to use some other distinct mechanism (either provided by OSGi or written themselves) for communication between remote components?

Any help much appreciated!

+2  A: 

AFAIK, bundles are running in the same JVM, but are not loaded using the same class loader (that why you can use two different versions of the same bundle at the same time).

To interact with components in another JVM, you must use a network protocol such as rmi.

Patriarch24
+1  A: 

@Patriarch24

The accepted answer to this question would seem to indicate otherwise (unless I'm misreading it). Also, taken from the FAQ:

The OSGi Service Platform provides the functions to change the composition dynamically on the device of a variety of networks, without requiring a restart

(Emphasis my own). Although in the same FAQ it describes OSGi as in-VM.

Why am I so confused about this? Why is such a basic question about a decade-old technology not clear?

oxbow_lakes
I'd say that is a very confusing, even misleading, answer. OSGi at its core does not deal with distributed systems, just with keeping modules separate and reloadable inside a single VM.
Thilo
+4  A: 

As far as I know, OSGi does not solve this problem out of the box. There are OSGi-bundles, for example Remote OSGi, which allow the programmer to distribute services across a network.

Stefan Schmidt
+1  A: 

Not yet, i think it's being worked on for the next release.

But some companies have already implemented distributed osgi. One i'm aware of is Paremus' Infiniflow (http://www.paremus.com/products/products.html). At linkedin they are also working on this. More info here: Building Linkedin next gen architecture with osgi and here: Matt raible: building linkedin next gen architecture

Here's a summary of the changes for OSGI 4.2: Some thoughts on the OSGi R4.2 draft, There's a section on RFC-119 dealing with distributed OSGi.

Andrej
+2  A: 

Yes, OSGi only deals with bundles and services running on the same VM. However, one should note that it is a distinct feature of OSGi that it facilitates running multiple applications (in a controlled way and sharing common modules) on the same JVM at all.

When it comes to accessing services outside the clients JVM, there is currently no standardized solution. Paremus Infiniflow and the derived open-source project Newton use an SCA approach. The upcoming 4.2 release of the OSGi specs will address one side of the problem, namely how to use a generic distribution software in such a way that it can bring remote services into the clients JVM.

As somebody mentioned R-OSGi, this approach also deals with the other side of the problem, being how to manage dependencies between distributed OSGi frameworks. Since R-OSGi is not a generic distribution software but explicitly deals with the lifecycle issues and dependency management of OSGi bundles.

+1  A: 

The original problem of OSGI was more related to distribution of code (and then configuration of bundle) than to distribution of execution.

People looking at distributed components are rather looking towards SCA

charoy
+1  A: 

The OSGi alliance is working on a standard for distributed OSGi:

http://www.osgi.org/download/osgi-4.2-early-draft2.pdf


There even is an early Apache implementation of this new standard:

http://cxf.apache.org/distributed-osgi.html

lewap