SlideShare a Scribd company logo
OSGi on 
Google Android 
using Apache Felix 
Marcel Offermans 
Karl Pauls 
luminis
luminis 
Who are we? 
• Karl Pauls 
• Marcel Offermans 
Arnhem Enschede 
image © 2008 Google Earth
luminis 
Agenda 
• Android 
• Introduction and architecture 
• Hello world demo 
• OSGi 
• Introduction 
• Framework and compendium 
• Apache Felix on Google Android 
• Getting it to run 
• Creating a dynamic application: paint program
luminis 
Agenda 
• Android 
• Introduction and architecture 
• Hello world demo 
• OSGi 
• Introduction 
• Framework and compendium 
• Apache Felix on Google Android 
• Getting it to run 
• Creating a dynamic application: paint program
luminis 
Android 
• First SDK release: november 2007 
• Android Developer Challenge, $10M prize money 
• Current SDK (M5 RC15): march 2008 
• Phones: second half of 2008?
luminis 
Android 
• Device Architecture 
• Dalvik Virtual Machine 
• From source to deployment 
• Anatomy of an application 
• Application life cycles
Architecture This image is 
rather low-res, 
so perhaps draw 
it again... 
luminis
luminis 
Dalvik Virtual Machine 
• interpreter-only, register based virtual machine 
• optimized to run multiple VM instances 
• executes files in .dex format 
• runs on posix-compliant operating systems 
• looks like Java ;)
From source to deployment 
.java .class .jar .dex .apk 
• Eclipse Plugin: Android Development Tools 
• compiles and packages automatically 
• allows you to launch and debug in the emulator 
• Command line: activityCreator.py 
• generates project structure 
• Ant build.xml file, optionally IntelliJ project files 
luminis 
javac jar dx aapt
luminis 
Anatomy 
• activity, a single screen 
• intent, describes what the application wants done 
• intent filter, describes intents that can be handled 
• intent receiver, non UI code that reacts to intent 
• service, background process with API 
• content provider, for shared data access
luminis 
Anatomy Example 
intent 
filter 
activity intent activity 
intent 
service 
intent 
filter 
intent 
receiver
luminis 
Life cycle 
• Application life cycle is not controlled by the 
application itself 
• Android maintains an “importancy hierarchy” 
based on the components and their state: 
• foreground process 
• visible process 
• service process 
• background process 
• empty process
luminis 
Life cycle (Activity)
luminis 
Hello world demo! 
• Create an application with an activity in Eclipse 
• Set “hello world” text 
• Create a breakpoint 
• Deploy and debug the application
luminis 
Agenda 
• Android 
• Introduction and architecture 
• Hello world demo 
• OSGi 
• Introduction 
• Framework and compendium 
• Apache Felix on Google Android 
• Getting it to run 
• Creating a dynamic application: paint program
luminis 
OSGi history 
• Started as an embedded platform for the “home 
gateway” 
• Originally under the JCP as JSR-8 (1999) 
• OSGi alliance, consists of a large number of big 
companies, with the following mission: 
• Maintaining and publicizing the OSGi specification. 
• Certifying implementations. 
• Organising events. 
• Current version: OSGi Release 4.1 (JSR-291)
luminis 
OSGi today 
OSGi technology is the dynamic module system 
for Java™ 
OSGi technology is Universal Middleware. 
OSGi technology provides a service-oriented, component-based 
environment for developers and offers standardized 
ways to manage the software lifecycle. These capabilities 
greatly increase the value of a wide range of computers 
and devices that use the Java™ platform.
luminis 
OSGi Alliance 
• Expert Groups: 
• core platform (CPEG) 
• mobile (MEG) 
• vehicle (VEG) 
• enterprise (EEG) 
• residential (REG) 
• Working Groups: 
• marketing 
• requirements
luminis 
OSGi specification 
OSGi Service Platform 
Service Compendium 
The OSGi Alliance 
Release 4, Version 4.1 
April 2007 
OSGi 
Alliance 
Digitally 
signed by 
OSGi Alliance 
DN: cn=OSGi 
Alliance, c=US 
Date: 
2007.02.22 
14:44:10 + 
01'00' 
Signatu 
re Not 
Verified 
OSGi Service Platform 
Core Specification 
The OSGi Alliance 
Release 4, Version 4.1 
April 2007 
OSGi 
Alliance 
Digitally 
signed by 
OSGi Alliance 
DN: cn=OSGi 
Alliance, 
c=US 
Date: 
2007.02.22 
14:45:47 + 
01'00' 
Signatur 
e Not 
Verified
OSGi Framework Layering 
luminis 
SERVICE MODEL 
LIFECYCLE 
MODULE 
Execution 
Environment 
L3 - Provides a publish/find/bind service 
model to decouple bundles 
L2 - Manages the life cycle of a bundle in 
a framework without requiring the vm to be 
restarted 
L1 - Creates the concept of a module 
(aka. bundles) that use classes from each 
other in a controlled way according to 
system and bundle constraints 
L0 - 
OSGi Minimum Execution Environment 
CDC/Foundation 
JavaSE
Bundle 
luminis 
Module Layer (1/3) 
• Unit of deployment 
is the bundle i.e., a JAR 
• Separate class loader 
per bundle 
• Class loader graph 
• Independent namespaces 
• Class sharing at the Java package level 
Module 
Module 
Bundle Bundle Bundle 
org.apache.utils 1.0 
exports 
org.apache.db 1.4 
org.apache.log 2.3 org.apache.utils 1.1 
exports 
imports 
exports 
imports 
exports
luminis 
Module Layer (2/3) 
• Multi-version support 
• i.e., side-by-side versions 
• Explicit code boundaries and dependencies 
• i.e., package imports and exports 
• Support for various sharing policies 
• i.e., arbitrary version range support 
• Arbitrary export/import attributes 
• Influence package selection Module
luminis 
Module Layer (3/3) 
• Sophisticated class space consistency model 
• Ensures code constraints are not violated 
• Package filtering for fine-grained class visibility 
• Exporters may include/exclude specific classes from 
exported package 
• Bundle fragments 
• A single logical module in multiple physical bundles 
• Bundle dependencies 
• Allows for tight coupling when required Module
Life-cycle 
resolved active 
luminis 
Life-cycle Layer 
• Managed life cycle 
• States for each bundle; 
• Allows updates of existing bundles. 
• Dynamically install, start, update, and uninstall 
Life-cycle 
start 
end 
installed 
install 
start starting 
stopping stop 
uninstall 
uninstalled 
Module
luminis 
Service Layer 
• OSGi framework 
promotes service 
oriented interaction 
pattern among 
bundles 
Service 
Service 
Log Database 
publish use 
use 
publish 
Bundle Bundle Bundle 
Bundle 
Prefs 
publish 
use 
publish find 
Service 
Provider 
Service 
Requester 
Service 
Registry 
interact 
Life-cycle 
Module
Service 
Life-cycle 
luminis 
Security 
• Optional Security Layer based on 
Java permissions 
• Infrastructure to define, deploy, and 
manage fine-grained application 
permissions 
• Code authenticated by location or 
signer 
• Well defined API to manage 
permissions 
• PermissionAdmin 
• ConditionalPermissionAdmin 
Security 
Module
luminis 
Shameless plug: 
if you want to know more about security in 
OSGi, come to our talk about 
Building Secure OSGi Applications
Leveraging standard services 
• Specification: 
• OSGi compendium – catalog of standard service 
luminis 
descriptions 
• Implementations: 
• OBR repository at bundles.osgi.org – over 1400 
bundles, implement compendium and other services 
• Maven repository and third party OBR’s 
• More and more projects are made OSGi compatible, for 
example: 
• Apache Commons OSGi
User Admin Wire Admin 
luminis 
OSGi compendium 
Log 
XML Parser 
Position 
Measurement and State 
Event Admin Service Tracker 
HTTP 
Device Access 
Configuration Admin 
Preferences 
Metatype 
IO Connector 
Initial Provisioning 
UPnP™ Device 
Execution Environment Spec 
Declarative Services 
OSGi Service Platform 
Service Compendium 
The OSGi Alliance 
Release 4, Version 4.1 
April 2007 
OSGi 
Alliance 
Digitally 
signed by 
OSGi Alliance 
DN: cn=OSGi 
Alliance, c=US 
Date: 
2007.02.22 
14:44:10 + 
01'00' 
Signatu 
re Not 
Verified
luminis 
Agenda 
• Android 
• Introduction and architecture 
• Hello world demo 
• OSGi 
• Introduction 
• Framework and compendium 
• Apache Felix on Google Android 
• Getting it to run 
• Creating a dynamic application: paint program
luminis 
Why OSGi and Android? 
Models are different 
Java VM 
App 
OSGi 
Dalvik VM 
App 
App App 
Dalvik VM 
App 
Dalvik VM 
App 
Android
luminis 
Benefits of each model 
Java VM 
invoke 
App App 
Java VM 
App App 
lib lib lib 
Dalvik VM 
App 
OSGi Android 
Dalvik VM 
App 
Dalvik VM 
App 
crash
Services in Android 
• Must be declared in AndroidManifest.xml 
• Can be started and stopped: 
Context.startService and Context.stopService() 
• You can bind to a service if you want to talk to it 
• Services can run in remote processes, in which 
case there is an Android IDL compiler to generate 
stubs 
• handles primitives, some collections and Parcelable’s 
luminis 
by value 
• handles other AIDL interfaces by reference
luminis 
Getting Felix to run... 
• First step, getting the framework to run 
• Apache Felix is very portable, so we just dex’ed it 
• found a couple of issues, fixed in release 1.0.3 
• Second step, dynamically loading bundles 
• the hard part was finding a way to load classes 
• found undocumented internal class 
• Google, we need an official API for this! 
• For more details: 
http://blog.luminis.nl/roller/luminis/entry/osgi_on_google_android_using
...others soon followed 
• At EclipseCon 2008, Santa Clara: 
• Neil Bartlett and BJ Hargrave, ported both Equinox and 
luminis 
Concierge to Android 
• Slides at: 
https://eclipsecon.greenmeetingsystems.com/attachments/download/390 
• ProSyst announced: 
• A port of their mBedded Server: 
http://www.adon-line.de/kunden/prosystBlog/?p=24 
• Knopflerfish 
• We talked to Eric Wistrand and Christer Larsson of 
MakeWave but they have no plans yet
luminis 
A dynamic application 
• Apache Felix framework 
• embeds an activity to hook into; 
• embeds file install bundle for easy deployment. 
• Host bundle that provides a canvas and a toolbar 
• Shape bundles that add new shapes 
• Based on example from Apache Felix website: 
http://felix.apache.org/site/apache-felix-application-demonstration.html
host bundle 
ShapeComponent 
getShape() : SimpleShape 
getX() : int 
getY() : int 
DefaultShape 
create(Context c) : View 
Activator 
shape bundle 
shape bundle 
luminis 
Architecture 
shape bundle 
apache felix application 
...osgi... 
...android... 
Activity 
... 
...android.felix 
ApacheFelix 
onCreate(Bundle b) 
onDestroy() 
onStart() 
onStop() 
...android.felix.view 
ViewFactory 
create(Context c) : View 
...android.servicebased.host 
... 
...android.servicebased.host.service 
SimpleShape 
draw(Canvas c, int x, int y) 
BundleActivator 
start(BundleContext c) 
stop(BundleContext c) 
ServiceTrackerCustomizer 
addingService(ServiceReference r) : o 
modifiedService(ServiceReference r, Object o) 
removedService(ServiceReference r, Object o) 
...android.servicebased.circle 
Activator 
...
luminis 
Live demo! 
• Deploying Felix to the Phone Emulator 
• Installing the first bundle, the host application 
• Adding and removing plugins: square, circle and 
triangle
luminis 
Links 
• Slides, docs and code: 
http://opensource.luminis.net/ 
• Android SDK: 
http://code.google.com/android/ 
• Open Handset Alliance: 
http://www.openhandsetalliance.com/ 
• Apache Felix and OSGi: 
http://felix.apache.org/ 
http://www.osgi.org/ 
• Karl Pauls: karl.pauls@luminis.nl 
Marcel Offermans: marcel.offermans@luminis.nl
luminis 
Questions?! 
? & !

