I have successfully created an osgi application with apache felix. Now I want to integrate spring 4 with it. How do I do it ? Can anyone provide me a complete example ?
Thanks
Arpan
In order to use Spring in your OSGi based java application for Spring Controllers or Dependency Injection you need to use Apache Aries Blueprint. Apache Karaf also provides a convenient distribution of the Felix OSGi Container with support for Apache Aries Blueprint. However before embarking on mixing Spring with OSGi I recommend reading the discussion on Blueprint here
Related
I have successfully deployed SOAP services via Apache CXF within Apache Karaf, but would now like to do the same with OSGi enroute. I suspect my sticking point is the jaxws:endpoint definition, still pursuing resolution.
With that said, does anyone know of a working example of Apache CXF within OSGi enroute that I could reference?
I want to use Spring in an application which loads several modules using OSGi. I want to be able to inject beans exposed by bundle A into targets exposed by bundle B.
I saw blueprint which seems to require Spring 3, and eclipse gemini which supports Spring 4 but seems pretty abandoned.
What's the latests on using OSGi with Spring 4?
Thanks
BLueprint is independent from spring. For example Aries Blueprint does not need any spring dependency. I am not sure about Gemini but I think it also does not require spring. Blueprint is optimized for OSGi and works well. It does not provide all spring features though.
Spring never worked well in OSGi. Spring 4 now even is not delivered as bundles. So I would not suggest to use spring in OSGi at all.
That said Apache Karaf offers spring 4 bundles but I am not sure how well they work. In any case I doubt you will get any OSGi support from spring source.
I am new to ESB's and was reading an older book on Mule and ServiceMix.
After a bit of research, and looking at FuseSource docs which state that JBI is deprecated in favour of OSGi services, am I correct in assuming that for integration purposes :-
ServiceMix ESB is (nowadays) mainly Camel running in an OSGi container
Services can be deployed as OSGi bundles, and Camel can somehow use these services where it would otherwise uses POJOs to do custom processing
Thanks
My two cents: ServiceMix is a "ready-made" integration container for JAVA. It packs together a number of features on top of an OSGI runtime (Apache Karaf), of whom highlights:
Apache Camel – EIP framework
Apache ActiveMQ – messaging
So:
ServiceMix ESB is (nowadays) mainly an OSGI container including Camel (as well as ActiveMQ, CXF, ...)
Everything is deployed as OSGI bundles.
I like el.atomo s answer but I'll add for question 2:
Services can be deployed as OSGi bundles, and Camel can somehow use these services where it would otherwise uses POJOs to do custom processing
Camel itself is just POJOs. Based on the servicemix camel guide, each OSGI bundle is going to have it's own CamelContext. NMR (or TCP or HTTP or JMS or whatever camel component you use) is used to communicate between the specific OSGI bundles and camel routes which sit in different OSGI bundles (and therefore different CamelContexts)
The biggest difference between vanilla OSGi with camel setup inside it and Servicemix is probably the inclusion ActiveMQ, NMR, and BPMN2.
References:
http://servicemix.apache.org/docs/4.5.x/
http://servicemix.apache.org/docs/4.5.x/nmr/nmr-camel.html
http://servicemix.apache.org/docs/4.5.x/camel/camel-guide.pdf
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 Blueprint standard)
TLDR: Apache Karaf is much more 'batteries-included'. It can also run on any OSGI runtime.
Apache Felix (which is an implementation of the OSGi 4.2 framework)
Sort of. Apache Karaf can use Apache Felix. Apache Karaf can also use Equinox or another OSGi runtime. By default, the Apache Karaf standard download does come with Apache Felix.
Apache Aries (which is an implementation of the Blueprint standard)
Again, sort of. The standard download of Apache Karaf does come with Apache Aries by default.
Now let's talk about what OSGI (Apache Felix, Equinox) is and what Apache Karaf is:
OSGI is very simple. You can start an OSGI runtime in your application and not even notice it. The shell, the ability to hot deploy from a folder, install from a maven repo, etc..These are all extras that OSGI doesn't have to do and are provided by additional projects like Karaf, GOGO, or Pax
Now on to Apache Karaf:
It is basically an OSGI environment that provides some additional goodies on top of a standard OSGI implementation. Because Apache Karaf is just built on standard OSGI, it can in theory run on any OSGI runtime. This gives you a uniform interface for working with OSGI runtimes.
Some goodies Apache Karaf provides that you won't see in a Apache Felix without some additional work:
Folder based hot deployment
A (IMHO) better default console than gogo. (org.apache.karaf.shell)
Remote SSH access to that console. (org.apache.karaf.shell.ssh)
Centralized Logging System. (org.apache.karaf.log)
It has it's own way of provisioning bundles and start levels. (org.apache.karaf.features)
Karaf has it's own maven plugins as well.
Pretty much anything here:
http://mvnrepository.com/search.html?query=org.apache.karaf*
I mentioned Karaf having it's own way of provisioning bundles and start levels. Apache Karaf also comes with a bunch of pre-defined ones to get started with. I know Apache Felix comes with some as well, through OBR, but Apache Karaf comes much more 'batteries-included'.
Apache Karaf is a swiss army knife to run OSGi "stuff" and non OSGi things bundled as OSGi.
Felix and Aries are default but the frameworks are pluggable, so equinox works as well.
"Unix like" shell accessible from CLI or SSH
Hotdeploy of bundles
May deploy almost anything as a bundle (plain .jar, spring xml, blueprint, etc)
WAR files
Deploy from maven - including autowrapping non OSGi bundles.
Web Console
Karaf features - ".kar files" that includes bundles and custom karaf features/commands.
A side note is that Karaf is part of ServiceMix (the initial name was ServiceMix kernel), so it has very tight integration with Apache Camel, Apache CXF and Apache ActiveMQ. Turning Karaf into an ESB with those features is trivial.
Apache Karaf is just an OSGi framework (it can be equinox, felix .etc) with a bunch of predefined modules.
Apache Karaf architecture:
Are there publicly available examples of Spring applications in Karaf 2.2.x, in particular ones using #Repository and other Spring component annotations?
If you want to use Spring and Karaf you're most probably bound to Spring DM version 1.2.1 and therefore also probably also bound to Spring 2.5.6. You're probably better of switching to blueprint.