Slides from my Liferay Symposium France 2016 talk aiming to explain the fundamental concepts behind OSGi (structured around Modularity Maturity Model) and what makes it the only true modular technology in Java world.
OSGi Community Event 2011 Level 1 Ad Hoc nothing Level 2 Modules decoupled from artifact Level 3 Modularity decoupled from identity Level 4 Loose-Coupling decoupled from implementation Level 5 Devolution decoupled from ownership Level 6 Dynamism decoupled from time
artifact Level 3 Modularity decoupled from identity Level 4 Loose-Coupling decoupled from implementation Level 5 Devolution decoupled from ownership Level 6 Dynamism decoupled from time Level 7 Peter Kriens only available to people who are Peter Kriens Modularity Maturity Model proposed by Dr Graham Charters at the OSGi Community Event 2011
uses:=”com.standard.power.plugs”,\ ... Export-Package ::= export ( ',' export)* List of packages (Java package + version) within this jar file that external code is allowed to access! Foo Me
com.other.power.plugs.shop;\ version=”1.5.0”,\ ... Foo Me Import-Package ::= import ( ',' import )* List of packages (Java package + version-range) that classes in this jar file expect other bundles to provide!
connect device to power outlet! Capability Can connect device to power outlet! RESOLVER Require-Capability: power.supply;\ filter:=”(& (voltage>110)\ (voltage<230))”,\ electrician;\ filter:=”(& (price<50)\ (certified=yes))”
connect device to power outlet! Capability Can connect device to power outlet! RESOLVER Require-Capability: power.supply;\ filter:=”(& (voltage>110)\ (voltage<230))”,\ electrician;\ filter:=”(& (price<50)\ (certified=yes))” org.osgi.framework.system.capabilities.extra= power.supply;voltage:Long=220
REGISTRY Service Service Service Service OSGi service registry SERVLET SERVLET GET GET REGISTER REGISTER HTTPServiceImpl HTTP Service HTTPServiceImpl REGISTER manifest
REGISTRY Service Service Service Service manifest OSGi service registry HTTP Servlet REGISTER SERVLET SERVLET GET (when needed) HTTPServiceImpl Servlet1 (path=”/1”) Servlet2 (path=”/2”) REGISTER
REGISTRY Service Service Service Service /OSGI-INF/MyComponent.xml file: <?xml version="1.0" encoding="UTF-8"?> <scr:component name=”MyComponent” xmlns:scr=”http://www.osgi.org/xmlns/scr/v1.2.0”> <implementation class=”com.liferay.MyComponent”/> </scr:component> Manifest header: Service-Component: OSGI-INF/MyComponent.xml
REGISTRY Service Service Service Service @Component( configurationPid=”hello.component.pid”, configurationPolicy=ConfigurationPolicy.OPTIONAL, enabled=true, immediate=true, name=”HelloComponent”, property={ ”vendor.name=Liferay”, ”other.property=value” }, service={HelloService.class, OtherService.class} ) public class HelloComponent implements MultiService { . . .