More Related Content

PPTX
OSGi on Android - Value Proposition
KEY
Beyond OSGi Software Architecture
PDF
2013.devcon3 liferay and google authenticator integration rafik_harabi
PDF
MOE: Cross Platform Mobile Apps in Java
PPTX
Java modularization
PPT
ProSyst OSGi SDK
PDF
JavaCro'15 - Oracle Java Cloud Service Java PaaS - Duško Vukmanović
PDF
Zure Azure PaaS Zero to Hero - DevOps training day
OSGi on Android - Value Proposition
Beyond OSGi Software Architecture
2013.devcon3 liferay and google authenticator integration rafik_harabi
MOE: Cross Platform Mobile Apps in Java
Java modularization
ProSyst OSGi SDK
JavaCro'15 - Oracle Java Cloud Service Java PaaS - Duško Vukmanović
Zure Azure PaaS Zero to Hero - DevOps training day

What's hot (20)

PPTX
Show and Tell: Building Applications on Cisco Open SDN Controller
KEY
Modularization in java 8
PDF
Microservice Approach for Web Development with Micro Frontends
PDF
OpenAPI Spec at Google (Open API Initiative Meetup on 2016-09-15)
PPTX
Migrating From Applets to Java Desktop Apps in JavaFX
PPTX
Nyc mule soft_meetup_13_march_2021
PPT
Pro Syst Enterprise OSGi
PPTX
The Swagger Format becomes the Open API Specification: Standardizing descript...
PPTX
Introduction to Module Development with Appcelerator Titanium
PPTX
Enterprise 2.0 with Open Source Frameworks like Agorava
PPTX
MuleSoft Meetup slides_kualalumpur_19thSept_Undisturbed REST: Achieving Undis...
PPTX
Java EE Arquillian Testing with Docker & The Cloud
PDF
Kasten securing access to your kubernetes applications
PDF
Java Webinar #12: "Java Versions and Features: Since JDK 8 to 16"
PPT
RAP vs GWT Which AJAX Technology is for you?
PDF
The Big Easy: Native Mobile App Development with Appcelerator Titanium and Ja...
PDF
OpenAPI 3.0, And What It Means for the Future of Swagger
PDF
Why your APIs should fly first class
PDF
SFD 2014: Multiplatform App Development with Migeran
PPTX
Micro Front Ends for Micro Services using Oracle JET
Show and Tell: Building Applications on Cisco Open SDN Controller
Modularization in java 8
Microservice Approach for Web Development with Micro Frontends
OpenAPI Spec at Google (Open API Initiative Meetup on 2016-09-15)
Migrating From Applets to Java Desktop Apps in JavaFX
Nyc mule soft_meetup_13_march_2021
Pro Syst Enterprise OSGi
The Swagger Format becomes the Open API Specification: Standardizing descript...
Introduction to Module Development with Appcelerator Titanium
Enterprise 2.0 with Open Source Frameworks like Agorava
MuleSoft Meetup slides_kualalumpur_19thSept_Undisturbed REST: Achieving Undis...
Java EE Arquillian Testing with Docker & The Cloud
Kasten securing access to your kubernetes applications
Java Webinar #12: "Java Versions and Features: Since JDK 8 to 16"
RAP vs GWT Which AJAX Technology is for you?
The Big Easy: Native Mobile App Development with Appcelerator Titanium and Ja...
OpenAPI 3.0, And What It Means for the Future of Swagger
Why your APIs should fly first class
SFD 2014: Multiplatform App Development with Migeran
Micro Front Ends for Micro Services using Oracle JET
Ad

