µservices for the rest of us - karl pauls

44
COPYRIGHT © 2008-2011 OSGi Alliance. All Rights Reserved μServices For the Rest of Us Karl Pauls Luminis 21.09.2011, 12:40-13:30 OSGi Alliance Marketing © 2008-2010 . All Rights Reserved Page 1

Upload: mfrancis

Post on 20-May-2015

2.999 views

Category:

Business


2 download

DESCRIPTION

Many people are drawn into OSGi because it provides class loaders on steroids, however, one of the often overlooked feature of OSGi is the Service Registry and the (µ)service model. µServices provide a much more powerful alternative to the traditional Java factories and listeners in your code or xml, which are the usual culprits for class loading headaches. Alas, you need to migrate your application to OSGi first in order to take advantage of µServices which would make it so much easier to migrate your application to OSGi in the first place. The idea of PojoSR (a.k.a OSGi Lite) is to remedy this situation by providing OSGi without the module layer. PojoSR is based on Apache Felix and runs in any standard Java environment: from the class path, inside a WAR, wherever your current Java runs because it never touches a class loader. It allows any application built in Java to reap the benefits of service-based modularity without first having to rid existing code of any class loader tricks. This approach also allows, many existing bundles work out of the box - just by adding them to the class path (PojoSR will detect bundles on the class path and execute their activators). It works so well that OSGi is thinking of standardizing this approach. This talk will show you how you can take advantage of µServices using PojoSR and present some examples where µServices and PojoSR wore used to modularize and OSGi'fy an existing application.

TRANSCRIPT

Page 1: µServices for the rest of us - karl pauls

COPYRIGHT © 2008-2011 OSGi Alliance. All Rights Reserved

µServices For the Rest of Us

Karl Pauls

Luminis

21.09.2011, 12:40-13:30

OSGi Alliance Marketing © 2008-2010 .

All Rights Reserved

Page 1

Page 2: µServices for the rest of us - karl pauls

OSGi Alliance Community Event 2011© 2008-2011. All Rights Reserved Page 2

Karl

• Member Apache Software Foundation • PMC: Felix, Sling, Incubator

• PPMC: Ace, Clerezza, Celix

• Fellow at Luminis

• Project Owner PojoSR

• Co-Author of “OSGi in Action”

[email protected]

[email protected]

Page 3: µServices for the rest of us - karl pauls

Luminis

http://luminis.eu

http://luminis-technologies.com

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 3

Page 4: µServices for the rest of us - karl pauls

HISTORY

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 4

Page 5: µServices for the rest of us - karl pauls

Agenda

• OSGi bootcamp

• OSGi µServices

• µServices For the Rest of Us

• Use Cases

• Implementation / Demo

• Closing Remarks

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 5

Page 6: µServices for the rest of us - karl pauls

BOOTCAMP

OSGi

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 6

Page 7: µServices for the rest of us - karl pauls

OSGi bootcamp

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 7

Page 8: µServices for the rest of us - karl pauls

Define Modules ...

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 8

Page 9: µServices for the rest of us - karl pauls

... Compose Modules ...

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 9

Page 10: µServices for the rest of us - karl pauls

... with OSGi

• L3 – Provides publish/find/bind

service model to decouple

bundles

• L2 – Manages the life cycle of

bundle in a bundle cache

without requiring restarts

• L1 – Creates the concept of

bundles that use classes from

each other in a controlled way

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 10

service

life cycle

module

Page 11: µServices for the rest of us - karl pauls

µSERVICES

OSGi

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 11

Page 12: µServices for the rest of us - karl pauls

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 12

Page 13: µServices for the rest of us - karl pauls

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 13

Page 14: µServices for the rest of us - karl pauls

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 14

Page 15: µServices for the rest of us - karl pauls

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 15

Page 16: µServices for the rest of us - karl pauls

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 16

Page 17: µServices for the rest of us - karl pauls

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 17

Page 18: µServices for the rest of us - karl pauls

WHITEBOARD

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 19

Page 19: µServices for the rest of us - karl pauls

EXTENDER

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 20

Page 20: µServices for the rest of us - karl pauls

SERVICE COMPONENTS

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 21

Page 21: µServices for the rest of us - karl pauls

µSERVICES FOR THE REST OF US

OSGi

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 22

Page 22: µServices for the rest of us - karl pauls

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 23

Page 23: µServices for the rest of us - karl pauls

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 24

Page 24: µServices for the rest of us - karl pauls

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 25

Page 25: µServices for the rest of us - karl pauls

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 26

Page 26: µServices for the rest of us - karl pauls

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 27

Page 27: µServices for the rest of us - karl pauls

OR CAN YOU?

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 28

Page 28: µServices for the rest of us - karl pauls

PojoSR (a.k.a OSGi Lite a.k.a lite a.k.a ???)

• OSGi µServices For the Rest of Us • OSGi without the module layer

• Based on Apache Felix

• Runs in standard Java environment

• Doesn‘t create class loaders

• Apache License 2

• Exposes Service Registry to normal Java • No need for bundles

• But bundles are supported up to a point

• Missing module layer

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 29

Page 29: µServices for the rest of us - karl pauls

USE CASES

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 30

Page 30: µServices for the rest of us - karl pauls

Common discovery (SPI)

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 31

Page 31: µServices for the rest of us - karl pauls

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 32

Page 32: µServices for the rest of us - karl pauls

Migration

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 33

Page 33: µServices for the rest of us - karl pauls

Migration with and without PojoSR

• Start using Service first! • Split into bundles later and work on trunk!

• Without PojoSR • Turn application into one big bundle

• Split into several bundles

• Fix problems

• Split even more bundles (goto split)

• Eventually, start using services

• Allows to remove ugly hacks and crazy meta-data needed

to fix problems

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 34

Page 34: µServices for the rest of us - karl pauls

Use OSGi where you can‘t OSGi (lite) on Google App Engine using PojoSR

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 35

Page 35: µServices for the rest of us - karl pauls

USAGE

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 36

Page 36: µServices for the rest of us - karl pauls

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 37

Page 37: µServices for the rest of us - karl pauls

As an OSGi „light“ framework

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 38

Page 38: µServices for the rest of us - karl pauls

Standalone

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 39

Page 39: µServices for the rest of us - karl pauls

IMPLEMENTATION

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 40

Page 40: µServices for the rest of us - karl pauls

• Classloader.getResources(META-

INF/MANIFEST.MF) • Find bundle on the classpath

• Provide Bundle Revision based on jar:

and file: url schemas (extendable)

• Use and expose Apache Felix service

registry for the rest

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 41

Page 41: µServices for the rest of us - karl pauls

DEMO

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 42

Page 42: µServices for the rest of us - karl pauls

CLOSING REMARKS

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 43

Page 43: µServices for the rest of us - karl pauls

Benefits and Drawbacks

• PojoSR provides part of the power of OSGi • In a non-intrusive way.

• Allows to increase modularity

• without first ridding an existing code base of class loader hacks

• Drawbacks are • Does not enforce module boundaries

• Does not allow multiple versions of the same package

• and other module layer features (so some are supported)

• Not support the Bundle-Classpath

• But you can use µServices to get rid of class loading hacks over time,

after which it will be easier to move to OSGi and get side by side

versioning and real module boundaries.

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 44

Page 44: µServices for the rest of us - karl pauls

QUESTIONS

http://pojosr.googlecode.com

OSGi Alliance Marketing © 2008-2011 . All Rights Reserved Page 45