Java Magazine, Mar/Apr 2018
ORACLE COM JAVAMAGAZINE MARCH APRIL 2018 44 microservices and containers internal classes are not directly visible outside the bundle thereby increasing true isolation Further objects within bundles are shared through services Figure 2 defining strict contracts for component usage and communication while further hiding internal implementation The result of this isolation is reduced complexity increased transparency into the running system and greater component reuse In Figure 2 which purposely difers from the typical OSGi layer illustration the main section where modularity is defined is outlined in red Security is shown as a shared responsibility involving the OS the JVM the OSGi environment and your application code No single component can be completely responsible for security Listing 1 shows a sample OSGi bundle for a partial math library to be used in a simulator application four files are shown in the listing Listing 1 Simplified sample OSGi bundle implementation package example simulation math public interface SimulationMath double degreesToRadians double degrees double getTargetAngle double centerOffset double targetDistanceZone package example simulation math impl import example simulation math SimulationMath public class MyMathImpl implements SimulationMath public double degreesToRadians double degrees return radians public double getTargetAngle double centerOffset double targetDistanceZone
You must have JavaScript enabled to view digital editions.