Introduction to-osgi

8,556 views
8,307 views

Published on

Introduction to OSGi and Apache Karaf Runtime.

Published in: Technology
1 Comment
19 Likes
Statistics
Notes
  • Having some jars, without having informations as version or what are the 'required' runtime dependencies, is like having a cooking recipe which only contains raw ingredients.
    Unfortunately I need some more information to cook a 'pastitsio' than 'it contains spaghetti'.

    Unfortunately this how class loading works, you throw raw materials into the class-path and you pray that somehow things are going to work.

    This was a short explanation to an example contained in the presentation that probably did not make any sense.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
8,556
On SlideShare
0
From Embeds
0
Number of Embeds
17
Actions
Shares
0
Downloads
351
Comments
1
Likes
19
Embeds 0
No embeds

No notes for slide

Introduction to-osgi

  1. 1. Introduction to OSGi using Apache Karaf<br /> Ioannis Canellos<br />JHUG / 16 April 2011<br />
  2. 2. Presenting today…<br />OSGi<br />Open Services Gateway initiative, since 1999<br />Initially targeted embedded devices<br />OSGi containers: Felix, Equinox, Knoperfish, Concierge<br />Most known use is Eclipse IDE<br />Apache Karaf<br />Apache OSGi runtime runs on any OSGi container<br />Born inside Service Mix, now is Top level project<br />Standard runtime for Geronimo, Service Mix, Sling<br />Ecosystem for deploying OSGi/EE applications<br />
  3. 3. Part I<br />Introduction to OSGi<br />
  4. 4. Introduction to OSGi<br />Problem <br />Solution<br />Architecture<br />Tools<br />OSGi in the Enterprise<br />Questions & Answers<br />
  5. 5. The problemaspects <br />Dependency management<br />Version Hell<br />Conflicting dependencies<br />Class loading issues<br />Dynamic behavior<br />Difficulties to control component lifecycle<br />Lack of a pure modularity solution<br />
  6. 6. The problemsDependency management<br />Large number of transitive dependencies<br />Conflicts among among dependencies<br />Class loading issues<br />Boot class loader<br />JTA<br />System class loader<br />JTA<br />war<br />war<br />
  7. 7. The problemsDynamic Behavior<br />Components & Services need come and go<br />Components need to get updated / replaced<br />Components need to started / stopped<br />Real life examples<br />Eclipse IDE<br />Adding/Removing “plugins”<br />Ebay<br />Multiple version of the same component<br />
  8. 8. The problemsModularity<br />The JVM does not address need for modularity<br />The class path paradox<br />The jar is a “black box”<br />No dependencies & No version<br />The pastitsioexample<br />The “WORA” promise was repeatedly failed<br />JavaBeans<br />EJBs<br />Has the quest for modularity failed ?<br />Project Jigsaw will be shipped with JDK 8 <br />OSGi is already here<br />
  9. 9. The OSGi SolutionOverview<br />A Layer …<br />A deployment infrastructure<br />Bundles = class + metadata (import/exports)<br />Bundles have a lifecycle<br />Bundles have their own Class loader<br />Class loading delegation between dependant bundles <br />A service platform<br />Defines a Service Registry<br />Bundles provide or request services<br />The service can “come and go”<br />
  10. 10. Architecture<br />
  11. 11. Architecture Execution Environment<br />The Runtime where the bundles live<br />A bundle can bound to an Execution Environment<br />JRE-1.5<br />J<br />JRE-1.3<br />OSGi/Minimum-1.0<br />
  12. 12. Architecture Module Layer<br />Bundles import, export or have private packages<br />Each package can be assigned version range<br />A bundle (fragment)can be attached to a bundle (host)<br />Export Package<br />javax.transaction 1.01B<br />Import Package<br />javax.transaction [1.0,1.1)<br />Export Package<br />javax.transaction 1.1<br />Bundle Name: JMS API<br />Import Package: javax.transaction<br />Export Package: javax.jms<br />Bundle-RequiredExecutionEnvironment: J2SE-1.5<br />
  13. 13. Architecture Module Layera MANIFEST.MF example<br />Manifest-Version:1.0<br />Import-Package:<br />javax.transaction;version="1.1”, javax.transaction.xa;version="1.1”<br />Export-Package:<br />javax.jms;version="1.1”<br />Bundle-SymbolicName:org.apache.geronimo.specs.geronimo-jms_1.1_spec<br />Tool:Bnd-0.0.227<br />
  14. 14. Installed<br />Starting<br />Architecture Lifecycle Layer<br />start<br />update <br />refresh<br />resolve<br />Started<br />Resolved<br />uninstall<br />uninstall<br />stop<br />Stopped<br />Uninstalled<br />
  15. 15. Architecture Service Layer<br />Each bundle can register or lookup a Service<br />Each service corresponds to one or more interfaces<br />Each service can be assigned and queried using properties<br />Service Registry<br />register<br />lookup<br />ServiceProvider<br />Service Consumer<br />
  16. 16. OSGi Tools working with services<br />Managing Services programmatically<br />Using the OSGi blueprint<br />Spring Dynamic Modules<br />Apache Aries<br />Felix i-Pojo<br />
  17. 17. OSGi Tools creating bundles<br />Manually providing the MANIFEST.MF<br />Bnd command line tool<br />Maven Bundle Plug-in<br />Spring’s Bundlor<br />Maven plug-in flavor<br />Command line flavor<br />
  18. 18. OSGi Tools OSGi Bundle Repository<br />Simplifies the provisioning of bundles<br />The “apt-get install” for the OSGi<br />Integrates with public repositories<br />Eclipse Orbit<br />Spring’s Enterprise Bundle Repository<br />
  19. 19. OSGiEnd of Part I<br />Questions & Answers<br />
  20. 20. Part II<br />Getting started with Apache Karaf<br />
  21. 21. Apache Karafagenda<br />Overview <br />Shell Console<br />Deployer<br />Features Concept<br />Security<br />Logging Service<br />Demo<br />Questions and Answers<br />
  22. 22. Apache KarafOverview<br />Born as Service Mix Kernel project<br />Grown inside Apache Felix project<br />Become a Top Level Apache project last year<br />
  23. 23. Apache KarafShell Console<br />Extensible <br />Auto complete & coloring support<br />Rich command set, covers most OSGi concepts/services<br />Special commands for the development phase<br />
  24. 24. Apache KarafDeployer<br />File Scanner<br />War Transformer<br />Configuration<br />Bundles<br />Transformation<br />Spring<br />Transformer<br />Blueprint<br />Transformer<br />Configuration<br />Admin<br />URL<br />Handler<br />Maven Handler<br />HTTP Handler<br />Hot deployment<br />Large number of supported artifacts<br />Large number of installation mediums<br />OBR Handler<br />
  25. 25. Apache KarafFeatures Concept<br />A Karaf feature is a descriptor which defines…<br />A set of bundles<br />A set of configurations<br />A set of other features<br />Allows provisioning of applications<br />Maven integration<br />OBR integration<br />
  26. 26. Apache KarafFeatures Example<br /><feature name="http" version=”2.2.0” resolver=“(obr)”><br /><configname="org.ops4j.pax.web”> <br />org.osgi.service.http.port=8181 <br /></config><br /><feature version="[7.0,8.0)">jetty</feature><br /> <bundle dependency=“true”>mvn:javax.servlet/servlet-api</bundle><br /> <bundle>mvn:org.ops4j.pax.web/pax-web-api</bundle><br /></feature><br />
  27. 27. Apache KarafSecurity<br />JAAS based security<br />Multiple login module implementations<br />Property Login Module<br />JDBC Login Module<br />LDAP Login Module<br />Command line support<br />Provisioning of any JASS realm <br />Add users roles etc<br />
  28. 28. Apache KarafLogging Service<br />Centralized Logging configuration<br />Supports most logging APIs<br />Log4J<br />Slf4j<br /> Commons Logging<br />Command line support<br />clear, display, tail change threshold etc.<br />OSGi integration<br />per bundle appender, osgi specific attributes<br />
  29. 29. Apache Karaf End of Part II<br />Questions & Answers<br />
  30. 30. Thank you<br />

×