OSGI with Apache Karaf
Introduction Gerald Preissler
Talend Professional Services
Consultant & Architect Talend ESB CXF
Camel
Karaf
ActiveMQ
Talend Open Studio [email_address] Document Identifier
Agenda Why OSGI?
What is Apache Karaf?
How can I develop for Apache Karaf?
What are the advanced features?
What is coming? Document Identifier
Why OSGI? Component-based modularity
SOA in the small
Standard services Document Identifier
Component-based modularity An individual component is a bundle A bundle is a jar file with additional metadata Imports Exports Dependency management is enabled through metadata Imports Exports Bundle lifecycle is controlled by the OSGI container Classloading environments are separated between bundles Multiple bundles can be combined into a feature Feature Document Identifier Bundle Classes & Ressources Metadata Classes & Ressources Metadata
Component-based modularity Metadata is located in MANIFEST.MF Can be created manually Peter Krien's bnd tools and derived utilities provide a convenient way to create it automagically Manifest­Version: 1.0 Bundle­ManifestVersion: 2 Bundle­Version: 2.1.6 Bundle­Name: Talend Logger Bundle­SymbolicName: t_logger Export­Package: org.talend.osgi.logger;version=2.1 Import­Package: org.apache.log4j;version=”[1.2,2)” Private­Package: org.talend.osgi.logger.internal Document Identifier
SOA in the small ● OSGi Service Registry allows a bundle to expose or use  services ● A service is specified by an interface ● A provider  bundle registers an interface implementation Service Registry Bundle Bundle register get listen ● A consumer bundle searches and uses a service Document Identifier B A Interface Impl Interface

W-JAX 2011: OSGi with Apache Karaf

  • 1.
  • 2.
  • 3.
  • 4.
    Consultant & ArchitectTalend ESB CXF
  • 5.
  • 6.
  • 7.
  • 8.
    Talend Open Studio[email_address] Document Identifier
  • 9.
  • 10.
  • 11.
    How can Idevelop for Apache Karaf?
  • 12.
    What are theadvanced features?
  • 13.
    What is coming?Document Identifier
  • 14.
  • 15.
  • 16.
  • 17.
    Component-based modularity Anindividual component is a bundle A bundle is a jar file with additional metadata Imports Exports Dependency management is enabled through metadata Imports Exports Bundle lifecycle is controlled by the OSGI container Classloading environments are separated between bundles Multiple bundles can be combined into a feature Feature Document Identifier Bundle Classes & Ressources Metadata Classes & Ressources Metadata
  • 18.
    Component-based modularity Metadatais located in MANIFEST.MF Can be created manually Peter Krien's bnd tools and derived utilities provide a convenient way to create it automagically Manifest­Version: 1.0 Bundle­ManifestVersion: 2 Bundle­Version: 2.1.6 Bundle­Name: Talend Logger Bundle­SymbolicName: t_logger Export­Package: org.talend.osgi.logger;version=2.1 Import­Package: org.apache.log4j;version=”[1.2,2)” Private­Package: org.talend.osgi.logger.internal Document Identifier
  • 19.
    SOA in thesmall ● OSGi Service Registry allows a bundle to expose or use services ● A service is specified by an interface ● A provider bundle registers an interface implementation Service Registry Bundle Bundle register get listen ● A consumer bundle searches and uses a service Document Identifier B A Interface Impl Interface
  • 20.
    Standardized Utility ServicesService Description Configuration Admin set and get the configuration information of deployed bundles Logging receives log entries and then dispatches these entries to other bundles Event Admin inter-bundle communication mechanism based on a publish-and-subscribe model User Admin database with user information (private and public) for authentication and authorization purposes ... Source : Wikipedia
  • 21.
    What is Karaf?- Sits “on top” of an OSGI container - Adds additional functionality via add-on features - Control of container via direct shell, ssh or web console - Provisioning and deployment via filesystem, Maven repository, archive, OBR - Administration and management via JMX - Configuration via filesystem, web console, JMX - Dependency injection with Spring DM or Blueprint Document Identifier OSGI Container Console Provisioning & Deployment Admin Management Configuration Blueprint ….
  • 22.
    How can Idevelop for Apache Karaf? Document Identifier
  • 23.
    Use the standardMaven project structure Organize sources and resources as usual
  • 24.
    No OSGI-specific configurationrequired For OSGI-services use Blueprint configuration Use the Maven Bundle plugin to generate your OSGI configuration Document Identifier
  • 25.
    Deploy locally ContainerRepository mvn package mvn install bundle:install file:// ... bundle:install mvn: ... Document Identifier
  • 26.
    Get your dependenciesBundles for 3rd party dependencies are easily available Use a pre-packaged bundle Maven Central
  • 27.
  • 28.
    SpringSource Enterprise BundleRepository Wrap an existing JAR file By adding the MANIFEST.MF
  • 29.
    Using bnd orother tools Document Identifier
  • 30.
    Use Karaf WebConsoleto control your container Provides a remote admin gui with similar capabilities like the local shell View and control bundles and features
  • 31.
    View and editbundle configuration
  • 32.
  • 33.
  • 34.
  • 35.
    Dynamically configure yourapplication Imports Exports Configuration source ConfigAdmin service monitor inject Document Identifier Bundle Classes & Ressources Metadata Container
  • 36.
    Package your featurefor deployment Container mvn package deploy Document Identifier Karaf Archive (KAR)
  • 37.
    Integrate Karaf withCXF and Camel CXF Provide WebService based applications as OSGi bundles
  • 38.
  • 39.
  • 40.
    Or use pre-packageddistribution, e.g., Talend ESB Document Identifier Container
  • 41.
    Advanced features Childinstances Provide multiple container instances from one installation Karaf Cellar Clustering for Karaf Karaf Cave (incubation) Better support for OSGi Bundle Repository ... Document Identifier
  • 42.
    Where to gofrom here? Karaf homepage karaf.apache.org Blogs Christian Schneider www.liquid-reality.de/ Dan Kulp www.dankulp.com/blog/ Jean-Baptiste Onofre blog.nanthrax.net/ Talend Forum www.talendforge.org/forum/ Document Identifier