Java Magazine, Mar/Apr 2018
ORACLE COM JAVAMAGAZINE MARCH APRIL 2018 48 microservices and containers simulation ui module info java module simulation ui requires simulation math For comparison Figure 4 shows the OSGi file structure for an application similar to the Java module version shown in Figure 3 Given this overview of both OSGi and Java modules lets examine their strengths and diferences OSGi and Java Modules Compared OSGi creates a plugin model for applications one such common application is the Eclipse IDE OSGis success is largely due to its support for dynamic component control In this case plugins or components modules defined as OSGi bundles are loaded dynamically and then activated deactivated and even updated or removed as needed Presently this dynamic module lifecycle is not available with Java modules Figure 4 Example showing OSGi modules available in the sample simulation application Additionally compared with Java modules OSGi supports improved versioning Other OSGi advantages are related to isolation For example bundle changes require only the direct dependencies to be recompiled whereas a Java modules entire layer along with all child layers needs to be recompiled if just one module changes Figure 5 Enforcing proper coding practices Java modules help to hide internal implementations private classes from usage and even from reflection which is an improvement over earlier versions of Java OSGi cannot enforce this However although the ability to use internal classes within OSGi bundles using reflection can be considered a weakness it does allow for dependency injection of private classes which is more dificult if not impossible with Java modules The downside is that OSGi bundles still sufer from classpath issues such as runtime exceptions for missing dependencies or arbitrary class loading for packages with the same
You must have JavaScript enabled to view digital editions.