Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
OSGi Enterprise R6 specs are out!
David Bossch...
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
About David Bosschaert davidb@apache.org
§  R...
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
About Carsten Ziegeler cziegeler@apache.org
§...
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Agenda
New and updated specs in OSGi Enterpris...
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Asynchronous Services and Promises
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
OSGi Promises
Javascript-style promises, can b...
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Async Services
§  Take an existing OSGi Servi...
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Declarative Services
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Declarative Services
§  Powerful component de...
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Configuration / Metatype
10
@Component
public ...
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Metatype based Configuration
§  Apache Felix ...
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Service References
§  Lookup Strategy
§  Eve...
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Field Injection
13
@Reference
private GameCont...
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Runtime Service
§  Introspection through DTOs...
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Declarative Services
§  Supports Framework R6...
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Http Whiteboard
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Building a Web Application
§  Servlets
§  Re...
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Web Application
18
Servlet B
/scores
Servlet A...
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Http Whiteboard
19
@Component( service = Servl...
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Web Applications
20
Servlet B
/scores
Servlet ...
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Web Contexts
21
@Component( service = ServletC...
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Whiteboard Registrations
§  ServletContextHel...
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Http Whiteboard Service
§  Servlet 3.1 API
§...
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
REST
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
OSGi REST Management
§  Manage remote OSGi Fr...
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
REST Management - Raw
§  List Bundles
	
  	
 ...
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
REST Client APIs
§  Java Client
	
  
RestClie...
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Portable Java Contracts
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Portable Java Contracts
§  Java packages that...
OSGi Enterprise R6 specs are out! - David Bosschaert & Carsten Ziegeler
Upcoming SlideShare
Loading in …5
×

OSGi Enterprise R6 specs are out! - David Bosschaert & Carsten Ziegeler

602 views

Published on

OSGi Community Event 2015

The Enterprise OSGi Specs R6 have been released this summer. There is a lot of good stuff in there! Asynchronous Services, REST management, HTTP Whiteboard, cool DS enhancements and much more. In this talk David and Carsten will give an overview of the new technologies so you can get started with it right away.

Published in: Technology
  • Be the first to comment

OSGi Enterprise R6 specs are out! - David Bosschaert & Carsten Ziegeler

  1. 1. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi Enterprise R6 specs are out! David Bosschaert | Carsten Ziegeler | Adobe R&D
  2. 2. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. About David Bosschaert davidb@apache.org §  R&D Adobe Ireland §  Co-chair OSGi Enterprise Expert Group §  ISO/IEC JTC1 SC38 Cloud Computing committee member for Ireland §  Apache Felix, Aries PMC member and committer §  … other opensource projects §  Cloud and embedded computing enthusiast 2
  3. 3. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. About Carsten Ziegeler cziegeler@apache.org §  RnD Adobe Research Switzerland §  Member of the Apache Software Foundation §  VP of Apache Felix and Apache Sling §  OSGi Core Platform, OSGi Enterprise, OSGi IoT Expert Groups §  Member on the board of the OSGi Alliance §  Book / article author, technical reviewer, conference speaker 3
  4. 4. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Agenda New and updated specs in OSGi Enterprise R6 §  Asynchronous Services and Promises §  Declarative Services §  Http Whiteboard §  REST Management §  Portable Contracts 4
  5. 5. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Asynchronous Services and Promises
  6. 6. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi Promises Javascript-style promises, can be used with Java 5 or later. §  Asynchronous chaining §  Very simple programming model Promises can be used outside of OSGi framework   Recommended implementation: https://svn.apache.org/repos/asf/aries/trunk/ async 6 public  class  PromisesTest  {            public  static  void  main(String...  args)  {                  System.out.println("Starting");                  takesLongToDo(21)                          .then(p  -­‐>  intermediateResult(p.getValue()))                          .then(p  -­‐>  finalResult(p.getValue()));                  System.out.println("Async  computation  kicked  off");          }            public  static  Promise<Long>  intermediateResult(Long  l)  {                  System.out.println("Intermediate  result:  "  +  l);                  return  takesLongToDo(l  *  2);          }            public  static  Promise<Void>  finalResult(Long  l)  {                  System.out.println("Computation  done.  Result:  "  +  l);                return  Promises.resolved(null);          }            public  static  Promise<Long>  takesLongToDo(long  in)  {  
  7. 7. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Async Services §  Take an existing OSGi Service … §  … and make it async! §  Or use an async-optimized one §  Also works great with Remote Services §  Recommended implementation: https://svn.apache.org/repos/asf/aries/trunk/ async Normal service use:  TimeConsumingService  tcs  =  ...  //  from  Service  Registry    System.out.println("Invoking  Big  Task");    System.out.println("Result:  "  +  tcs.bigTask(1));    //  further  code   7 §  Async service use §  via mediator obtained from Async Service  TimeConsumingService  tcs  =  ...  //  from  Service  Registry    Async  async  =  ...  //  Async  Service  from  Service  Registry    TimeConsumingService  mediated  =  async.mediate(    tcs,  TimeConsumingService.class);        System.out.println("Invoke  Big  Task  Asynchronously...");    async.call(mediated.bigTask(1))        .then(p  -­‐>  bigTaskFinished(p.getValue()));    System.out.println("Big  Task  submitted");    
  8. 8. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Declarative Services
  9. 9. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Declarative Services §  Powerful component development §  Managing OSGi dynamics §  Integrates with Configuration Admin §  Support for metatype §  100% Pure Java
  10. 10. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Configuration / Metatype 10 @Component public class GameControllerImpl implements GameController { public @interface Config { int easy_max() default 10; ... } private Config configuration; @Activate protected void activate(final Config config) { this.configuration = config; } @Designate( ocd = GameControllerImpl.Config.class ) @ObjectClassDefinition( name = "Game Configuration", description = "The configuration for the guessing game.") @AttributeDefinition(name="Easy", description="Maximum value for easy“)
  11. 11. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Metatype based Configuration §  Apache Felix Web Console 11
  12. 12. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Service References §  Lookup Strategy §  Event Strategy §  Field Strategy 12
  13. 13. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Field Injection 13 @Reference private GameController game; @Reference private List<HighscoreService> highscores;
  14. 14. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Runtime Service §  Introspection through DTOs §  Apache Felix Web Console Plugin
  15. 15. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Declarative Services §  Supports Framework R6 §  Simple, efficient, but powerful
  16. 16. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Http Whiteboard
  17. 17. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Building a Web Application §  Servlets §  Resources §  Filters §  Listeners 17
  18. 18. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Web Application 18 Servlet B /scores Servlet A /game Servlet C /* Servlet Filters Resources /*.js|*.css Request Listeners
  19. 19. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Http Whiteboard 19 @Component( service = Servlet.class , scope = ServiceScope.PROTOTYPE, property={"osgi.http.whiteboard.servlet.pattern=/game"}) public class ServletA extends HttpServlet { @Component( service = Filter.class , scope = ServiceScope.PROTOTYPE, property={"osgi.http.whiteboard.filter.pattern=/*"}) public class MyFilter implements Filter { @Component( service = ServletRequestListener.class, property={"osgi.http.whiteboard.listener=true"}) public class MyListener implements ServletRequestListener {
  20. 20. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Web Applications 20 Servlet B /scores Servlet A /game Servlet C /* Servlet Filters Resources /*.js|*.css Request Listeners Servlet Filters Request Listeners Resources /*.js|*.css Servlet X /foo Servlet Z /* Servlet Context <mygame> /play Servlet Context <app> /fooapp
  21. 21. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Web Contexts 21 @Component( service = ServletContextHelper.class , property={"osgi.http.whiteboard.context.name=mygame", "osgi.http.whiteboard.context.path=/play"}) public class GameServletContext extends ServletContextHelper { @Component( service = Servlet.class , scope = ServiceScope.PROTOTYPE, property={"osgi.http.whiteboard.servlet.pattern=/foo", "osgi.http.whiteboard.context.select=mygame"}) public class ServletB extends HttpServlet {
  22. 22. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Whiteboard Registrations §  ServletContextHelper §  Grouping §  Security §  Resource Handling §  Servlets §  Listeners §  Resources §  Filters §  Error Pages 22
  23. 23. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Http Whiteboard Service §  Servlet 3.1 API §  Runtime Service §  DTOs §  Introspection §  Multipe Whiteboard Services possible §  Different endpoints / apps 23
  24. 24. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. REST
  25. 25. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi REST Management §  Manage remote OSGi Frameworks §  using REST/HTTP §  data in either JSON or XML §  Control Bundles §  install / start / stop / uninstall §  Inspect Service §  Control Start Levels §  Clients §  Raw §  Java §  JavaScript Implementation at http://git.eclipse.org/c/concierge/org.eclipse.concierge.git 25 Flaming June, by Frederic Lord Leighton, Wikipedia
  26. 26. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. REST Management - Raw §  List Bundles            $  curl  http://127.0.0.1:8888/framework/bundles              ["framework/bundle/0","framework/bundle/1","framework/bundle/2","framework/bundle/3","framework/bundle/4"]   26 §  List Services            $  curl  'http0.0.1:8888/framework/services?filter=(objectClass=*Resolver)'              ["framework/service/15"]   §  Install a Bundle            $  curl  -­‐i  -­‐X  POST  http://127.0.0.1:8888/framework/bundles  -­‐H  "Content-­‐Type:  application/vnd.osgi.bundle"                              -­‐-­‐data-­‐binary  "@/bundles/my-­‐bundle.jar"              framework/bundle/14   §  Get Bundle details            $  curl  http://127.0.0.1:8888/framework/bundle/14              {"symbolicName":"my-­‐bundle","location":"cf3da656-­‐febd-­‐4e05-­‐aff6-­‐16e6a925f86d","id":14,"state":2,                "lastModified":1445457553149,"version":"1.1.1"}   §  Start a Bundle            $  curl  -­‐i  -­‐X  PUT  http://127.0.0.1:8888/framework/bundle/14/state                              -­‐H  "Content-­‐Type:  application/org.osgi.bundlestate+json"  -­‐-­‐data  '{"state":32}'  
  27. 27. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. REST Client APIs §  Java Client   RestClientFactory  restClientFactory  =  …  //  From  Service  Registry   RestClient  restClient  =  restClientFactory.createRestClient("http://127.0.0.1:8888");   Collection<String>  serviceURIs  =  getRestClient().getServicePaths("(objectClass=*Resolver)");   27 §  JavaScript Client   var  client  =  new  OSGiRestClient('http://127.0.0.1:8888');   client.getBundles({      success  :  function(res)  {          //  do  something  with  res,  which  is  an  Array  of  bundle  URI  strings      },        failure  :  function(errCode,  res)  {          //  handle  failure   }});  
  28. 28. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Portable Java Contracts
  29. 29. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Portable Java Contracts §  Java packages that do not follow semantic versioning, e.g. from the JCP §  What version range do you import? §  ? 29 §  Solution: use osgi.contract §  and Import-Package without version range! Import-­‐Package:  javax.servlet,  javax.servlet.http   Require-­‐Capability:  osgi.contract;                          filter:="(&(osgi.contract=JavaServlet)(version=3.0))"   §  http://www.osgi.org/Specifications/ReferenceContract

×