Modulation of existing web applications with OSGi

I need some advice here. I want to modulate existing Java Java applications.
Tried to do it with maven and it worked. I managed to isolate the service level in one module ("core"), and the other two web applications use the same main module.

Now I want to try it with OSGi, I want to use OSGi in modulation so that I can use it when necessary.
I have a few questions here:
1. How to modulate any part of my application with OSGi, how to start from it? There are many examples to start with OSGi, but no one does this in an existing application.
2. How to use it on tomcat server? I know that I need an OSGi container (Equinox, Apache Felix, ..) to use OSGi, but how to install Tomcat and OSGi container together?

If anyone has any tips or you can connect me with some useful tutorials,
I would be very grateful.

Thanks in advance,
Milos.

+4
source share
3 answers

Using OSGi requires a thorough knowledge of all the functions of OSGi, especially with regard to class behavior. You must bear in mind that OSGi really benefits your application. If you use Class.forName extensively, you will have problems. There are also many third-party libraries that are not easy to use with OSGi.

So, be sure to check out OSGi before you change anything in your code. I would recommend the OSGi book in depth and / or OSGi in action for learning and understanding OSGi.

Do not get me wrong, OSGi is a good technology, but it is much more complicated than it seems at first glance. You won't need Tomcat if your application uses OSGi completely, the OSGi container is the runtime for OSGi applications, because Tomcat Server is another runtime. If you need to communicate with Tomcat Server, you can use JMS or something similar. Take a look at the remote OSGi service

+2
source

I would recommend Spring dynamic modules (http://www.springsource.org/osgi). Its advantages are that you do not need to get your hands dirty with all the unpleasant OSGi details and use it through Spring IOC.

Even if you want to deal with OSGi, this does not mean that you need to make an existing OSGi application. The following two specifications can help you abstract your components from the OSGi API:

Good luck

+1
source

Source: https://habr.com/ru/post/1347101/


All Articles