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
27
votes
6 answers

Can OSGi help reduce complexity?

I saw lots of presentations on OSGi and i think it sounds promising for enforcing better modularization. Apparently "hotdeployment" and "running different versions of x in parallel" are mayor selling points too. I wonder whether what OSGi promises…
raoulsson
  • 14,978
  • 11
  • 44
  • 68
26
votes
5 answers

How to modularize a JSF/Facelets/Spring application with OSGi?

I'm working with very large JSF/Facelets applications which use Spring for DI/bean management. My applications have modular structure and I'm currently looking for approaches to standardize the modularization. My goal is to compose a web application…
lexicore
  • 42,748
  • 17
  • 132
  • 221
25
votes
3 answers

Is the resolution problem in OSGi NP-Complete?

The resolution problem is described in the modularity chapter of the OSGi R4 core specification. It's a constraint satisfaction problem and certainly a challenging problem to solve efficiently, i.e. not by brute force. The main complications are…
glyn
  • 1,180
  • 8
  • 19
25
votes
5 answers

Why is Sun inventing another module system when everyone has standardised on OSGi?

Sun is putting a lot of effort behind modularising the JDK in the form of Jigsaw, and insinuating that it should be the module format of choice for other Java developers as well. The only notable player who is using this is NetBeans (and derivative…
AlBlue
  • 23,254
  • 14
  • 71
  • 91
24
votes
3 answers

Is MEF OSGi for .NET?

I'm just trying to get my head around the Managed Extensibility Framework (MEF) at the moment and digging into a bit. I have an Eclipse background so in my brain I currently have the equation: MEF =~ OSGi for .NET Based on what I have heard so…
Martin Woodward
  • 11,770
  • 31
  • 45
24
votes
3 answers

How does OSGi bundle update work?

When a bundle is updated (say to fix a bug), what happens to other bundles that are currently using the one being updated? Say that there are two bundles service and dao. Say that classes in service bundle are using classes in dao bundle when I…
Satish
  • 241
  • 1
  • 2
  • 3
24
votes
1 answer

How is Java 8 modules different from OSGi?

Java 8 with Project Jigsaw brings a module system to the SDK. I see it as a good thing as it's part of the package (built-in). OSGi also provides a module system, but requires a container. But apart from that what are the major difference among…
user235273
24
votes
8 answers

org.osgi.framework.BundleException: Could not find bundle: org.eclipse.equinox.console

Command : \eclipse-SDK-4.2RC3-win32-x86_64_001\eclipse\plugins>java -jar org.eclipse.osgi_3.8.0.v20120529-1548.jar -console Exception (from Log files) !SESSION 2012-06-22 23:36:27.649…
Siva Arunachalam
  • 7,582
  • 15
  • 79
  • 132
23
votes
4 answers

Apache Karaf vs. Servicemix

Is anyone using Karaf instead of Servicemix? If so, how did you come to this decision? I'm aware that Servicemix adds a layer of functionality around Karaf, just curious if Karaf is being used on its own and why...
Ben ODay
  • 20,784
  • 9
  • 45
  • 68
23
votes
3 answers

What is the intended use case for Bundle-Classpath in OSGI bundles

I am trying to understand the intended use case for Bundle-Classpath in OSGI bundles. Here is my understanding, please help me understand if this is correct. Let's say I am working on creating an OSGI bundle which will be deployed in an ecosystem of…
Parag
  • 12,093
  • 16
  • 57
  • 75
23
votes
4 answers

OSGi: Does Blueprint replace Declarative Services?

The new R4.2 spec for OSGi describes the Blueprint service, for dependency injection and service wiring. Does Blueprint replace Declarative Services (which is still part of the spec, as well), or are they intended to work together? Is Blueprint…
Thilo
  • 257,207
  • 101
  • 511
  • 656
22
votes
1 answer

Using Spring Security on a JAX-RS bundle in Karaf

I have an OSGi bundle that uses JAX-RS to handle some REST services. This bundle is running in Karaf with Apache CXF. I need to apply basic http authentication to certain path/method combinations. I've been tinkering with Spring Security and it…
Jon7
  • 7,165
  • 2
  • 33
  • 39
22
votes
3 answers

Camel in OSGi Container: Apply InterceptStrategy to all camel contexts

I have several bundles (A, B, and C) deployed to an OSGi container, each containing a CamelContext and some routes. I have another bundle (M) with a CamelContext with a route (for collecting monitoring data) and a InterceptStrategy bean. I would…
VeeArr
  • 6,039
  • 3
  • 24
  • 45
22
votes
2 answers

Logging in Eclipse/OSGi plugins

I am starting to develop an Eclipse plugin (technically, an OSGi plugin) and one of the first problems I've run into is that I can't seem to control the commons-logging output as I normally would. I've included the commons-logging package in the…
rcreswick
  • 16,483
  • 15
  • 59
  • 70
21
votes
6 answers

How to create OSGi bundle from jar library?

How to create OSGi bundle from jar library?
EK.
  • 2,890
  • 9
  • 36
  • 49