This is a biggie.
I have a well-structured, but monolithic code base that has a primitive modular architecture (all modules implement interfaces, but have the same class path). I understand the stupidity of this approach and the problems it presents when I go to deploy on application servers that may have different conflicting versions of my library.
Currently, I am addicted to about 30 cans, and I am in the middle of the way, although they are picked up. Now, some of my modules easily declare version-specific versions, such as my network components. They statically refer to classes in the JRE and other BNDded libraries, but my associated JDBC components are created through Class.forName (...) and can use any of several drivers.
I break everything down into OSGi packages by service area.
- My main classes / interfaces.
- Information about related components.
- Database Access Components (via JDBC).
- etc....
I want my code to be able to be used without OSGi through a single jar file with all my dependencies and without OSGi in general (via JARJAR), and also be modular using OSGi metadata and granular packets with information dependency.
How to configure my package and my code so that it can dynamically use any driver on the classpath and / or in the OSGi container environment (Felix / Equinox / etc.)?
Is there any execution method during discovery in an OSGi container that is compatible with containers (Felix / Equinox / etc.)?
Do I need to use a different class loading mechanism if I'm in an OSGi container?
Do I need to import OSGi classes into my project in order to be able to load an unknown JDBC driver while working through the database module?
I also have a second way to get the driver (via JNDI, which is really applicable when working on the application server), do I need to change the JNDI passcode for application servers that support OSGi?
java jdbc modularity osgi
Chris
source share