Similar to OSGi on Google Android using Apache Felix (20)

PDF
De leukste Bug
PDF
Embedded Android in Real Life - Live Embedded Event 2021
PDF
Building a server platform with os gi
PPT
Introduction to android sessions new
PPTX
DockerCon 15 Keynote - Day 2
PDF
Introduction to Android Development and Security
PDF
DevOpsDays Houston 2019 - Shaun Ladewig, Robert Stone - From OverTheWallOps t...
PDF
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...
PDF
Apereo OAE - Bootcamp
PDF
Building a Modular Server Platform with OSGi
PDF
Building a Modular Server Platform with OSGi - Harshana Eranga Martin, Dileep...
PDF
Android dev o_auth
PDF
OSGi introduction
PDF
OSGi and Java EE: A Hybrid Approach to Enterprise Java Application Development
KEY
A Platform Approach to Enterprise Content Management with Eclipse Apricot, CM...
PDF
OW2 JOnAS 5.0 Java EE AS- An OSGi Based Integration Platform - François Forna...
PDF
Eclipse plug in development
PPT
Android OS
PDF
OSGi Technology, Eclipse and Convergence - Jeff McAffer, IBM
PPT
Chapter 1 Introduction to android.ppt pl
De leukste Bug
Embedded Android in Real Life - Live Embedded Event 2021
Building a server platform with os gi
Introduction to android sessions new
DockerCon 15 Keynote - Day 2
Introduction to Android Development and Security
DevOpsDays Houston 2019 - Shaun Ladewig, Robert Stone - From OverTheWallOps t...
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...
Apereo OAE - Bootcamp
Building a Modular Server Platform with OSGi
Building a Modular Server Platform with OSGi - Harshana Eranga Martin, Dileep...
Android dev o_auth
OSGi introduction
OSGi and Java EE: A Hybrid Approach to Enterprise Java Application Development
A Platform Approach to Enterprise Content Management with Eclipse Apricot, CM...
OW2 JOnAS 5.0 Java EE AS- An OSGi Based Integration Platform - François Forna...
Eclipse plug in development
Android OS
OSGi Technology, Eclipse and Convergence - Jeff McAffer, IBM
Chapter 1 Introduction to android.ppt pl
Ad

