Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Moved to https://slidr.io/azzazzel/osgi-fundamentals

1,204 views

Published on

This slide deck will be removed from here in the future. It has been moved to : https://slidr.io/azzazzel/osgi-fundamentals

Published in: Software

Moved to https://slidr.io/azzazzel/osgi-fundamentals

  1. 1. @MilenDyankov OSGi Fundamentals
  2. 2. OSGi = Modularity
  3. 3. "When I use a word," Humpty Dumpty said, in rather a scornful tone, "it means just what I choose it to mean - neither more nor less."
  4. 4. Modularity Maturity Model proposed by Dr Graham Charters at the 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
  5. 5. 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 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
  6. 6. Modularity Maturity Model proposed by Peter Kriens in foreword to “Java Application Architecture” Level 1 Ad Hoc Level 2 Modules Level 3 Modularity Level 4 Loose-Coupling Level 5 Devolution Level 6 Dynamism Unmanaged / chaos Managing dependencies Proper isolation Minimize coupling Service-oriented architecture
  7. 7. Level 1 Monolith Level 2 Composite Level 3 Containers Level 4 Discovery Level 5 JuServices Buzzword compliant Modularity Maturity Model
  8. 8. Level 1 Monolith Unaware of own dependencies Level 2 Composite Aware of infrastructural dependencies Level 3 Containers Aware of functional dependencies Level 4 Discovery Aware of functional requirements Level 5 Adapts to changing requirementsJuServices Buzzword compliant Modularity Maturity Model
  9. 9. Level 1 Monolith Level 2 Composite Level 3 Containers Level 4 Discovery Level 5 JuServices Buzzword compliant Modularity Maturity Model
  10. 10. Level 1 Monolith Level 2 Composite Level 3 Containers Level 4 Discovery Level 5 JuServices Buzzword compliant Modularity Maturity Model
  11. 11. Buzzword compliant Modularity Maturity Model JuServices Level 1 Monolith Level 2 Composite Level 3 Containers Level 4 Discovery Level 5
  12. 12. Buzzword compliant Modularity Maturity Model JuServices Level 1 Monolith Level 2 Composite Level 3 Containers Level 4 Discovery Level 5 OSGi
  13. 13. product intermediate intermediate material
  14. 14. Product Entity Entity Entity Entity Entity Entity Offer Offer Offer Offer Offer Offer Offer Offer Offer Offer Offer
  15. 15. Application Artifact Artifact Artifact Artifact Artifact Artifact Export Export Export Export Export Export Export Export Export Export Export
  16. 16. Artifact Level 2 decoupled from artifact
  17. 17. Foo Level 2 decoupled from artifact Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Foo Bundle-SymbolicName: com.foo Bundle-Vendor: Foo, Inc. Bundle-Version: 1.0.0 . . .
  18. 18. Buzzword compliant Modularity Maturity Model JuServices OSGi Level 1 Monolith Level 2 Composite Level 3 Containers Level 4 Discovery Level 5 OK!
  19. 19. Level 3 decoupled from identity Artifact Export Artifact
  20. 20. Level 3 decoupled from identity Require-Bundle: com.foo Foo Me
  21. 21. Level 3 decoupled from identity Export-Package ::= export ( ',' export)* List of packages (Java package + version) within this jar file that external code is allowed to access! Foo Me
  22. 22. Level 3 decoupled from identity Export-Package: com.standard.power.plugs; version=”1.0.0”, com.foo.power.plugs.shop; version=”2.3.0”; 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
  23. 23. Level 3 decoupled from identity Import-Package ::= import ( ',' import )* List of packages (Java package + version-range) that classes in this jar file expect other bundles to provide! Foo Me
  24. 24. Level 3 decoupled from identity Import-Package: com.standard.power.plugs; version=”[1,2)”, com.foo.power.plugs.shop; version=”2.3.0”, 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!
  25. 25. Buzzword compliant Modularity Maturity Model JuServices OSGi Level 1 Monolith Level 2 Composite Level 3 Containers Level 4 Discovery Level 5 OK! OK!
  26. 26. Level 4 decoupled from implementation Artifact Artifact Requirement Need to connect device to power outlet! Capability Can connect device to power outlet! RESOLVER
  27. 27. Level 4 decoupled from implementation Artifact Artifact Requirement Need to 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))”
  28. 28. Level 4 decoupled from implementation Artifact Artifact Requirement Need to 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
  29. 29. Level 4 decoupled from implementation Artifact Artifact Requirement Need to 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 Provide-Capability: electrician;price:Long=10;certified=yes
  30. 30. Buzzword compliant Modularity Maturity Model JuServices OSGi Level 1 Monolith Level 2 Composite Level 3 Containers Level 4 Discovery Level 5 OK! OK! OK!
  31. 31. Level 5 decoupled from ownership & time JuServices Artifact Artifact REGISTRY Service Service Service Service
  32. 32. Level 5 decoupled from ownership & time JuServices Artifact Artifact REGISTRY Service Service Service Service manifestmanifest OSGi service registry REGISTER REGISTER manifest Interface Service 1 . . . Service N
  33. 33. Level 5 decoupled from ownership & time JuServices Artifact Artifact REGISTRY Service Service Service Service manifestmanifest OSGi service registry REGISTER USE manifest Interface Service 1 . . . Service N REGISTER
  34. 34. Level 5 decoupled from ownership & time JuServices Artifact Artifact REGISTRY Service Service Service Service OSGi service registry SERVLET SERVLET GET GET REGISTER REGISTER HTTPServiceImpl HTTP Service HTTPServiceImpl REGISTER manifest
  35. 35. Level 5 decoupled from ownership & time JuServices Artifact Artifact REGISTRY Service Service Service Service manifest OSGi service registry HTTP Servlet REGISTER SERVLET SERVLETGET (when needed) HTTPServiceImpl Servlet1 (path=”/1”) Servlet2 (path=”/2”) REGISTER
  36. 36. Level 5 decoupled from ownership & time JuServices Artifact Artifact REGISTRY Service Service Service Service Register OSGI service (manually) SINGLETON PROPERTIES CONTRACT
  37. 37. Level 5 decoupled from ownership & time JuServices Artifact Artifact REGISTRY Service Service Service Service Use an OSGI service (manually) DONE WITH THE SERVICE START USING THE SERVCE FIND A SERVCE
  38. 38. Level 5 decoupled from ownership & time JuServices Artifact Artifact REGISTRY Service Service Service Service Declarative services and Service Component Runtime (SCR)
  39. 39. Level 5 decoupled from ownership & time JuServices Artifact Artifact 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
  40. 40. Level 5 decoupled from ownership & time JuServices Artifact Artifact 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 { . . .
  41. 41. Level 5 decoupled from ownership & time JuServices Artifact Artifact REGISTRY Service Service Service Service @Activate void open(Map<String,?> properties) { } @Deactivate void close() { } @Modified void modified(Map<String,?> properties) { }
  42. 42. Level 5 decoupled from ownership & time JuServices Artifact Artifact REGISTRY Service Service Service Service @Reference( cardinality=ReferenceCardinality.MANDATORY, name = “LogService”, policy = ReferencePolicy.STATIC, policyOption=ReferencePolicyOption.RELUCTANT, service = LogService.class, target = “(vendor.name=Liferay)”, unbind = “unsetLog”, updated = “updatedLog” ) void setLog( LogService log) { } void unsetLog( LogService log) { } void updatedLog( Map<String,?> ref ) { }
  43. 43. Buzzword compliant Modularity Maturity Model JuServices OSGi Level 1 Monolith Level 2 Composite Level 3 Containers Level 4 Discovery Level 5 OK! OK! OK! OK!
  44. 44. The essence of modularity is Not knowing
  45. 45. The essence of modularity is Not knowing Which enforces optimization for Predictability
  46. 46. Which results in application Agility The essence of modularity is Not knowing Which enforces optimization for Predictability
  47. 47. milen.dyankov@liferay.com @MilenDyankov http://www.liferay.com @Liferay

×