Top Banner
Intro to OSGi Ivan Chadikovski AEM Team Lead at Tricode February 2016
16

Intro to OSGi

Apr 15, 2017

Download

Technology

Tricode
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Intro to OSGi

Intro to OSGiIvan Chadikovski

AEM Team Lead at TricodeFebruary 2016

Page 2: Intro to OSGi

AgendaModule (What is it?)

OSGi (the mission)

Bundles (ARE modules!)

Component Models

Declarative Services

SRC Annotations

Implementations

Who is using OSGi

Questions?

Page 3: Intro to OSGi

Module (What is it?)A module must have one, well defined purpose.

A module should know nothing about implementations of the modules it depends on, It should rely on their public interface.

Benefits: Separation of concerns, parallel development, ease of maintenance.

Page 4: Intro to OSGi

JARs (Are NOT modules!)JARs are not modules, they can be considered more as

deployment units.

What JARs are missing to achieve modularity:

meaningful names, versions, vendors, exports, explicit class restriction, explicit dependency information, etc..

Build tools such as Maven, Ant and Gradle tackle some deficiencies, but do not offer true modularity.

True modular approach currently is offered only by OSGi.

Page 5: Intro to OSGi

OSGi (the mission)OSGi - The dynamic module system for Java.

Was originally conceived as a standard embedded systems.

Driven by OSGi AllianceConsortium of vendors (big players in tech industry).

Mission

Build ecosystem to support component and service based development in Java.

Page 6: Intro to OSGi

OSGi Architecture

Page 7: Intro to OSGi

Bundles (ARE modules)JARs with metadata that OSGi can interpret (via MANIFEST.MF)

Can also be used outside OSGi.

Dynamic and have a life-cycle Installed, Resolved, Active, Uninstalled, Start, Stop.

Can be updated without down time.

Page 8: Intro to OSGi

MANIFEST.MFExample:

Bundle-Name: Hello WorldBundle-SymbolicName: nl.tricode.helloworldBundle-Description: Hello World BundleBundle-Version: 1.0.0Bundle-Activator: nl.tricode.ActivatorExport-Package: nl.tricode.helloworld;version="1.1.0"Import-Package: org.osgi.framework;version=[1.3.0, 2)"

Page 9: Intro to OSGi

BundleActivatorExample:

Oldest way to activate code in your bundle.

It couples you to OSGi API, using Component Models is far more convenient.

Page 10: Intro to OSGi

Component ModelsComponent, the LEGO vs BEES analogy

Component Models: Defining components that interact with each other via Services.

Multiple Choices:Blueprint

Declarative Services (DS)

Page 11: Intro to OSGi

Declarative ServicesIt helps developer to concentrate on application logic and takes

responsibility for almost all OSGi aspects of tracking and registering services.

Service (API) implementations can be swapped on the fly.

SCR Annotations (Automated creation of Descriptor Files).

Page 12: Intro to OSGi

SCR AnnotationsSCR Annotations (Automated creation of Descriptor Files).

Page 13: Intro to OSGi

SCR Annotations

Page 14: Intro to OSGi

Implementations

Page 15: Intro to OSGi

Who is using OSGi

Page 16: Intro to OSGi

Questions?