32
Apache Celix Universal OSGi? Alexander Broekhuis [email protected]

ApacheCon NA11 - Apache Celix, Universal OSGi?

Embed Size (px)

Citation preview

Page 1: ApacheCon NA11 - Apache Celix, Universal OSGi?

Apache  CelixUniversal  OSGi?

Alexander  Broekhuis  [email protected]

Page 2: ApacheCon NA11 - Apache Celix, Universal OSGi?

Introduc<on

• Alexander  Broekhuis• Started  as  Java  Engineer

• Programming  C  since  2010

• At  Luminis  since  2008• Small  SoAware  House

• Research  and  innovaEon  oriented

• Involved  in  Open  Source  (Apache)

• Apache  commiKer  since  2010

Page 3: ApacheCon NA11 - Apache Celix, Universal OSGi?

Agenda

• IntroducEon

• History

• OSGi  in  C

• Remote  Services

• Development

• Universal  OSGi

• Status

Page 4: ApacheCon NA11 - Apache Celix, Universal OSGi?

Introduc<on

• OSGi  specificaEon  implemented  in  C• Adapted  where  needed

• Focussed  on  Embedded  Dynamic  Systems

• Based  on  Apache  Felix

• Remote  Services

• Distributed  Systems

• Interoperability  with  Java

Page 5: ApacheCon NA11 - Apache Celix, Universal OSGi?

History

• Started  in  2010

• Middleware

• Mixed  Java/C  environment

• Based  on  (de-­‐facto)  standards

• Open  Source

• Generic  Middleware  -­‐>  No  core  business

• Benefits  others,  but  also  benefits  FROM  others

Page 6: ApacheCon NA11 - Apache Celix, Universal OSGi?

OSGi  is:

• component  based  framework

• allows  dynamic  assembly  of  components

• Java,  so  independent  of  operaEng  system

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  so@ware  lifecycle.  These  capabiliBes  greatly  increase  the  value  of  a  wide  range  of  computers  and  devices  that  use  the  Java™  plaForm.

Page 7: ApacheCon NA11 - Apache Celix, Universal OSGi?

OSGi

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

!"#$%&'&($

)*+,*

$-.

)*+,/-0)*+,*

)*122"-0 )*12

+&/3$,$)1(3$.

4-"-)*+(($.

4-"-)*+((

"-)*+(($."-)*+((

Page 8: ApacheCon NA11 - Apache Celix, Universal OSGi?

OSGi

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

+%,'()*!!

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

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

("$%.*23,&-,.!!

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

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

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

!"#$%&'&($

)*+,*

$-.

)*+,/-0)*+,*

)*122"-0 )*12