More from Marcel Offermans (6)

PDF
Building Secure OSGi Applications
PDF
Component-based ontwikkelen met OSGi: van embedded tot enterprise
PDF
Dependencies, dependencies, dependencies
PDF
Modular Architectures using Micro Services
PDF
Felix HTTP - Paving the road to the future
PDF
Dynamic Deployment With Apache Felix
Building Secure OSGi Applications
Component-based ontwikkelen met OSGi: van embedded tot enterprise
Dependencies, dependencies, dependencies
Modular Architectures using Micro Services
Felix HTTP - Paving the road to the future
Dynamic Deployment With Apache Felix

Recently uploaded (20)

PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PPTX
GSA Content Generator Crack (2025 Latest)
PDF
Salesforce Agentforce AI Implementation.pdf
PDF
STL Containers in C++ : Sequence Container : Vector
DOCX
How to Use SharePoint as an ISO-Compliant Document Management System
PDF
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
PDF
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
PDF
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
PDF
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
PPTX
chapter 5 systemdesign2008.pptx for cimputer science students
PDF
How Tridens DevSecOps Ensures Compliance, Security, and Agility
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Wondershare Recoverit Full Crack New Version (Latest 2025)
PDF
Topaz Photo AI Crack New Download (Latest 2025)
PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
Complete Guide to Website Development in Malaysia for SMEs
PDF
Designing Intelligence for the Shop Floor.pdf
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
wealthsignaloriginal-com-DS-text-... (1).pdf
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
GSA Content Generator Crack (2025 Latest)
Salesforce Agentforce AI Implementation.pdf
STL Containers in C++ : Sequence Container : Vector
How to Use SharePoint as an ISO-Compliant Document Management System
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
chapter 5 systemdesign2008.pptx for cimputer science students
How Tridens DevSecOps Ensures Compliance, Security, and Agility
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Wondershare Recoverit Full Crack New Version (Latest 2025)
Topaz Photo AI Crack New Download (Latest 2025)
Digital Systems & Binary Numbers (comprehensive )
Complete Guide to Website Development in Malaysia for SMEs
Designing Intelligence for the Shop Floor.pdf
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx

