Questions tagged [osgi]

The OSGi (Open Service Gateway Initiative) framework is a module system and service platform for the Java programming language that implements a complete and dynamic component model.

The Open Service Gateway Initiative or commonly named OSGi is a specification for a Java component framework with enforced modularity. It provides a comprehensive model to build applications out of smaller, reusable parts. Though it works with any Java code, its advantages are best obtained by using its strong modularity. OSGi encapsulates each JAR in its own class loader and selectively exports packages. OSGi then links each module to the package/module versions they need thereby addressing JAR hell since multiple versions of the same package/module are allowed in OSGi. It also provides for private packages, i.e. packages not visible to any other module.

OSGi modules are normal JAR files with their metadata in the manifest, expressing the module's requirements and capabilities (e.g. import/export package, but extendable). OSGi modules are reified in runtime and have a life cycle. They can be installed, resolved, started, stopped, and uninstalled. Module code can run at start/stop time and an extensive event mechanism is the basis for numerous middleware that simplifies writing modules.

Popular Java factory/DI models collide with strong modularity (these model require implementation class names to be known outside their module). To alleviate this clash, the OSGi provides a modular solution to finding and sharing instances between modules, the so called (µ)services model. A consequence of the strong modularity is that OSGi can hot-swap modules without restarting the application. This is very useful during development but can also be used in server based applications.

All popular Java Application servers are either built on top of OSGi or fully support its module specification. The two popular open source OSGi frameworks are Felix and Equinox. Equinox is the foundation on which Eclipse is built. For the Java embedded world there are implementations like Knopflerfish, Concierge, Prosyst (commercial) as well as several private implementations.

The OSGi Alliance is a worldwide consortium of technology innovators that advances a proven and mature process to create open specifications that enable the modular assembly of software built with Java technology. The OSGi Service Platform facilitates the componentization of software modules and applications and assures interoperability of applications and services over a variety of networked devices.

6201 questions
21
votes
4 answers

Managing OSGi Dependency Hell

UPDATE 2: Since my blog is a bit dead the links got degraded so you can view the articles…
PedroD
  • 5,670
  • 12
  • 46
  • 84
21
votes
5 answers

Where can I find Spring 4 OSGi bundles

Where can I find OSGi bundles for Spring 4? I checked http://ebr.springsource.com/ but can only find Spring 3.2.x and the artifacts in Maven Central are not bundles. Clarification I'm not looking for Spring DM or similar. I'm looking for the "Spring…
Philippe Marschall
  • 4,452
  • 1
  • 34
  • 52
20
votes
5 answers

why osgi is used?

I want to know why OSGI framework is used when building java applications. I am searching the web for this but answers look complex to me. Can anyone please explain few points on why we need to adopt osgi. Am sorry if the question does not suit…
javalearner
  • 3,314
  • 7
  • 26
  • 33
19
votes
1 answer

Enterprise OSGi frameworks : Maturity comparison Apache Aries vs. Eclipse Gemini

Question: As of today, which of the two Enterprise OSGi frameworks is more mature: Apache Aries or Eclipse Gemini? I have done some basic research of Aries and Gemini Enterprise OSGi capabilities. I have also gone through a similar this question:…
user1230646
  • 191
  • 1
  • 3
19
votes
2 answers

Difference between OSGi services and REST microservices

OSGi talks about microservices and the press talks about microservices. However, they do not seem to be the same. What is the difference between these microservices.
sdindiver
  • 491
  • 1
  • 5
  • 19
19
votes
1 answer

Cannot build Eclipse RCP project with Tycho and Java 9

My Eclipse RCP Maven project builds fine with Java 8, but fails with Java 9: [INFO] Scanning for projects... [WARNING] Could not start bundle org.eclipse.equinox.registry org.osgi.framework.BundleException: Could not resolve module:…
ZhekaKozlov
  • 36,558
  • 20
  • 126
  • 155
19
votes
1 answer

What is a p2 repository?

I'm working on a project now for a few months where we use "p2-repositories". I know that I get my dependencies from them. But now I want do dive deeper into the subject and I wonder what exactly is a p2-repository - the definition. I think it has…
armin.miedl
  • 1,070
  • 1
  • 11
  • 16
19
votes
1 answer

How to work with frequent local snapshot bundle deployments on Karaf?

I decided to build an application on top of OSGI and Karaf - I really like this stuff. However, I'm struggling a bit with a daily deployment on my local, development machine. I mean.. I make a change and then I would like to test it on my local…
Michal Chudy
  • 1,883
  • 2
  • 21
  • 41
19
votes
2 answers

When to use ServiceLoader over something like OSGi

Being someone who is allergic to dependencies, when would I use something like OSGi instead of the built in java 6 http://java.sun.com/javase/6/docs/api/java/util/ServiceLoader.html (I want to let plugin jars just be dropped in). (FYI this is in a…
Michael Neale
  • 19,248
  • 19
  • 77
  • 109
19
votes
4 answers

Best way to shutdown an OSGi Container (specifically equinox)

I'm looking for a best practice on shutting down an OSGi container. Currently we are using a small launcher app which calls EclipseStarter.startup() and installs some core bundles. After that the launcher terminates. When the test GUI (running as a…
James Carr
  • 797
  • 2
  • 10
  • 21
18
votes
1 answer

Why can't maven find an osgi bundle dependency?

I have declared a OSGi bundle as a dependency in my maven project. ( It just happens to be the felix container. ) org.apache.felix org.apache.felix.framework
chad
  • 7,369
  • 6
  • 37
  • 56
18
votes
4 answers

What are the fundamental differences between OSGi and Java EE?

So I took some time this afternoon to finally sit down and begin reading up on the mysterious and elusive "OSGi" and its so-called bundles. OK, so I think I get it. An OSGi "bundle" is basically a JAR with some additional manifest information. And,…
IAmYourFaja
  • 55,468
  • 181
  • 466
  • 756
18
votes
1 answer

static invocation of Class.getName()

I stumbled upon the following code in NestedRuntimeException in org.springframework.core: static { NestedExceptionUtils.class.getName(); } What is the use of having such a block?
Novice User
  • 3,552
  • 6
  • 31
  • 56
18
votes
9 answers

Unable to Acquire the State Change Lock

Our products are using the latest production-ready release of SWT, 3.7.2. Now since no one back then knew what the next Java version would be called (and how would they know that 8 came after 7, that's like higher mathematics), we were forced to…
Stefan S.
  • 3,950
  • 5
  • 25
  • 77
18
votes
1 answer

Is it possible to create JKS keystore file without a password?

I'm experimenting with OSGi conditional permissions mechanism. More specifically, I'm trying to use org.osgi.service.condpermadmin.BundleSignerCondition to restrict which bundles can be started. Documentation I have states that in order to use this…
Alex
  • 185
  • 1
  • 2
  • 6