+&/3$,$)1(3$.

4-"-)*+(($.

4-"-)*+((

"-)*+(($."-)*+((

Page 9: ApacheCon NA11 - Apache Celix, Universal OSGi?

OSGi

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

+%,'()*!!

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

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

("$%.*23,&-,.!!

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

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

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

Page 10: ApacheCon NA11 - Apache Celix, Universal OSGi?

OSGi

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

+%,'()*!!

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

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

("$%.*23,&-,.!!

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

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

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

!"#$%&'&$())'*&+,(-./'%0!$1012-)'3"24$1*&+,(-./'5''''!"#$%&',.%4')-(/-63"24$17.2-18-'&.2-18-9'5''''''''&.2-18-:/1;%)-1/<1/,%&16<-./1:&$()):;1-=(0169>'2"$$>'''''''''''''21?'<-./1@0!$699A''''B''''!"#$%&',.%4')-.!63"24$17.2-18-'&.2-18-9'5''''BB

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

!+-#"

Page 11: ApacheCon NA11 - Apache Celix, Universal OSGi?

Benefits

• Making  products  with  many  variaEons

• Improving  quality  through  re-­‐use

• Speed:  Eme  to  market

Page 12: ApacheCon NA11 - Apache Celix, Universal OSGi?

OSGi  in  C

• Follows  the  OSGi  SpecificaEon• A  Service  Registry  for  tracking  services

• Bundle  AcEvators  for  registering  services

• Bundle  Lifecycle  for  tracking  Bundle  state

• Structs  instead  of  Interfaces

• Using  funcEon  pointers  to  forward  calls

Page 13: ApacheCon NA11 - Apache Celix, Universal OSGi?

Services  in  C

• Service• Struct  with  funcEon  pointers

• AcEvator

• start  /  stop

• Celix

• bundleContext

• registry

• etc..

Celix

Activator+ start+ stop

Component

<struct>ServiceregisterService

getService

create

depends

create

pointer

Page 14: ApacheCon NA11 - Apache Celix, Universal OSGi?

Services  in  C  -­‐  BundleAc<vator

C - BundleActivator

celix_status_t bundleActivator_start(void * userData, BUNDLE_CONTEXT context) { struct userData * data = (struct userData *) userData; printf("Hello %s\n", data->word); return CELIX_SUCCESS;}

Java - BundleActivator

@Overridepublic void start(BundleContext context) throws Exception { System.out.println("Hello " + m_word);}

Page 15: ApacheCon NA11 - Apache Celix, Universal OSGi?

Services  in  C  -­‐  Service  registra<on

C - Register service

SHELL_SERVICE shellService = (SHELL_SERVICE) apr_palloc(pool, (sizeof(*shellService));shellService->shell = shell;shellService->getCommands = shell_getCommands;shellService->getCommandDescription = shell_getCommandDescription;shellService->getCommandUsage = shell_getCommandUsage;shellService->getCommandReference = shell_getCommandReference;shellService->executeCommand = shell_executeCommand;

SERVICE_REGISTRATION registration = NULL;status = bundleContext_registerService(

context, SHELL_SERVICE_NAME, shellService, NULL, &registration);

Java - Register service

context.registerService(ShellService.class.getName(), new ShellServiceImpl(), null);

Page 16: ApacheCon NA11 - Apache Celix, Universal OSGi?

• Dynamic  Loading• Library

• Using  dlfcn.h

• dlopen  /  dlclose  

• dlsym

Dynamic  Assembly

<shared object>Celix

<shared object>Provider

<shared object>Consumer

<struct>ProviderService

Uses

Realizes

Depends

Depends

Initializes

Initializes

Page 17: ApacheCon NA11 - Apache Celix, Universal OSGi?

• Bundling• Zip  file  with  Shared  Object

• (.so,  .dll,  .dylib,  ...)

• Manifest

• Import  /  Export

• RunEme• Extracted  to  cache

Deployment

Page 18: ApacheCon NA11 - Apache Celix, Universal OSGi?

• Paint  ApplicaEon• From  OSGi  in  AcEon

• Install  /  Start  /  Stop  bundles

Demo

Page 19: ApacheCon NA11 - Apache Celix, Universal OSGi?

Remote  Services

• Remote  Service  Admin• Enterprise  SpecificaEon

• Interoperability

• Protocol• SOAP?

• REST/JSON

• Hessian

Page 20: ApacheCon NA11 - Apache Celix, Universal OSGi?

Server

RemotePublisher

«track»

ServerStub«service»

Serverremote = "true"

ServerProxy

Client

ProxyPublisher

Registry

«service»Server

imported = "true"

«service»Discovery

Service

«service»Discovery

Service

Remote  Services

Page 21: ApacheCon NA11 - Apache Celix, Universal OSGi?

Server

RemotePublisher

«track»

ServerStub«service»

Serverremote = "true"

ServerProxy

Client

ProxyPublisher

Registry

«service»Server

imported = "true"

«service»Discovery

Service

«service»Discovery

Service

Remote  Services

Stubs Proxies

Page 22: ApacheCon NA11 - Apache Celix, Universal OSGi?

Remote  Services  in  Celix

• REST/JSON• Basic  implementaEon  working

• Hessian• Basic  (de)serializaEon  implementaEon  made

• Todo

• Generate  code  for  endpoints  (stubs/proxies)

• Test/Implement  interoperability  with  Java

Page 23: ApacheCon NA11 - Apache Celix, Universal OSGi?

Demo  -­‐  Remote  Services

• Calculator  Example  Service

• Calculator  Shell  Commands

• add  /  sub  /  sqrt

• Endpoints  using  REST  /  JSON

• Embedded  Mongoose  webserver

struct example_service { example_t example; celix_status_t (*add)(example_t example,

double a, double b, double *result); celix_status_t (*sub)(example_t example,

double a, double b, double *result); celix_status_t (*sqrt)(example_t example,

double a, double *result);};

Page 24: ApacheCon NA11 - Apache Celix, Universal OSGi?

Demo  -­‐  Remote  Services

• Calculator  Example  Service

• Calculator  Shell  Commands

• add  /  sub  /  sqrt

• Endpoints  using  REST  /  JSON

• Embedded  Mongoose  webserver

struct example_service { example_t example; celix_status_t (*add)(example_t example,

double a, double b, double *result); celix_status_t (*sub)(example_t example,

double a, double b, double *result); celix_status_t (*sqrt)(example_t example,

double a, double *result);};

struct example_service { example_t example; celix_status_t (*add)(example_t example,

double a, double b, double *result); celix_status_t (*sub)(example_t example,

double a, double b, double *result); celix_status_t (*sqrt)(example_t example,

double a, double *result);};

Page 25: ApacheCon NA11 - Apache Celix, Universal OSGi?

PlaJorm  Support

• Apache  Portable  RunEme• Linux,  Unix,  Windows,  etc

• Memory  pool

• File  handling

• Threads

• No  RealTime/Embedded• Reuse  APR  API

Page 26: ApacheCon NA11 - Apache Celix, Universal OSGi?

Building

• CMake• Cross  pladorm  /  MulE  IDE

• Framework

• Standard  library

• Bundle  macros

• Create  bundle  zip

• Add  library  and  resources

Page 27: ApacheCon NA11 - Apache Celix, Universal OSGi?

Universal  OSGi

• RFP-­‐89• Proposed  to  the  mailing  list  in  2007

• Since  then  remained  silent

• Ongoing  effort  to  pick  up  again

• Supported  Languages• C++  /  .NET  language  (C#)  /  ECMAScript

• What  about  C?

• Interest  from  Community?

Page 28: ApacheCon NA11 - Apache Celix, Universal OSGi?

Universal  OSGi  -­‐  Celix

• NaEve  port  in  C

• Status

• Based  on  the  R4  SpecificaEon

• Deployable  bundles

• Bundle  lifecycle

• Service  registry

• Framework  API

• Standards  for  IPC  and  communicaEons

• Remote  Services

Page 29: ApacheCon NA11 - Apache Celix, Universal OSGi?

Status  -­‐  Framework

• Dynamic  Loading  of  Libraries

• Service  Registry  for  Querying  and  Registering

• Bundles  with  Manifest  for  Deployment

• Service  Tracker  for  tracking  Services

• Bundle  State  and  Life  Cycle

• Bundle  Cache  for  Storing  State

Page 30: ApacheCon NA11 - Apache Celix, Universal OSGi?

Status  -­‐  Extras

• Shell  ImplementaEon  for  InspecEng  Bundles• ps/start/stop/install/update/uninstall  commands

• Dependency  Manager  for  Dependencies

• Simple  ImplementaEon

• StaEc  Linked

• Open  Source  at  Apache• Currently  in  the  Incubator

Page 31: ApacheCon NA11 - Apache Celix, Universal OSGi?

Apache  Celix

• Roadmap• ...  

• Deployment  Admin

• Remote  Services

• ConfiguraEon  Admin

• Event  Admin

• Looking  for

• Users  /  Testers  /  CommiKers

Page 32: ApacheCon NA11 - Apache Celix, Universal OSGi?

Links

• Original  Proposal:• hKp://wiki.apache.org/incubator/CelixProposal

• Incubator  Mailing  List  Archive:

• hKp://incubator.markmail.org/search/?q=Celix

• IncubaEon  Status:

• hKp://incubator.apache.org/projects/celix.html

• Project  Page:

• hKp://incubator.apache.org/celix/