OSGi on Google Android using Apache Felix

  • 1. OSGi on Google Android using Apache Felix Marcel Offermans Karl Pauls luminis
  • 2. luminis Who are we? • Karl Pauls • Marcel Offermans Arnhem Enschede image © 2008 Google Earth
  • 3. luminis Agenda • Android • Introduction and architecture • Hello world demo • OSGi • Introduction • Framework and compendium • Apache Felix on Google Android • Getting it to run • Creating a dynamic application: paint program
  • 4. luminis Agenda • Android • Introduction and architecture • Hello world demo • OSGi • Introduction • Framework and compendium • Apache Felix on Google Android • Getting it to run • Creating a dynamic application: paint program
  • 5. luminis Android • First SDK release: november 2007 • Android Developer Challenge, $10M prize money • Current SDK (M5 RC15): march 2008 • Phones: second half of 2008?
  • 6. luminis Android • Device Architecture • Dalvik Virtual Machine • From source to deployment • Anatomy of an application • Application life cycles
  • 7. Architecture This image is rather low-res, so perhaps draw it again... luminis
  • 8. luminis Dalvik Virtual Machine • interpreter-only, register based virtual machine • optimized to run multiple VM instances • executes files in .dex format • runs on posix-compliant operating systems • looks like Java ;)
  • 9. From source to deployment .java .class .jar .dex .apk • Eclipse Plugin: Android Development Tools • compiles and packages automatically • allows you to launch and debug in the emulator • Command line: activityCreator.py • generates project structure • Ant build.xml file, optionally IntelliJ project files luminis javac jar dx aapt
  • 10. luminis Anatomy • activity, a single screen • intent, describes what the application wants done • intent filter, describes intents that can be handled • intent receiver, non UI code that reacts to intent • service, background process with API • content provider, for shared data access
  • 11. luminis Anatomy Example intent filter activity intent activity intent service intent filter intent receiver
  • 12. luminis Life cycle • Application life cycle is not controlled by the application itself • Android maintains an “importancy hierarchy” based on the components and their state: • foreground process • visible process • service process • background process • empty process
  • 13. luminis Life cycle (Activity)
  • 14. luminis Hello world demo! • Create an application with an activity in Eclipse • Set “hello world” text • Create a breakpoint • Deploy and debug the application
  • 15. luminis Agenda • Android • Introduction and architecture • Hello world demo • OSGi • Introduction • Framework and compendium • Apache Felix on Google Android • Getting it to run • Creating a dynamic application: paint program
  • 16. luminis OSGi history • Started as an embedded platform for the “home gateway” • Originally under the JCP as JSR-8 (1999) • OSGi alliance, consists of a large number of big companies, with the following mission: • Maintaining and publicizing the OSGi specification. • Certifying implementations. • Organising events. • Current version: OSGi Release 4.1 (JSR-291)
  • 17. luminis OSGi today OSGi technology is the dynamic module system for Java™ OSGi technology is Universal Middleware. OSGi technology provides a service-oriented, component-based environment for developers and offers standardized ways to manage the software lifecycle. These capabilities greatly increase the value of a wide range of computers and devices that use the Java™ platform.
  • 18. luminis OSGi Alliance • Expert Groups: • core platform (CPEG) • mobile (MEG) • vehicle (VEG) • enterprise (EEG) • residential (REG) • Working Groups: • marketing • requirements
  • 19. luminis OSGi specification OSGi Service Platform Service Compendium The OSGi Alliance Release 4, Version 4.1 April 2007 OSGi Alliance Digitally signed by OSGi Alliance DN: cn=OSGi Alliance, c=US Date: 2007.02.22 14:44:10 + 01'00' Signatu re Not Verified OSGi Service Platform Core Specification The OSGi Alliance Release 4, Version 4.1 April 2007 OSGi Alliance Digitally signed by OSGi Alliance DN: cn=OSGi Alliance, c=US Date: 2007.02.22 14:45:47 + 01'00' Signatur e Not Verified
  • 20. OSGi Framework Layering luminis SERVICE MODEL LIFECYCLE MODULE Execution Environment L3 - Provides a publish/find/bind service model to decouple bundles L2 - Manages the life cycle of a bundle in a framework without requiring the vm to be restarted L1 - Creates the concept of a module (aka. bundles) that use classes from each other in a controlled way according to system and bundle constraints L0 - OSGi Minimum Execution Environment CDC/Foundation JavaSE
  • 21. Bundle luminis Module Layer (1/3) • Unit of deployment is the bundle i.e., a JAR • Separate class loader per bundle • Class loader graph • Independent namespaces • Class sharing at the Java package level Module Module Bundle Bundle Bundle org.apache.utils 1.0 exports org.apache.db 1.4 org.apache.log 2.3 org.apache.utils 1.1 exports imports exports imports exports
  • 22. luminis Module Layer (2/3) • Multi-version support • i.e., side-by-side versions • Explicit code boundaries and dependencies • i.e., package imports and exports • Support for various sharing policies • i.e., arbitrary version range support • Arbitrary export/import attributes • Influence package selection Module
  • 23. luminis Module Layer (3/3) • Sophisticated class space consistency model • Ensures code constraints are not violated • Package filtering for fine-grained class visibility • Exporters may include/exclude specific classes from exported package • Bundle fragments • A single logical module in multiple physical bundles • Bundle dependencies • Allows for tight coupling when required Module
  • 24. Life-cycle resolved active luminis Life-cycle Layer • Managed life cycle • States for each bundle; • Allows updates of existing bundles. • Dynamically install, start, update, and uninstall Life-cycle start end installed install start starting stopping stop uninstall uninstalled Module
  • 25. luminis Service Layer • OSGi framework promotes service oriented interaction pattern among bundles Service Service Log Database publish use use publish Bundle Bundle Bundle Bundle Prefs publish use publish find Service Provider Service Requester Service Registry interact Life-cycle Module
  • 26. Service Life-cycle luminis Security • Optional Security Layer based on Java permissions • Infrastructure to define, deploy, and manage fine-grained application permissions • Code authenticated by location or signer • Well defined API to manage permissions • PermissionAdmin • ConditionalPermissionAdmin Security Module
  • 27. luminis Shameless plug: if you want to know more about security in OSGi, come to our talk about Building Secure OSGi Applications
  • 28. Leveraging standard services • Specification: • OSGi compendium – catalog of standard service luminis descriptions • Implementations: • OBR repository at bundles.osgi.org – over 1400 bundles, implement compendium and other services • Maven repository and third party OBR’s • More and more projects are made OSGi compatible, for example: • Apache Commons OSGi
  • 29. User Admin Wire Admin luminis OSGi compendium Log XML Parser Position Measurement and State Event Admin Service Tracker HTTP Device Access Configuration Admin Preferences Metatype IO Connector Initial Provisioning UPnP™ Device Execution Environment Spec Declarative Services OSGi Service Platform Service Compendium The OSGi Alliance Release 4, Version 4.1 April 2007 OSGi Alliance Digitally signed by OSGi Alliance DN: cn=OSGi Alliance, c=US Date: 2007.02.22 14:44:10 + 01'00' Signatu re Not Verified
  • 30. luminis Agenda • Android • Introduction and architecture • Hello world demo • OSGi • Introduction • Framework and compendium • Apache Felix on Google Android • Getting it to run • Creating a dynamic application: paint program
  • 31. luminis Why OSGi and Android? Models are different Java VM App OSGi Dalvik VM App App App Dalvik VM App Dalvik VM App Android
  • 32. luminis Benefits of each model Java VM invoke App App Java VM App App lib lib lib Dalvik VM App OSGi Android Dalvik VM App Dalvik VM App crash
  • 33. Services in Android • Must be declared in AndroidManifest.xml • Can be started and stopped: Context.startService and Context.stopService() • You can bind to a service if you want to talk to it • Services can run in remote processes, in which case there is an Android IDL compiler to generate stubs • handles primitives, some collections and Parcelable’s luminis by value • handles other AIDL interfaces by reference
  • 34. luminis Getting Felix to run... • First step, getting the framework to run • Apache Felix is very portable, so we just dex’ed it • found a couple of issues, fixed in release 1.0.3 • Second step, dynamically loading bundles • the hard part was finding a way to load classes • found undocumented internal class • Google, we need an official API for this! • For more details: http://blog.luminis.nl/roller/luminis/entry/osgi_on_google_android_using
  • 35. ...others soon followed • At EclipseCon 2008, Santa Clara: • Neil Bartlett and BJ Hargrave, ported both Equinox and luminis Concierge to Android • Slides at: https://eclipsecon.greenmeetingsystems.com/attachments/download/390 • ProSyst announced: • A port of their mBedded Server: http://www.adon-line.de/kunden/prosystBlog/?p=24 • Knopflerfish • We talked to Eric Wistrand and Christer Larsson of MakeWave but they have no plans yet
  • 36. luminis A dynamic application • Apache Felix framework • embeds an activity to hook into; • embeds file install bundle for easy deployment. • Host bundle that provides a canvas and a toolbar • Shape bundles that add new shapes • Based on example from Apache Felix website: http://felix.apache.org/site/apache-felix-application-demonstration.html
  • 37. host bundle ShapeComponent getShape() : SimpleShape getX() : int getY() : int DefaultShape create(Context c) : View Activator shape bundle shape bundle luminis Architecture shape bundle apache felix application ...osgi... ...android... Activity ... ...android.felix ApacheFelix onCreate(Bundle b) onDestroy() onStart() onStop() ...android.felix.view ViewFactory create(Context c) : View ...android.servicebased.host ... ...android.servicebased.host.service SimpleShape draw(Canvas c, int x, int y) BundleActivator start(BundleContext c) stop(BundleContext c) ServiceTrackerCustomizer addingService(ServiceReference r) : o modifiedService(ServiceReference r, Object o) removedService(ServiceReference r, Object o) ...android.servicebased.circle Activator ...
  • 38. luminis Live demo! • Deploying Felix to the Phone Emulator • Installing the first bundle, the host application • Adding and removing plugins: square, circle and triangle
  • 39. luminis Links • Slides, docs and code: http://opensource.luminis.net/ • Android SDK: http://code.google.com/android/ • Open Handset Alliance: http://www.openhandsetalliance.com/ • Apache Felix and OSGi: http://felix.apache.org/ http://www.osgi.org/ • Karl Pauls: karl.pauls@luminis.nl Marcel Offermans: marcel.offermans@luminis.nl