Is it appropriate to use the OSGI environment for a small java application?

I have a plan to redefine one of my small but useful applications using OSGI. I have never used it, so I ask that it is appropriate to use OSGI on a small application, and this is a big difference in speed and / or memory when using such a structure. Also, if this is a good option, I would ask which implementation is best for small applications.

Thank you!

+4
source share
4 answers

For modern computer systems, the speed and memory size of OSGi are irrelevant: remember that OSGi was designed for devices with limited resources. The memory size is in hundreds of kilobytes, and after the service is resolved, the structure does not affect the speed of your application (for example, there are no proxy servers). In short, don't worry about runtime.

I like the way a properly designed OSGi application cleans the application structure, making you think about your modules and services. I will stay away from all the benefits of modulation and service orientation here, just remember that they apply to small applications as well as large ones. Hey, you can even start finding reusable components!

You will need to think about packaging and sending your application: depending on your audience, you can leave by simply sending a bunch of packages, using a shell script to get the system (using, for example, Pax Runner ), or you may need to invest in something more interesting, for example, a beautiful application packaging with an icon.

+5
source

I use karaf / iPOJO as an OSGi container to update library versions while the application is running.

However, for a small application that you can restart at any time, I would put everything as simple as possible.

+3
source

Today OSGi has no overhead, the range varies from 350 thousand to 1 mb. At run time, OSGi stays in your way.

You should take a look at bndtools, it provides a very nice development environment for OSGi packages, including startup, debugging and testing. You can easily switch between frameworks.

You can find bndtools in the Eclipse market.

+3
source

OSGi is still β€œslightly” more overhead than regular Java projects. Instead, I would rely on Maven modules if you want to have version control.

If you choose OSGi apporach, look at creating an Eclipse plugin. It is based on Eclipse Equinox and can be applied to new projects quickly thanks to Wizzards. Eclipse offers to create new projects.

Good luck

+2
source

All Articles