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
295
votes
15 answers

What does OSGi solve?

I've read on Wikipedia and other sites about OSGi, but I don't really see the big picture. It says that it's a component-based platform, and that you can reload modules at runtime. Also the "practical example" given everywhere is the Eclipse Plugin…
Pablo Fernandez
  • 103,170
  • 56
  • 192
  • 232
152
votes
13 answers

Reading my own Jar's Manifest

I need to read the Manifest file, which delivered my class, but when I use: getClass().getClassLoader().getResources(...) I get the MANIFEST from the first .jar loaded into the Java Runtime. My app will be running from an applet or a webstart, so I…
Houtman
  • 2,819
  • 2
  • 24
  • 34
151
votes
1 answer

Why are uses constraints violated when both chains end in the same bundle?

I have four bundles, each containing only a manifest. The bundles are app which imports com.example.foo.fragment and com.example.bar foo which exports com.example.foo;uses:=com.example.foo.cfg foo.fragment which is a fragment attached to foo that…
Emil Lundberg
  • 7,268
  • 6
  • 37
  • 53
142
votes
3 answers

OSGi: What are the differences between Apache Felix and Apache Karaf?

Apache Karaf is a sub project of Apache Felix. It is defined as "a lightweight OSGi container". I don't understand when should I use the heavyweight and when to use the lightweight. Their site doesn't explain this too much.
GabiMe
  • 18,105
  • 28
  • 76
  • 113
94
votes
3 answers

OSGi, Java Modularity and Jigsaw

So as of yesterday morning I hadn't a clue as to what OSGi even was. OSGi was just some buzzword that I kept seeing cropping up over and over again, and so I finally set aside some time to brush up on it. It actually seems like pretty cool stuff, so…
IAmYourFaja
  • 55,468
  • 181
  • 466
  • 756
79
votes
3 answers

What exactly is Apache Karaf?

I am a little bit confused about what Apache Karaf exactly is. Can you say that Apache Karaf includes, amongst other things: Apache Felix (which is an implementation of the OSGi 4.2 framework) Apache Aries (which is an implementation of the…
Frizz
  • 2,524
  • 6
  • 31
  • 45
64
votes
3 answers

Java plugin framework choice

We're trying to determine how to implement a simple plugin framework for a service we are implementing that allows different types of calculators to be "plugged-in". After reading a number of posts about Java plugin frameworks, it seems like the…
Marcus Leon
  • 55,199
  • 118
  • 297
  • 429
63
votes
2 answers

What is OSGi and what are some examples of its use?

I've just started hearing the term OSGi being used (while reading tutorials on common Java EE containers such as GlassFish and Spring), however I have been unable to find a simple, straight-forward, easy-to-understand explanation of what OSGi is…
Zac
  • 761
  • 2
  • 8
  • 6
59
votes
6 answers

When should I use Import-Package and when should I use Require-Bundle?

OSGi allows for dependencies to be determined via Import-Package, which just wires up a single package (exported from any bundle), and Require-Bundle, which wires up to a specific named bundle's exports. In building a greenfield OSGi application,…
AlBlue
  • 23,254
  • 14
  • 71
  • 91
55
votes
17 answers

A cycle was detected in the build path of project xxx - Build Path Problem

I'm in the process of converting my projects to OSGI bundles using maven and eclipse. Maven builds the stuff just fine, only I get the above error now within Eclipse. How can I find out which project causes this? Is there a special view or…
Mauli
  • 16,863
  • 27
  • 87
  • 114
55
votes
10 answers

Why can't JAXB find my jaxb.index when running inside Apache Felix?

It's right there, in the package that it should be indexing. Still, when I call JAXBContext jc = JAXBContext.newInstance("my.package.name"); I get a JAXBException saying that "my.package.name" doesnt contain ObjectFactory.class or…
Hanno Fietz
  • 30,799
  • 47
  • 148
  • 234
45
votes
8 answers

What's the best way to get started with OSGI?

What makes a module/service/bit of application functionality a particularly good candidate for an OSGi module? I'm interested in using OSGi in my applications. We're a Java shop and we use Spring pretty extensively, so I'm leaning toward using…
Nicholas Trandem
  • 2,815
  • 5
  • 30
  • 32
43
votes
2 answers

What is the difference between OSGi Components and Services

Under OSGi, what are the main differences between Components vs Services? As I understand it, all Services must be Components, but not all Components must be services. What are the benefits of using one over the other with sample use cases?
empire29
  • 3,729
  • 6
  • 45
  • 71
43
votes
6 answers

OSGI - handling 3rd party JARs required by a bundle

I'm just getting started with OSGI development and am struggling to understand how best to handle dependant JARs. i.e. if I'm creating a bundle the likelyhood is that I will need to use a few 3rd party JARs. When I create my bundle JAR to deploy to…
William
  • 13,332
  • 13
  • 60
  • 73
42
votes
8 answers

Java 8 & Missing required capability Require-Capability: osgi.ee; filter="(&(osgi.ee=JavaSE)(version=1.8))"

I have using Eclipse Luna win32.x86_64 runing with Java 8. Here from the Help Menu > About > Installation Detail > Configuration Tab: java.runtime.version=1.8.0_05-b13 java.version=1.8.0_05 I have created new plug-in project, requesting JavaSE-1.8…
Jmini
  • 9,189
  • 2
  • 55
  • 77
1
2 3
99 100