I am in a situation where I could use the SPI service loader in OSGi environment. I found out about osgi.serviceloader.registrar. However, what is unclear to me is whether this is supported by Equinox OOTB or if I still need Apache Aries SPI Fly to have it implemented and usable?
Related
I'm trying to get comfortable in the vast ecosystem of enterprise OSGi programming, but I find it very difficult to get an overview of how this technology stack is put together, which technologies build upon one another, which technologies solve what task, and how they all fit in the limited terminology I have managed to understand so far.
For example: What is the relation between Apache Felix, Equinox, Karaf, Jira OSGi, Spring DM, Aries Blueprint, Gemini Blueprint, iPOJO, Camel etc. etc...
I know Equinox is based on Felix, and that the Blueprint variants and iPOJO are somewhat related to component management, but what about Declarative Services? Is DS an alternative to Blueprint, or is Blueprint an implementation of Declarative Services?
In general, I am heavily confused, and I really need a simple overview of how common OSGi technologies in general are related.
Does anyone know of there exists such an overview - perhaps graphical - of the OSGi ecosystem?
Best regards.
I don't know of a graphical representation. I can break down the few specific things you have mentioned in your post:
An "OSGi Framework" is an implementation of the core OSGi specification. It would have to implement the concept of bundles, installing and resolving bundles, lifecycle, services and so on.
Apache Felix is an OSGi Framework implementation.
Equinox is also an OSGi Framework implementation. It is not "based on" Apache Felix but it does borrow a small amount of code from it. Equinox is the implementation of OSGi used in Eclipse etc.
Karaf is essentially an application server product. It uses Felix as its core OSGi Framework implementation, and then adds a lot of extra features on the top.
Jira OSGi: don't know. I believe Jira is internally implemented with OSGi but I don't know any of the details.
Spring DM is an obsolete/dead project. It was a way of splitting up a Spring bean graph into a modular application, using OSGi.
Blueprint is a specification published by the OSGi Alliance. It is one of the Compendium specifications, i.e. add-ons that are not required in the Core. Blueprint was inspired by Spring-DM and it standardises the idea of wiring together beans within and between bundles.
Gemini Blueprint is an implementation of the Blueprint specification. Gemini started with the Spring-DM code and evolved it to comply with the (then) new specification.
Aries Blueprint is also an implementation of Blueprint. It is "clean-room", i.e. implemented from scratch against the specification rather than evolved from older Spring code.
Declarative Services is an OSGi specification from the Compendium. It is an alternative way to define components and to wire them together using services across bundles. Many experienced OSGi developers β including me β consider Declarative Services to be FAR superior to Blueprint. I can elaborate more on the reasons for that if you like.
iPOJO is yet another different way to define components and wire them together. It does not conform to any OSGi specification.
Camel is an integration library, mostly used for messaging applications. It doesn't have much to do with OSGi except that it can run under OSGi.
I hope this helps.
Imagine you want to have a highly modular web application in Java. Components are already using Spring framework also. Some components cover only pure Logic and some others also come with some presentation GUIs in HTML. The application is not Portlet compatible but we need to have dynamic menu which promotes the list of installed modules and links to the pages or REST APIs. Since itβs Java, using OSGI is recommended but I got too much confused with the recent features in OSGI (introduced past few years) and I have few questions:
Now OSGI is not only Module Management System but also IoC Container! It almost contains equivalent annotations for many of Spring IoC features. So How we can use Spring enabled modules inside OSGI? Can we eliminate Spring for our new designs and completely rely on OSGI? Or for dependency Injection within the modules we can use Spring and for Dependency injection over the Modules we can use OSGI?
For real-life large scale applications we have two options: Using Embedded Felix within application Container (e.g. Tomcat) or Using OSGI Bundle of Application Container (Jetty or Tomcat) within KARAF. Which approach is better? Which one is more scalable?
Researching OSGi can get confusing because there are 15 years of articles and examples out there - a lot of which are valid but may be out of date.
You could consider removing Spring if it was just used as an IoC container. OSGi DS provides #Component and #Reference annotations (like spring Autowire) if DS is enabled in your OSGi container. The new OSGi enroute project has some modern examples of performing IoC and providing REST services.
Replacing more of the features might be more work. Running the latest Spring in OSGi may not work due to the classloader differences in OSGi and the spring projects move away from OSGi.
OSGi is no IoC container at all. There are some technologies for injection support that run on OSGi though. The most important are declarative services and blueprint. Spring is not really supported. There is some Spring DM support but this code is not maintained for ages.
So you should use one of the two supported IoC containers above. For aries blueprint I have written support for CDI annotations using the maven-blueprint-plugin. This may be your best bet to convert the application. I recommend to first convert your spring application to use only CDI annotations and only then start the OSGi migration. Such a migration is not easy. Make sure you get some good coaching and consulting.
Embedded Felix on a servlet container is good if most of you application is non OSGi and you just want to use bundles for a very small part. Karaf is better if you want to write your whole application for OSGi.
What is the status of the current developments around Spring and OSGi?
It looks like things have gotten a bit quiet lately.
The latest version of the doc at (http://docs.spring.io/osgi/) is from 2009.
I see some announcements that Spring DM has become Eclipse Gemini Blueprint (http://www.eclipse.org/gemini/blueprint/documentation/migration/). But also there, the latest release is from August 2012.
Is Spring and OSGi a dead path? If so, what other options are there to make a spring application modular (e.g. allow deployment, starting, stopping & updating of a module within a running JVM)?
Thanks
I agre that spring on OSGi is a dead end. There does not seem to be any real drive in it since springsource abandoned OSGi.
There are some alternatives though. The most stable and complete one is Apache Aries at the moment. It provides blueprint support which is similar to spring xml and some extensions like jpa container managed transactions. Be aware though that aries still contains much less functionality then spring. So for example annotation support is very limited.
Alternatives to Aries blueprint are Declarative Services and pax CDI. Declarative services is very small footprint and quite stable and has great supports for the dynamics of OSGi. On the other hand it is even more limited than blueprint. So for example there is no special jpa support at all.
PAX CDI aims to provide Java EE on OSGi using Open Webbeans or Weld + some extensions like Deltaspike. Together it would provide similar comfort like Java EE 6. Unfortunately it is not completely finished so at the moment I would not yet consider it ready for production use.
Gemini Blueprint is still active, right now gemini blueprint upgraded to support R5 and M2 is available in the eclipse nexus.
I'm experimenting with OSGI and CDI. I want to register my OSGI services using CDI annotations and also retrieve the registered OSGI services using CDI.
I have found the following: https://github.com/mathieuancelin/weld-osgi, it seems like it is integrated into weld-core. But when I depenend on the weld-core 1.2.0.Beta1 or 2.0.0.Final version, I do not find any of the annotations specified in the documentation on https://github.com/mathieuancelin/weld-osgi.
It this weld-osgi the way to go when you want to use OSGI with CDI? Or should I use spring? (I prefer weld because my AS is currently jboss EAP 6.1)
In which dependency can I find the annotations specified in the documentation?
Thanks!
Currently I do not advice using CDI to work with OSGi services. The Weld-OSGi library is still very experimental and will most likely change when the OSGi-CDI specification is released.
At this moment a new specification, OSGi-CDI (RFC 193) is being written in the Enterprise OSGi expert group (I'm one of the members writing this spec). OSGi-CDI is scheduled to be part of Enterprise OSGi R6 early next year. Unfortunately, it's too early to start using this yet, the reference implementation is far from finished. Some more details about the upcoming specification can be found in a presentation I gave at EclipseCon this year: https://speakerdeck.com/paulbakker/rfc-193-osgi-cdi
I strongly advice to use one of the other dependency injection solutions available for OSGi services, preferably either Apache Felix Dependency Manager or Dynamic Services. Because both of these libraries are built directly on the OSGi service API, you don't have to drag in other dependencies. The programming model is obviously different than CDI, but the concepts are very similar, so it should be easy to pick up.
Do not use Spring either because it doesn't really fit OSGi very well (although it can work).
I haven't worked on it, and I know little about weld-osgi, but you should be using it if you want OSGi and CDI to play nicely. I'm pretty sure they're separate jars, you'll need to add the weld-osgi dependency to your project.
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.
The 'lightweight OSGi container' label is contrasting Karaf with more feature rich OSGi containers, not with Felix.
To quote Guillaume Nodet (Karaf's author) from here:
Felix is just the OSGi core runtime. Karaf provides a "distribution" based on Felix by adding other features such as a console, an SSH remoting mechanism, a file deployer and more.
In this diagram of the Karaf architecture, Felix (or other OSGi implementation - currently Equinox is also supported) is the OSGi box, the other boxes are the features added by Karaf:
Therefore, unless you have specific needs which are not met by Karaf (requiring access to the underlying implementation) it usually makes sense to use this since it provides more 'out of the box'.
#Marcel
Karaf isn't monolithic or huge like a Java EE server. It is a very slim and minimalist implementation. It is a core product without much functionality other than a basic console, file loading so that you can actually read configuration files, etc. The latest zip file of it is 19.1 MB. Yeah. Small. It can easily run on small devices and work in embedded.
What you may be thinking of is something more like ServiceMix which uses Karaf as a core/kernel. But it includes CXF, ActiveMQ, Camel and other libraries in its full configuration. Even then they have minimal, medium and full sizes.
Really, for 99% of the projects out there it wouldn't make sense to start directly with Felix and not use Karaf instead.
Currently, there are three popular open source OSGi containers:
- Equinox. It is the modular Java runtime at the heart of the Eclipse IDE,
- Knopflerfish, Is an open source implementation of the OSGi R3 and OSGi R4 specifications.
- Apache Felix. Is the open source OSGi container from the Apache Software Foundation.
http://www.javaworld.com/article/2077837/java-se/java-se-hello-osgi-part-1-bundles-for-beginners.html
The Apache project maintains a general-purpose OSGi container called Felix.
Here is used as ServiceMix and
The main difference between the ServiceMix and Karaf is that
ServiceMix bundles a bunch of other integration components β ActiveMQ
message broker, the Camel routing engine, and some other things
According: http://kevinboone.net/osgitest.html