osgi workshop - become a certified bundle manager

95
Become a Cer*fied Bundle Manager today Karl Pauls & Marcel Offermans !"#$%&'&()"*

Upload: skills-matter

Post on 03-Jul-2015

583 views

Category:

Technology


1 download

DESCRIPTION

OSGi is great at enabling you to build your systems out of sets of bundles. In a way, your bundles are your configuration. However, this also requires you to master the identification, assembly and provisioning of all of the components that make-up your system. * How do you hot-deploy bundles for delivery? * Is there a simple way of bootstrapping your system with specific configurations that are easy to assemble and kick-start? * Once your system is "out there" how can you take things one-step further and manage the provisioning remotely? * Is there an easy way to let the user discover and deploy what he wants, when he wants it? * How can you do all of these things using existing technologies? Well, you've come to the right place. In this workshop we will focus on ways to manage OSGi installations. Using a simple example application, we will show you how you can: * use Fileinstall to hot-deploy bundles into your live application environment * take advantage of Pax Runner to create and easily bootstrap configurations of bundles * remotely manage, provision, and audit systems in the field with Apache Ace * provide, discover, and deploy bundles using Apache Felix OBR

TRANSCRIPT

Page 1: OSGI workshop - Become A Certified Bundle Manager

Become  a  Cer*fied  Bundle  Manager  

today

Karl  Pauls  &  Marcel  Offermans

!"#$%&'&()"*

Page 2: OSGI workshop - Become A Certified Bundle Manager

Karl  @  Akquinet

• Member  Apache  So8ware  Founda<on

• PMC  Felix,  Sling,  Incubator

• PPMC  Ace,  Clerezza

• So8ware  Architect  at  akquinet

• Co-­‐Author  „OSGi  in  Ac<on“

[email protected]

Page 3: OSGI workshop - Become A Certified Bundle Manager

Marcel  @  luminis

• Member  Apache  So8ware  Founda<on

• CommiMer  and  PMC  member  at  Apache  Felix  and  Apache  ACE

• So8ware  architect  at  Luminis  Technologies

• Luminis:  group  of  companies,  strong  focus  on  technical  excellence,  offices  in  The  Netherlands  and  the  United  Kingdom

[email protected]

Page 4: OSGI workshop - Become A Certified Bundle Manager

Requirements  for  exercises

• Computer  with  Java  6  pre-­‐installed

• Memory  s<ck  with  the  exercises

Page 5: OSGI workshop - Become A Certified Bundle Manager

Agenda

• Quick  OSGi  recap

• Bundle  management

• Pax  Runner

• File  Install

• OBR

• Apache  ACE

Page 6: OSGI workshop - Become A Certified Bundle Manager

OSGi:  core  +  compendium

!"#$%"&'($)&%*+,-./'01/'&%"2&)$.$),-$/345&%!"#$%6++$,3)&

7&+&,8&%9:%;&'8$/3%9<=>?3&%=@@A

!"#$%"&'($)&%*+,-./'0"&'($)&%1/02&34$5067&%!"#$%8++$,3)&

9&+&,:&%;<%=&':$/3%;>?85@5:-%?AAB

Page 7: OSGI workshop - Become A Certified Bundle Manager

Core

!"#$%"&'($)&%*+,-./'01/'&%"2&)$.$),-$/345&%!"#$%6++$,3)&

7&+&,8&%9:%;&'8$/3%9<=>?3&%=@@A

Page 8: OSGI workshop - Become A Certified Bundle Manager

Framework

!"#$%&'&($

)*+*%,"-./*(%0*&1"2$

345"%#-*6$78-9

4$&/-".'

