Microservices are often created by refactoring a service out of an existing monolithic application. There are some who suggest that for greenfield development it is actually preferable to build a monolith first and allow microservices to be pulled out as service boundaries are discovered. But whether you’re dealing with an existing Java-based monolith or are looking for ways to develop new functionality, the OSGi framework and Eclipse OSGi tooling can do a lot to improve your development process.
In this presentation I’ll start with the basic premise that it’s possible to host most Java applications (with some minor alterations) inside of an OSGi framework. Even if your application is composed of one or a few massive JAR files, you can still run it on OSGi as a single bundle. And once that has been done, you now have access to all of the power of OSGi classloading rules and related Eclipse tooling to help you in your refactoring.
Using a real world example, I’ll demonstrate how OSGi classloading and tooling can give you precise feedback as you refactor a microservice out of a monolith. As you make each small refactoring move, the OSGi framework and tooling will ensure that your application still compiles and runs correctly. In the end, you don’t even need to run your application using OSGi. In this context, you can think of OSGi as a scaffolding that surrounds your Java application during the refactoring process, but that can be taken down when the process is complete.
But be warned, you may find that OSGi is useful enough to keep around!