08:/($

!"#$%&'&($

4$-+"&$;/2:($ ;/2:($ ;/2:($

4$-+"&$

!8< 4.8-$

=/>("?1 /?$/?$

=/>("?1

?.*-.

$2:

"2?.*((

?.*-.

?.8=/2"2?.*((

08:/($;/2:($ ;/2:($ ;/2:($ ;/2:($

$@=8-.?

"6=8-.?

$@=8-.?

"6=8-.?

$@=8-.?

$@=8-.?

A-$#?

=/>("?1/?$

8-<B*=*&1$B/C(%DBE

8-<B*=*&1$B/C(%DBD8-<B*=*&1$B(8<%FBG

8-<B*=*&1$B:>%DBH

;/2:($ ;/2:($ ;/2:($ ;/2:($

"2?.*(($:

?.*-C2<

?.8=="2<

*&C+$-$?8(+$:

/2"2?.*(($:

Page 9: OSGI workshop - Become A Certified Bundle Manager

Framework

!"#$%&'&($

)*+*%,"-./*(%0*&1"2$

345"%#-*6$78-9

4$&/-".'

08:/($

!"#$%&'&($

4$-+"&$;/2:($ ;/2:($ ;/2:($

4$-+"&$

!8< 4.8-$

=/>("?1 /?$/?$

=/>("?1

?.*-.

$2:

"2?.*((

?.*-.

?.8=/2"2?.*((

08:/($;/2:($ ;/2:($ ;/2:($ ;/2:($

$@=8-.?

"6=8-.?

$@=8-.?

"6=8-.?

$@=8-.?

$@=8-.?

A-$#?

=/>("?1/?$

8-<B*=*&1$B/C(%DBE

8-<B*=*&1$B/C(%DBD8-<B*=*&1$B(8<%FBG

8-<B*=*&1$B:>%DBH

;/2:($ ;/2:($ ;/2:($ ;/2:($

"2?.*(($:

?.*-C2<

?.8=="2<

*&C+$-$?8(+$:

/2"2?.*(($:

Page 10: OSGI workshop - Become A Certified Bundle Manager

Framework

!"#$%&'&($

)*+*%,"-./*(%0*&1"2$

345"%#-*6$78-9

4$&/-".'

08:/($

!"#$%&'&($

4$-+"&$;/2:($ ;/2:($ ;/2:($

4$-+"&$

!8< 4.8-$

=/>("?1 /?$/?$

=/>("?1

?.*-.

$2:

"2?.*((

?.*-.

?.8=/2"2?.*((

08:/($;/2:($ ;/2:($ ;/2:($ ;/2:($

$@=8-.?

"6=8-.?

$@=8-.?

"6=8-.?

$@=8-.?

$@=8-.?

A-$#?

=/>("?1/?$

8-<B*=*&1$B/C(%DBE

8-<B*=*&1$B/C(%DBD8-<B*=*&1$B(8<%FBG

8-<B*=*&1$B:>%DBH

;/2:($ ;/2:($ ;/2:($ ;/2:($

"2?.*(($:

?.*-C2<

?.8=="2<

*&C+$-$?8(+$:

/2"2?.*(($:

Page 11: OSGI workshop - Become A Certified Bundle Manager

Framework

!"#$%&'&($

)*+*%,"-./*(%0*&1"2$

345"%#-*6$78-9

4$&/-".'

08:/($

!"#$%&'&($

4$-+"&$;/2:($ ;/2:($ ;/2:($

4$-+"&$

!8< 4.8-$

=/>("?1 /?$/?$

=/>("?1

?.*-.

$2:

"2?.*((

?.*-.

?.8=/2"2?.*((

08:/($;/2:($ ;/2:($ ;/2:($ ;/2:($

$@=8-.?

"6=8-.?

$@=8-.?

"6=8-.?

$@=8-.?

$@=8-.?

A-$#?

=/>("?1/?$

8-<B*=*&1$B/C(%DBE

8-<B*=*&1$B/C(%DBD8-<B*=*&1$B(8<%FBG

8-<B*=*&1$B:>%DBH

;/2:($ ;/2:($ ;/2:($ ;/2:($

"2?.*(($:

?.*-C2<

?.8=="2<

*&C+$-$?8(+$:

/2"2?.*(($:

Page 12: OSGI workshop - Become A Certified Bundle Manager

!"#$%"&'($)&%*+,-./'0"&'($)&%1/02&34$5067&%!"#$%8++$,3)&

9&+&,:&%;<%=&':$/3%;>?85@5:-%?AAB

Compendium

Page 13: OSGI workshop - Become A Certified Bundle Manager

OSGi  compendium

Log

HTTP

Device Access

Configuration Admin

Preferences

Metatype

Wire AdminUser Admin

IO Connector

Initial Provisioning

UPnP™ Device

Declarative Services

Event Admin Service Tracker

XML Parser

Position

Measurement and State

Execution Environment Spec

Remote Services

Deployment Admin

Blueprint Container

!"#$%"&'($)&%*+,-./'0"&'($)&%1/02&34$5067&%!"#$%8++$,3)&

9&+&,:&%;<%=&':$/3%;>?85@5:-%?AAB

Page 14: OSGI workshop - Become A Certified Bundle Manager

Define  Modules  ...

Page 15: OSGI workshop - Become A Certified Bundle Manager

...  Compose  Modules  ...

Page 16: OSGI workshop - Become A Certified Bundle Manager

...  with  OSGi

• L3  -­‐  Provides  a  publish/find/bind  service  model  to  decouple  bundles

• L2  -­‐  Manages  the  lifecycle  of  bundle  in  a  bundle  repository  without  requiring  the  VM  be  restarted

• L1  -­‐  Creates  the  concept  of  bundles  that  use  classes  from  each  other  in  a  controlled  way  according  to  constraints

!"#$%&"

'()*+"

+%,"-&.&+"

Page 17: OSGI workshop - Become A Certified Bundle Manager

Experience:  oHen,  it’s  not  OSGi

• Real  world  applica<ons  run  on

• an  opera<ng  system,  inside  a  virtual  machine

• and  have:

• databases

• non-­‐OSGi  clients

• other  (na<ve)  files  /  data

• For  the  BEST  experience,  make  everything  deployable

Page 18: OSGI workshop - Become A Certified Bundle Manager

Modularity

• What?

• Separa<on  of  concerns

• Structure

• Encapsula<on

• Focuses  on

• Cohesion  (low  is  bad,  high  is  good)

• Coupling  (low  is  good,  high  is  bad)

• Why?

• Independent  development

• Independent  maintenance

• Improve  reusability

Page 19: OSGI workshop - Become A Certified Bundle Manager

OSGi  Bundle

• A  bundle  is  a  module  in  OSGi  terminology

• A  bundle  is  a  JAR  file  containing

• Code

• Resources

• Metadata!"#$%&

!"#$%&'(

)*+"'')*+"'')*+"''

),!+-.)/0&1-.&(*)

),!+-.)/0&1-.&(*)

),!+-.)/0&1-.&(*)

Page 20: OSGI workshop - Become A Certified Bundle Manager

Bundle  Metadata

• Bundle  metadata  captures

• Human-­‐readable  informa<on

• Bundle  iden<fica<on

• Code  visibility

• Stored  in  the  JAR  manifest  as  proper<es

Page 21: OSGI workshop - Become A Certified Bundle Manager

Version  Format

• OSGi  uses  a  4-­‐part  version  numbering  scheme

• <major>.<minor>.<micro>.<qualifier>

• Major,  minor,  and  micro  are  numeric  values

• Qualifier  is  a  string  value

• Valid  examples

• 1,  1.10,  1.9.9.alpha,  0.2.0.SNAPSHOT

• Invalid  examples

• 0.2.SNAPSHOT,  1.9.9-­‐alpha

• Comparison  (not  always  intui<ve)

• 1.0.0  <  1.9.9  <  1.10

• 1.0.0.beta  >  1.0.0.alpha  >  1.0.0

Page 22: OSGI workshop - Become A Certified Bundle Manager

Version  Range  Format

• Interval  nota<on  is  used  for  version  ranges

• Use  '['  or  ']'  for  inclusive  values

• Use  '('  or  ')'  for  exclusive  values

• Example  (quotes  needed)

• "[1.0.0,2.0.0)"  ==  (1.0.0  <=  v  <  2.0.0)

• When  a  version  range  is  expected,  a  single  value  represents  an  infinite  range

• "1.0.0"  ==  (1.0.0  <=  v  <  ∞)

• To  specify  a  precise  version

• "[1.0.0,1.0.0]"

Page 23: OSGI workshop - Become A Certified Bundle Manager

Experience:  versioning

• Choose  a  versioning  policy  and  s<ck  with  it

• Version  all  packages  you  export

• Use  version  ranges  on  import  that  are  consistent  with  policy

• If  you  FORGET  this  you  will  REGRET  it

• Do  not  be  tempted  to  mis-­‐use  commercial  versions  internally

• Only  bump  versions  on  actual  changes

Page 24: OSGI workshop - Become A Certified Bundle Manager

Version  Policy

• Major  number  change  –  signifies  an  incompa<ble  update.  

• Minor  number  change  –  signifies  a  backward  compa<ble  update.  

• Micro  number  change  –  signifies  an  internal  update  (e.g.,  a  bug  fix  or  performance  improvement).  

• Qualifier  change  –  signifies  a  trivial  internal  change  with  “outward”  no<ceable  difference,  but  nonetheless  is  a  new  ar<fact  (e.g.,  line  number  refactoring).  

Page 25: OSGI workshop - Become A Certified Bundle Manager

Tip:  Seman*c  Versioning  whitepaper

Source:  h*p://www.osgi.org/wiki/uploads/Links/Seman9cVersioning.pdf

© 2010 OSGi Alliance

All Rights Reserved.

Semantic Versioning Technical Whitepaper

Revision 1.0May 6, 2010

Page 26: OSGI workshop - Become A Certified Bundle Manager

Exposing  Internal  Code

• Expor<ng  a  versioned  package

• Export-­‐Package:  javax.servlet;  version="2.4.0"

• Can  also  specify  arbitrary  matching  aMributes

• Export-­‐Package:  javax.servlet;  javax.servlet.hMp;  version="2.4.0";  "vendor=ASF"

!

Page 27: OSGI workshop - Become A Certified Bundle Manager

Downsides  and  Pi\alls

!!"#$%&'(")) *++,&(-./01

*++234$

!!"#$%&'(")) *++,&(-./015&(-./01

*++234$

!"#"

$%&'#%#()" !&*+)# $%&'#%#()"

!"#"

Page 28: OSGI workshop - Become A Certified Bundle Manager

Best  Prac*ce

!!"#$%&'(")) *++

*++,-.$

!"#"

$%&'#%#()"

*+,-./0,-1

*+,-./+,+1

Page 29: OSGI workshop - Become A Certified Bundle Manager

Impor*ng  &  Expor*ng  a  Package  (1/4)

• Imagine  bundle  A  somehow  gets  servlet  instances  from  bundle  B

!

"#$%&'(

)*+*,-./'+0/(

/,%&'()*+*,-./'+0/(

-10*..

&2/31&%43&5)*+*,-./'+0/(

Page 30: OSGI workshop - Become A Certified Bundle Manager

Impor*ng  &  Expor*ng  a  Package  (1/4)

• What  if  bundle  A  also  wanted  to  get  servlet  instances  somehow  from  bundle  C?

!

"#$%&'(

)*+*,-./'+0/(

/,%&'()*+*,-./'+0/(

-10*..

&2/31&%43&5)*+*,-./'+0/(

Page 31: OSGI workshop - Become A Certified Bundle Manager

Impor*ng  &  Expor*ng  a  Package  (2/4)

• Bundle  C  could  import  from  bundle  B,  but  then  it  is  dependent  on  it

!

"#$%&'(

)*+*,-./'+0/(

/,%&'()*+*,-./'+0/(

-10*..

&2/31&%43&5)*+*,-./'+0/(

6

#$%&'()*+*,-./'+0/(

Page 32: OSGI workshop - Become A Certified Bundle Manager

Impor*ng  &  Expor*ng  a  Package  (3/4)

• Bundle  C  could  export  its  own  servlet  package,  but  bundle  A  could  only  see  either  C  or  B

!

"

#$%&'()*+*,-./'+0/(

/,%&'()*+*,-./'+0/(

-10*..

(2&31&%#/.3&4)*+*,-./'+0/(

5

/,%&'()*+*,-./'+0/(

-10*..

666

Page 33: OSGI workshop - Become A Certified Bundle Manager

Impor*ng  &  Expor*ng  a  Package  (4/4)

• Bundle  C  could  both  import  and  export  servlet  to  solve  the  dilemma

!

"

#$%&'()*+*,-./'+0/(

/,%&'(1*231#$%&'()*+*,-./'+0/(

-40*..

5-40*..

/,%&'(1*231#$%&'()*+*,-./'+0/(

Page 34: OSGI workshop - Become A Certified Bundle Manager

Advanced  Consistency  Checking

• Some<mes  more  advanced  consistency  checking  is  necessary,  consider  this

Interfacepackage org.foo.http;import javax.servlet;public interface HttpService { void registerServlet(Sting alias, Servlet servlet);}

MetadataExport-Package: org.foo.http; version="1.0.0"Import-Package: javax.servlet; version="2.3.0"

Page 35: OSGI workshop - Become A Certified Bundle Manager

Advanced  Consistency  Checking

• Some<mes  more  advanced  consistency  checking  is  necessary,  consider  this

!""#$%&'()*&

+

),-.'/01(123%&'(4&/(&'%).5673839

&2-.'/01(123%&'(4&/(&'%).5673839

&2-.'/.':3;..3<=-

Page 36: OSGI workshop - Become A Certified Bundle Manager

Advanced  Consistency  Checking

• Some<mes  more  advanced  consistency  checking  is  necessary,  consider  this

!""#$%&'()*&

+

),-.'/01(123%&'(4&/(&'%).5673839

&2-.'/01(123%&'(4&/(&'%).5673839

&2-.'/.':3;..3<=-

!""#$*4)&5/

),-.'/.':3;..3<=-

),-.'/01(123%&'(4&/(&'%).5673>39

Page 37: OSGI workshop - Become A Certified Bundle Manager

Advanced  Consistency  Checking

• Some<mes  more  advanced  consistency  checking  is  necessary,  consider  this

!""#$%&'()*&

+

&,-.'/01(1,2%&'(3&/(&'%).4562728

&,-.'/.'92:..2;<-

!""#$*3)&4/

=

&,-.'/01(1,2%&'(3&/(&'%).4562>28

Page 38: OSGI workshop - Become A Certified Bundle Manager

Advanced  Consistency  Checking

• Some<mes  more  advanced  consistency  checking  is  necessary,  consider  this

This  would  result  in  aClassCastExcep<on,

why?

!""#$%&'()*&

+

&,-.'/01(1,2%&'(3&/(&'%).4562728

&,-.'/.'92:..2;<-

!""#$*3)&4/

=

&,-.'/01(1,2%&'(3&/(&'%).4562>28

Page 39: OSGI workshop - Become A Certified Bundle Manager

Advanced  Consistency  Checking

• Some<mes  more  advanced  consistency  checking  is  necessary,  consider  this

!""#$%&'()*&

+

&,-.'/01(1,2%&'(3&/(&'%).4562728

&,-.'/.'92:..2;<-

!""#$*3)&4/

=

&,-.'/01(1,2%&'(3&/(&'%).4562>28

Page 40: OSGI workshop - Become A Certified Bundle Manager

Advanced  Consistency  Checking

• Some<mes  more  advanced  consistency  checking  is  necessary,  consider  this

!""#$%&'()*&

+

&,-.'/01(1,2%&'(3&/(&'%).4562728

&,-.'/.'92:..2;<-

!""#$*3)&4/

=

&,-.'/01(1,2%&'(3&/(&'%).4562>28

?@%&%?

We  need  to  declare  suchinternal  dependencies!

MetadataExport-Package: org.foo.http; version="1.0.0";

uses:="javax.servlet"Import-Package: javax.servlet; version="2.3.0"

Page 41: OSGI workshop - Become A Certified Bundle Manager

Run-­‐Time  Bundle  Iden*fica*on

• Bundle  symbolic  name  plus  bundle  version

• Assigned  in  the  bundle  metadata

• Install  loca<on

• Assigned  when  installing  bundle

• Typically  the  URL  from  which  the  bundle  is  retrieved

• Bundle  iden<fier

• Assigned  by  the  framework

• A  long  value  which  increases  for  each  installed  bundled

Page 42: OSGI workshop - Become A Certified Bundle Manager

Framework  Bundle  Cache

• The  framework  maintains  a  bundle  cache

• Installing  a  bundle  saves  it  to  the  cache

• Once  installed,  the  original  bundle  JAR  file  is  no  longer  needed

• Subsequent  framework  execu<ons  will  reload  the  cached  bundles

• The  framework  also  saves  the  bundle  state  in  the  bundle  cache

• When  a  bundle  is  started,  it  is  persistently  recorded  as  being  ac<ve

• Ac<ve  bundles  will  be  restarted  in  subsequent  framework  execu<ons

• Upda<ng  and  uninstalling  bundles  also  impact  the  cache,  but  it  is  a  liMle  more  complicated

Page 43: OSGI workshop - Become A Certified Bundle Manager

Package  Admin

• Framework  provides  special  API  for  this  purpose

public interface PackageAdmin { static final int BUNDLE_TYPE_FRAGMENT = 0x00000001; Bundle getBundle(Class clazz); Bundle[] getBundles(String symbolicName, String versionRange); int getBundleType(Bundle bundle); ExportedPackage getExportedPackage(String name); ExportedPackage[] getExportedPackages(Bundle bundle); ExportedPackage[] getExportedPackages(String name); Bundle[] getFragments(Bundle bundle); RequiredBundle[] getRequiredBundles(String symbolicName); Bundle[] getHosts(Bundle bundle); void refreshPackages(Bundle[] bundles); boolean resolveBundles(Bundle[] bundles);}

Page 44: OSGI workshop - Become A Certified Bundle Manager

Paint  Program  Design  (1/2)

• Rela<onship  between  classes

!"#$%&'(#)*%(

+#,-.&/(#0%

!"#$%&120$2-%-.

1,()3% !45#(% '(,#-63% '(#$%72,8

!,0$3%&!"#$%

9%:#53.&!"#$%

Page 45: OSGI workshop - Become A Certified Bundle Manager

Paint  Program  Design  (2/2)

!"#$% &'"()

)*(+,%+,-./++.0'"()

1#,23)

&45",)

6,#"$-3)

6,"()7+#8

Page 46: OSGI workshop - Become A Certified Bundle Manager

Demo

Page 47: OSGI workshop - Become A Certified Bundle Manager

Experience:  Swing

• First  of  all,  how  do  you  modularize  a  UI?

• Second,  how  dynamic  do  you  want  it  to  be?

• Third:  dealing  with  already  instan<ated  stuff  (panels,  look  and  feel,  ...)

• For  more  info:hMp://lsd.luminis.nl/swing-­‐and-­‐osgi

Page 48: OSGI workshop - Become A Certified Bundle Manager

Pax  Runner

• Hosted  at  OPS4J

• Bootstrapper  for  OSGi  frameworks

• ini<al  provisioning  of  bundles

• great  tool  for  developers

Page 49: OSGI workshop - Become A Certified Bundle Manager

Pax  Runner

• Unzip  the  archive,  add  to  path

• selec<ng  the  framework

• op<ons,  op<ons,  op<ons

• profiles  and  ini<al  provisioning

• crea<ng  a  distribu<on

Page 50: OSGI workshop - Become A Certified Bundle Manager

Pax  Runner  -­‐  Frameworks

• Run  the  default  framework:pax-­‐run.sh

• Run  Equinox  version  3.5.1:pax-­‐run.sh  -­‐-­‐playorm=equinox  -­‐-­‐version=3.5.1

• Run  with  a  pre-­‐defined  profile:pax-­‐run.sh  -­‐-­‐profiles=felix.webconsole

Page 51: OSGI workshop - Become A Certified Bundle Manager

Pax  Runner  -­‐  Windows  FAQ

009.  I'm  using  Pax  Runner  on  DOS/Windows,  I  have  the  right  command  but  I'm  ge{ng  strange  errors

DOS/Windows  shell  seems  to  strip  the  equals  (=)  from  the  command  line  and  treats  the  leD  and  right  side  of  the  equals  as  separate  arguments  for  the  batch  file.  Thus,  the  arguments  to  the  java  executable  for  an  argument  like  (for  example)  -­‐-­‐profiles=log  will  be  split  in  two  arguments  as  -­‐-­‐profiles  and  log.  To  avoid  this  you  will  have  to  enclose  the  en9re  argument  between  quotes  (")  as  in  "-­‐-­‐profiles=log".

Source:  h*p://paxrunner.ops4j.org/display/paxrunner/FAQ

Page 52: OSGI workshop - Become A Certified Bundle Manager

Pax  Runner  -­‐  Provisioning

• Provisioning  your  own  bundles:

• Create  a  text  file  with  the  bundle  URLs  (called  “profile”):file:paint/servicebased.host-­‐1.0.0.jarfile:paint/servicebased.circle-­‐1.0.0.jar

• Point  to  the  file  when  launching:pax-­‐run.sh  -­‐-­‐args=file:profile

• Provisioning  all  bundles  in  a  directory:pax-­‐run.sh  mybundledir/

Page 53: OSGI workshop - Become A Certified Bundle Manager

Pax  Runner  -­‐  Crea*ng  scripts

• Crea<ng  a  script  to  launch  a  framework  without  Pax  Runner:pax-­‐run.sh  -­‐-­‐executor=script          -­‐-­‐workingDirectory=.

• Create  an  archive  containing  everything  you  need  to  run:pax-­‐run.sh  -­‐-­‐executor=zip          -­‐-­‐profiles=felix.webconsole,compendium

Page 54: OSGI workshop - Become A Certified Bundle Manager

Excercises

• Launch  Pax  Runner  with  different  fw’s

• Launch  a  profile  (felix.webconsole)hMp://localhost:8080/system/console  and  log  in  as  admin/admin

• Create  a  profile  for  the  Paint  Program

• Add  webconsole  (for  monitoring)

• Create  a  distributable  ZIP  file  with  Pax  Runner

Page 55: OSGI workshop - Become A Certified Bundle Manager

Experience:  Pax  Runner

• great  for  development

• nicely  integrates  into  build  environment

• base  for  Pax  Exam  (tes<ng  framework)

• don’t  ship  to  customers  (needs  online  connec<on,  usually  you  don’t  want  that  much  freedom)

Page 56: OSGI workshop - Become A Certified Bundle Manager

Apache  Felix  File  Install

• Simple  and  Lightweight  deployer

• Hotdeploy  directory

• The  content  of  the  directory  represents  the  content  in  the  framework

• Support  for  bundles  and  configura<ons

Page 57: OSGI workshop - Become A Certified Bundle Manager

Apache  Felix  File  Install

• Take  all  bundles  in  a  given  directory  and  install  them

• Start  all  bundles  

• If  a  bundle  can‘t  be  resolved  try  it  again  the  next  <me

• Monitor  the  directory  and  

• if  a  bundle  gets  removed  uninstall  it

• if  a  bundle  gets  added  install  and  start  it

• if  a  bundle  gets  updated  update  and  refresh  it

• Same  for  configura<ons

Page 58: OSGI workshop - Become A Certified Bundle Manager

Summary

• File  Install  adds  hotdeploy  directory

• Supports  hotdeploy  of  bundles  and  configura<ons

• Can  be  extended  for  other  types  of  deployments

• Good  for  development  

Page 59: OSGI workshop - Become A Certified Bundle Manager

Exercises

• Launch  a  framework  with  File  Install  and  Web  Consolepax-­‐run.sh      -­‐-­‐profiles=felix.config,felix.fileinstall

• Check  the  bundles  with  Web  Console

• Deploy  the  main  paint  applica<on  and  some  shapes

• Add  and  remove  shapes  to  see  how  the  applica<on  behaves

Page 60: OSGI workshop - Become A Certified Bundle Manager

Experience:  File  Install

• Great  for  development,  hot  deployment

• In  general  not  so  great  for  produc<on:  limited  control,  does  your  app  really  support  hot  deployment  at  “every”  point  in  <me?

• IF  you  use  it  in  produc<on,  at  least  customize  it,  but  look  for  other  solu<ons

Page 61: OSGI workshop - Become A Certified Bundle Manager

OBR

• OBR  aMempts  to  define  a  common  bundle  repository

• Enable  to  share,  discover,  and  deploy  

• Addresses:

• Inability  of  developers  to  discover  and  re-­‐use  exis<ng  bundles

• Difficulty  in  deploying  exis<ng  bundles

Page 62: OSGI workshop - Become A Certified Bundle Manager

OBR  Status

• Oscar  bundle  repository

• OSGi  Bundle  Repository  RFC  112

• Current  status  unsure

• Might  become  the  felix  bundlerepository

Page 63: OSGI workshop - Become A Certified Bundle Manager

OBR  Design

• Generic  capability/requirement  model

• XML  representa<on

• Models  package,  bundle,  fragments,  na<ve,  and  service  dependencies  (plus  arbitrary  ones)

• Repository  Admin  Service  for  discovery  and  deployment  of  bundles

Page 64: OSGI workshop - Become A Certified Bundle Manager

High-­‐Level  View  

!"#$%&'$()*+,"

!"#$%&'$()*-./&0

!"%$,1"(

!"23&("/"0' !"%$3(4" 56#67&,&')

!"#$%&'$()

4$0'6&0%

("8"("04"% 4("6'"%

#($1&."%

4$0'6&0%

("23&("%

9 :;;0:;;0

:;;0

:;;0

9

9

9

Page 65: OSGI workshop - Become A Certified Bundle Manager

High-­‐Level  View

!"#$%&'$()*+,-&.

/0&".'

!"#$%&'$()*1 !"#$%&'$()*2

!"#$%&'$()*3 !"#$%&'$()*4

!"#$%&'$()*5

Page 66: OSGI workshop - Become A Certified Bundle Manager

Bindex

• Tool  to  create  xml  for  a  set  of  bundles

• java  -­‐jar  bindex.jar  

-­‐r  repository.xml  

-­‐n  Paint  

bundles/*.jar

Page 67: OSGI workshop - Become A Certified Bundle Manager

XML

!-'()*+,)-."#$%&%'()(*+''),%-.///0"&1,2+3*4'),%-.///0"///"5""""!-'*)1-2'5""""""""!3'*2-+(,+)45///!63'*2-+(,+)45""""""""!*+5'5///!6*+5'5""""""""!3)216'4,7,+)45///!63)216'4,7,+)45""""""""!*)1-2'5///!6*)1-2'5""""""""!27,'8)-."*7-.///065""""""""!27(79+0+,.5///!627(79+0+,.5"""""""":::""""""""!-';1+-'6'4,5///!6-';1+-'6'4,5"""""""":::""""!6-'*)1-2'5"""":::!6-'()*+,)-.5

Page 68: OSGI workshop - Become A Certified Bundle Manager

Summary

• OBR  is  addressing  to

• find  exis<ng  bundles

• use  exis<ng  bundles

• share  bundles

• OBR  allows  to  resolve  the  transi<ve  closure  over  the  dependencies  of  a  bundle

Page 69: OSGI workshop - Become A Certified Bundle Manager

Example

• Launch  a  framework  with  OBRpax-­‐run.sh  -­‐-­‐profiles=felix.obr

• Add  repository  to  OBR

• Deploy  bundles  from  OBR  via  shell

Page 70: OSGI workshop - Become A Certified Bundle Manager

Experience

• Good  fit  if  you  have  a  „user“  driven  deployment  scenario

Page 71: OSGI workshop - Become A Certified Bundle Manager

Apache  ACE

• Started  in  incubator  on  april  24th  2009

• So8ware  distribu<on  framework  based  on  OSGi

• 12  commiMers

• working  codebase

• hMp://incubator.apache.org/ace/

Page 72: OSGI workshop - Become A Certified Bundle Manager

!"#$%&'(!

!"#$%&'()

!"#$%&'(*

+%",-'(!

+%",-'()

+%",-'(*

Deployment

!"#$%&'"()

Page 73: OSGI workshop - Become A Certified Bundle Manager

last year!"#$%&'(!

!"#$%&'()

*%"+,'(!

*%"+,'(-

last month!"#$%&'(!

!"#$%&'()

*%"+,'(!

*%"+,'()

*%"+,'(-

last week

!"#$%&'(!

!"#$%&'()

!"#$%&'(*

+%",-'(!

+%",-'()

+%",-'(*

now

!"#$%&'(!

!"#$%&'()

!"#$%&'(*

+%",-'(!

+%",-'()

+%",-'(*

Keeping  the  history

Page 74: OSGI workshop - Become A Certified Bundle Manager

Why?

• Automate  deployment

• Insight  into  who  uses  what

• History  of  each  system

• Consistent  development,  tes<ng,  produc<on

• Basis  for  several  possible  extensions

Page 75: OSGI workshop - Become A Certified Bundle Manager

Topology

!"#$%!

!"#$%!

!"#$%!

&%!'(#)*#(+,-,(&,&$.

-%#+%#

/(0*(&%&!.#%*(-,!(#1

/2,%&!0"&"$%0%&!.

"$%&!

0"&"$%0%&!."$%&!

0"&"$%0%&!."$%&!

Page 76: OSGI workshop - Become A Certified Bundle Manager

High  level  overview

!"#"$!"$%&'()$)*"("$+

!"#$%&'"()

!""#$%&'

Page 77: OSGI workshop - Become A Certified Bundle Manager

High  level  overview

!"#"$!"$%&'()$)*"("$+

!""#$%&'

Page 78: OSGI workshop - Become A Certified Bundle Manager

Dependency  Management

• Organizing  ar<facts

• Mapping  them  to  targets

Page 79: OSGI workshop - Become A Certified Bundle Manager

Organizing  ar*facts

• group  ar<facts:  makes  them  manageable

• two  levels:  feature  and  distribu<on

• Analogy:  IKEA  catalog

• data  is  kept  in  “store  repository”

!"#$%&'%(#)*"#$+

,$-./0" 1*)"$*23-#45%/"3$%

Page 80: OSGI workshop - Become A Certified Bundle Manager

Mapping  them  onto  targets

• mapping  distribu<ons  to  targets

• some<mes  done  by  an  external  system

• data  kept  in  “license  repository”

!"#$%&$'($)*&"+*,-

."&+,"/01*% 23,4$+

Page 81: OSGI workshop - Become A Certified Bundle Manager

User  Interface

• retrieve,  modify  and  store

• interact  with  OBR

Page 82: OSGI workshop - Become A Certified Bundle Manager

High  level  overview

!"#"$!"$%&'()$)*"("$+

!"#$%&'"()

!""#$%&'

Page 83: OSGI workshop - Become A Certified Bundle Manager

High  level  overview

!"#$%&'"()

!""#$%&'

Page 84: OSGI workshop - Become A Certified Bundle Manager

Deployment

• deployment  repository

• management  agent

!"#$%&'"()*+"#%,-)%.&

/0.1") 2.3405)

Page 85: OSGI workshop - Become A Certified Bundle Manager

Deployment  Repository

!"#$!%&'()"'*+,'&!"-)&'

.!"-)&/0

0/123231

4

5

6

7/12323

0/12423 7/12323 8/42323

0/12423 8/42323 9/1232:

8/42323 9/52323

.!"-)&/77/123231

4

9/52323

0/12123 7/12321 9/1232:

Page 86: OSGI workshop - Become A Certified Bundle Manager

Management  Agent

!"#$%&'(%)$ "!*')+#,-

*'.#"/0#,

"#10)-2#$343(*5

(/"!340)6

!"#"$%!%#&'"$%#&

'('.#

Page 87: OSGI workshop - Become A Certified Bundle Manager

Deployment  Admin

• deployment  packages

• versioned  set  of  ar<facts

• transac<onal  install/update

• fix  packages  provide  deltas

• signing  makes  them  secure

• extensible  through  resource  processors

• AutoConfig  defines  configura<on  admin  data

Page 88: OSGI workshop - Become A Certified Bundle Manager

From  dependency  to  deployment

!"#$%&'%(#)*"#$+

,$-./0" 1*)"$*23-#45%/"3$% + =6*0%4)%&'%(#)*"#$+

1*)"$*23-#4 7/$8%"

1%(9#+:%4"&'%(#)*"#$+

7/$8%" ,$-./0"

Page 89: OSGI workshop - Become A Certified Bundle Manager

High  level  overview

!"#"$!"$%&'()$)*"("$+

!"#$%&'"()

!""#$%&'

Page 90: OSGI workshop - Become A Certified Bundle Manager

High  level  overview

!"#"$!"$%&'()$)*"("$+

!"#$%&'"()

!""#$%&'

Page 91: OSGI workshop - Become A Certified Bundle Manager

Feedback

!"#$"%&'()*+%,+'(+*-!"#$.%/+'(01)%23-'+*%4(56%7*(,851%9%+5%:!"#$.%;21-<*%"=%23-'+*-!"#$9%>3-'+*%+5%7*(,851%:%,2??**-*-!.#$9%&'()*+%,+533*-

!=#".%@A*?B*-%45(%23-'+*,C%151*%4521-!:#".!D#".$E#".$!#".

$"#$E%;21-<*%$"%,+533*-$"#$9$"#.9E$#$$E9#$$

!"#$"%&'()*+%,+'(+*-!"#$.%/+'(01)%23-'+*%4(56%7*(,851%9%+5%:!"#$.%;21-<*%"=%23-'+*-!"#$9%>3-'+*%+5%7*(,851%:%,2??**-*-!.#$9%&'()*+%,+533*-

!"#$%!

&%!'(#)*#(+,-,(&,&$.

-%#+%#/"&"$%/%&!.

"$%&!

012,!.3($

012,!.3($

Page 92: OSGI workshop - Become A Certified Bundle Manager

Experience:  embedded

• Characteris<cs:  long  running,  deployed  in  places  you  cannot  reach,  not  always  on,  not  “reachable”  from  the  server

• most  “conven<onal”  management  tooling  is  fairly  useless  (JMX,  web  console,  ...)

• make  sure  you  can  deploy,  make  sure  you  can  see

Page 93: OSGI workshop - Become A Certified Bundle Manager

Exercises

• Launch  ACEunzip,  then  go  into  folder  and  start  run.sh/bat

• Browse  to  the  UIhMp://localhost:8080/webui/

• Upload  the  set  of  bundles  for  the  Paint  appput  in  store/  folder

• Launch  a  target,  hook  it  upunzip,  then  go  into  folder  and  start  run.sh/bat

• Add  and  remove  things

Page 94: OSGI workshop - Become A Certified Bundle Manager

Experience:  source  to  produc*on

• developer  runs  on  local  machine  (build  creates  bundles,  auto  deploys  to  ACE)

• con<nuous  build  feeds  test  servers  (deploy  like  you  would  in  produc<on)

• QA  team  uses  the  same  bundles,  performs  test  on  provisioned  systems

• release  management  finally  ships  to  customer

Page 95: OSGI workshop - Become A Certified Bundle Manager

Ques*ons

Certifiedbundle manager

Marcel and Karl are both OSGi experts. For additional training or help with your project, contact them directly or via their companies’ websites.

We, Karl Pauls and Marcel Offermans, hereby declare that this participant officially became a:

Full Name

!"#$%&%'()**%%+$,%-./0,)1)2$.*34/5%678%9):$1.%;,<.,=>,2.,%%

!"#$%"&&"'(

)*&+,"'(-../(

!"0"(123%456*"4&"7(80'56(1+,4%4&9&(?):$1.% #.8@3.% =.8% ,.>.,% #.,.843$),% 5A,,.,% 28)B.%C,6)8943$),*9.,2.,% 1)541% 5)96)834:.1% D>8%E.8672>,2%*3.11.,F% G$.*% .89A21$/03% ,.>.% >,=% *.08% $,3.8.**4,3.%;,<.,=>,2*9A21$/05.$3.,F% +$,%H483>,2*48:.$3.8% 043%*)%DF(F%I>28$66%4>6%411.%3./0,$*/0.,%C,6)8943$),.,%>,=%4>6% 411.% */0),% =>8/02.67083.,% ;8:.$3.,F% ;>6<@,=$2.%J7/56842.,K% 9.0864/0.% ;,64083.,% >,=% L.01.,3M*/0.$=>,2.,% 4>628>,=% >,2.,72.,=.8% C,6)8943$),*M142.%5A,,.,%*)%8.=>D$.83%<.8=.,F%

N4/0% O,3.8*>/0>,2.,% P),% ?/Q$,*.RK% #483,.8% >,=%";S% $,P.*3$.8.,% -./0,$5.8% 9.08% 41*% TUV% $08.8%;8:.$3*D.$3% 678% 4=9$,$*3843$P.% -@3$25.$3.,WXYF% G42.2.,%P.8:8$,2.,%E.838$.:*9$348:.$3.8%,>8%TUV%$08.8%I.$3%9$3%Z)3.,D$.11.,%Q>,=.,F%G.*%H.$3.8.,%*$,=%[UV%=.8% $9%L.1=% .864**3.,% +$,24:.=43.,% 6.01.80463F% G.8% +$,*43D%9):$1.8% ;,<.,=>,2.,% P.8*Z8$/03% *$2,$6$54,3.%S8)=>53$P$3@3**3.$2.8>,2.,F%

I>*@3D1$/0%D>%=.,%,.>.,%C,3.8453$),*9A21$/05.$3.,%678%;,<.,=.8K% .,3*3.0.,% ,.>.% #.*/0@63*$=..,F% G4*%"3$/0<)83% 0$.8% $*3% -.1.*.8P$/.K% =$.% .,36.8,3.%H483>,2%4>3)943$*$.83.8%"R*3.9.F%H@08.,=%=$.*%6870.8%,>8%678%*343$),@8.% "R*3.9.% 9$3% 6.*3.8% N.3D<.85P.8:$,=>,2%9A21$/0% <48K% 5A,,.,% $,D<$*/0.,% 4>/0% 9):$1.%+$,0.$3.,% >,3.8*373D3% <.8=.,F% ")% 5A,,.,% DF(F%#4:.1*34Z1.8% $08.% 453>.11.,% L>,53$),*=43.,% 4,% .$,.,%H483>,2**.8P.8%7:.83842.,K%=.8%=4,,%=484>6%8.42$.83F%")% 54,,% .$,% ".8P$/.9$348:.$3.8% 1)*2.*/0$/53% <.8=.,K%.*%54,,%4:.8%4>/0%=.8%453>.11.%L408.8%:.,4/08$/03$23%<.8=.,K%<.,,%#.6408%$9%E.8D>2%$*3F%

G.8%+$,*43D%)83*4:0@,2$2.8%G$.,*3.%P.8*Z8$/03%<.$3.8.%?A21$/05.$3.,K% =.8.,% O964,2% ,)/0% 54>9%4:D>*/0@3D.,%$*3F%C9%Z8$P43.,%O96.1=%<.8=.,%G$.,*3.%<$.% N4P$243$),K% 4>3)943$*/0.8% -4\$8>6% )=.8%3)>8$*3$*/0.% C,6)8943$),.,% D>9% 453>.11.,% "34,=)83%*/0),% $,% :8.$3.9% J409.,% 2.,>3D3F% ;>/0% 678%#.*/0@63*4ZZ1$543$),.,% *$,=% P$.1.% ;,<.,=>,2.,%=.,5:48F%+$,%S8)28499%678%.$,.,%Q>,=.,:.4>638423.,%54,,% 4,04,=% =.8% #S"MQ))8=$,43$),% =.,% Q>,=.,%.89$33.1,% >,=% 411.% L)89>1486.1=.8% .,3*Z8./0.,=%

P)8:.1.2.,F% (.$% =.8% C,P.,3>8% .$,.*% ]42.8*% 54,,% =$.%J4>9MK%J.241M%>,=%;83$5.1$=.,3$3@3%4,04,=%P),%JLCGM-42*%4>3)943$*/0%6.*32.*3.113%<.8=.,F%

!"0"(:"';0$<+'8"'073"7(80'56(=+,4%"(>7?#"78073"7(;>*% 3./0,$*/0.8%S.8*Z.53$P.%>,3.8*/0.$=.,%*$/0%9)M:$1.% Q1$.,3.,% P),% *343$),@8.,% P)8% 411.9% =>8/0% =8.$%+$2.,*/0463.,^%

!"!661$,.ML@0$25.$3%

!"#.8$,2.%J.**)>8/.,%

!"GR,49$5%%

_@>6$2%1@**3%*$/0%.$,.%5),*34,3.%N.3D<.85P.8:$,=>,2%678%9):$1.% Q1$.,3.,% ,$/03% 2484,3$.8.,F%H.,,% =$.% ;,M<.,=>,2% =.,,)/0% P.8672:48% *.$,% *)11K% 9>**% *$.% $,%=.8%]42.%*.$,K%.8*3.,*%*.8P.8*.$3$2.%G43.,% 1)541%P)8MD>0413.,% >,=% D<.$3.,*% (.,>3D.8.$,24:.,% 1)541% D>%Z>66.8,% >,=% *[email protected]% D>% 7:.83842.,F% C,% :.$=.,% L@11.,%:.*3.03%=$.%28>,=*@3D1$/0.%;>624:.%$,%=.8%"R,/08),$M*43$),%P),%G43.,F%

+*% :.*3.03% .$,.% 28)B.% E$.16413% 4,%9):$1.,% +,=2.8@M3.,F%N)3.:))5*%:$.3.,%"Z.$/0.8M%>,=%J./0.,8.**)>8M/.,K% =$.%G.*53)ZMJ./0,.8,% P.821.$/0:48% *$,=F%SG;*%>,=%_4,=R*%*$,=%=42.2.,%=.>31$/0%5,4ZZ.8%:.*37/53F%;>/0%=$.%#8AB.% =.*%G$*Z14R*% >,=%=$.%+$,24:.9A2M1$/05.$3.,% 5A,,.,% *.08% .$,2.*/08@,53% *.$,F% "/01$.BM1$/0% $*3% =$.% (4,=:8.$3.% 9.$*3.,*% D>% 51.$,K% >9% DF(F%5)9Z1.\.%H.:%TFU%;,<.,=>,2.,%D>%>,3.8*373D.,F%

G>8/0%=$.%E$.16413%4,%;,<.,=>,2*9A21$/05.$3.,%.82.M:.,%*$/0%*3.3$2%,.>.%;,6)8=.8>,2.,%4,%9):$1.%Q1$.,M3.,F%G$.*%2$13% D>9%+$,.,% 678%=$.% 8.$,.%")63<48.*.$3.K%=4% ,.>.% L.43>8.*% *)6)83% =.,% ;,<.,=.8,% :.8.$32.M*3.113%<.8=.,%*)113.,F%+$,.%3>8,>*9@B$2.%;:24:.%P),%#.8@3.,% :.$% .$,.9% C-M-./0,$5.8% D>8% ;53>41$*$.8>,2%=.8% Q),6$2>843$),% $*3% 4>6<.,=$2% >,=% 67083% D>% .$,.9%P.8DA2.83.,% +$,*43D% ,.>.8K% S8)=>53$P$3@3**3.$2.8,=.8%L.43>8.*F%

Marcel [email protected]

Karl [email protected]