Presentation is loading. Please wait.

Presentation is loading. Please wait.

OSGi in action BlueDavy 1.1 2007-10-20.

Similar presentations


Presentation on theme: "OSGi in action BlueDavy 1.1 2007-10-20."— Presentation transcript:

1 OSGi in action BlueDavy http://www.osgi.org.cn http://blog.bluedavy.cn 1.1 2007-10-20

2 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-212 Agenda  Use OSGi with popular framework  Deploy exist system to OSGi  The feature of OSGi application  OSGi application design best practices  OSGi application develop best practices  Resources

3 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-213 Use OSGi with popular framework  Use with Hibernate  Use with Spring  Use with Webwork  Intergration key factors

4 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-214 Use with Hibernate  Download Hibernate-OSGi  http://www.osgi.org.cn/Hibernate-OSGi; http://www.osgi.org.cn/Hibernate-OSGi  install cn.org.osgi.hibernate bundle or import Hibernate-OSGi source project to eclipse.  Write demo bundle with Hibernate-OSGi to use Hibernate

5 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-215 Use with Hibernate  Change the connection info in hibernate.cfg.xml of cn.org.osgi.hibernate bundle;  New Plug-in project,and write persistent class as you always do,then generate persistent class hbm file;  Implemention DAO class with cn.org.osgi.hibernate.service.CommonDaoServi ce or other common Hibernate DAO API;

6 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-216 Use with Hibernate  Register Persistent class as extension point;  create plugin.xml,then input following content into the file,just like this: –  Start the application,then finish the demo that use OSGi with Hibernate

7 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-217 Use with Hibernate  Summary  the difference between use with hibernate and use with OSGi & hibernate only two sides: –don’t add resource mapping element to hibernate.cfg.xml any more; –Use extension point to register po.

8 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-218 Use with Hibernate  The implemention method of Hibernate-OSGi  Refactor AbstractClassGenerator.getClassLoader() method to sure use the AbstractClassGenerator class’s classloader to load the associate class –Why do this? –Just because AbstractClassGenerator use po class’s classloader to load cglib associate class,but now the bundle including po class don’t need import cglib jar.  Based on extension point to register/unregister po –Why do this? –Just because module seperation rule. –Use extension point so we can register po outside of HibernateModule. –The session service use Configuration.addClass to register po from other bundle.

9 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-219 Use with Hibernate  The weakpoint of Hibernate-OSGi  Not support many hibernate po advanced configuration just like po class cache etc. currently;  Not support multi sessionfactory currently;  Need support register connection info from other bundles;  When new pos added or exist pos removed,SessionFactory need be restarted;  Let’s improve Hibernate-OSGi together  If u want to join this group,pls visit this webpage: – http://www.osgi.org.cn/Hibernate-OSGi/join.html

10 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-2110 Use with Spring  Download Spring-OSGi;  http://www.springframework.org/osgihttp://www.springframework.org/osgi  Create the build and run environment  Publish Spring bean as OSGi service  Inject OSGi service to Spring bean  Best practices  The weakpoint of Spring-OSGi

11 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-2111 Use with Spring  Create the build and run environment  install these bundles to eclipse or equinox –aopalliance –aspectjrt –backport-util-concurrent –spring-aop –spring-aspects –spring-beans –spring-context –spring-core –spring-dao –spring-osgi-core –spring-osgi-extender –spring-osgi-io

12 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-2112 Publish Spring bean as OSGi service  It’s very simple to do this  just write this element – –You can add osgi:service-properties to realize the properties configuration in OSGi component’s xml

13 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-2113 Inject OSGi service to Spring bean  It’s also very simple to do this, just write this element   We can use two method to inject this OSGi service to spring bean – –add osgi:listener to osgi:reference – –The bind-method need change to this kind signature public void some-method-name(service interface,Dictionary)  The difference between these two methods –The first method cann’t get the OSGi service’s dynamic changination,but the second method can do this.

14 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-2114 Best practices  Only publish those pojo needed export as OSGi service;  Use osgi:listener method to inject OSGi service to spring bean;  Handle the OSGi service dynamic change;  If can publish the pojo in DS style,then use DS style;

15 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-2115 The weakpoint of Spring-OSGi  Cann’t dynamic load spring bean bundle;  Spring-OSGi bundle must start before other bundles;  Spring-OSGi depends excessive bundles.

16 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-2116 Use with Webwork  Download Webwork-OSGi  http://www.osgi.org.cn/Webwork-OSGi http://www.osgi.org.cn/Webwork-OSGi  Install cn.org.osgi.webwork bundle or Import Webwork-OSGi project to eclipse  The bundle did realize webwork intergration with Spring-OSGi  Write demo bundle with Webwork-OSGi to use webwork with OSGi

17 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-2117 Use with Webwork  New Plug-in project,write action class and action xml as always you do;   Class property upside map to its OSGi service’s property –  Publish action class as OSGi service in ds style or spring-OSGi style;  Export the package where your action classes and action resource files in;  Register action xml file to extension point;  <extension point=“cn.org.osgi.webwork.actionextension">  Start the application,then u can visit the action

18 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-2118 Use with Webwork  Summary  the difference between use with webwork and use with webwork-OSGi –the action class property is not the action class true name,but is the osgi service command property the action class published; –the action xml file is not write to a singlepoint xwork.xml,but register to webwork-OSGi based on extension point;

19 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-2119 Use with Webwork  The implemention of Webwork-OSGi  Write own action xml file configuration provider class –so webwork-OSGi can dynamic load and unload action xml file outside webwork-OSGi bundle;  Write own ObjectFactory to load action and other class –so webwork-OSGi can load action class instance from OSGi service registration and then realize intergration with spring- OSGi; –Other class loading as webwork always do  Change webwork action xml file configuration provider and ObjectFactory

20 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-2120 Use with Webwork  The weakpoint of Webwork-OSGi  Maybe we need write a webwork-OSGi bundle so when webwork update,we can update quickly;  Not support servlet filter configuration,but this is httpservice problem

21 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-2121 Intergration key factors  Classloader factor  Can use OSGi Dynamic-ImportPackage and Export- Package to solve this factor.  Resource loader factor  Can use extension point to realize load resource dynamically and so resource can be placed in module style.  The most important factor:”modularity” & “Plug and Play”

22 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-2122 Agenda  Use OSGi with popular framework  Deploy exist system to OSGi  The feature of OSGi application  OSGi application design best practices  OSGi application develop best practices  Resources

23 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-2123 Deploy exist system to OSGi  Use bnd tool to do this  http://www.aqute.biz/Code/Bnd http://www.aqute.biz/Code/Bnd  http://www.aqute.biz/Code/BndCn http://www.aqute.biz/Code/BndCn  Step  Separate project packages in module style logically;  Define module need import package and export package;  Write bnd file for per module;  Run bnd tool then get the module jar file;  Deploy the module jar file to OSGi framework

24 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-2124 Agenda  Use OSGi with popular framework  Deploy exist system to OSGi  The feature of OSGi application  OSGi application design best practices  OSGi application develop best practices  Resources

25 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-2125 The feature of OSGi application  Strict and clear modularity  Quickly know the module dependency;  Quickly know the module exported function;  Quickly know how the module can be extensioned;  Reusable  Build company bundle respository  Dynamic  “Plug and Play”  Extensionable

26 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-2126 Agenda  Use OSGi with popular framework  Deploy exist system to OSGi  The feature of OSGi application  OSGi application design best practices  OSGi application develop best practices  Resources

27 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-2127 OSGi app design best practices  Clear and strict define module;  Module’s Export Function;  Module’s Dependency;  Module’s Extension Point;  Interface-oriented and SOCM;  Bundles compose of components,components communicate each other with OSGi service;  All service publish in interface type;  Split Interface & Implemention into separate bundles;

28 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-2128 Agenda  Use OSGi with popular framework  Deploy exist system to OSGi  The feature of OSGi application  OSGi application design best practices  OSGi application develop best practices  Resources

29 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-2129 OSGi app develop best practices  Keep the dynamic feature  Don’t suppose the dependence service usable;  Handle the dynamic change such as extension added/event published/service unavaible;  If the service is used only inside bundle,then don’t publish it as OSGi service;  Don’t make static dependency to other bundles;

30 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-2130 Agenda  Use OSGi with popular framework  Deploy exist system to OSGi  The feature of OSGi application  OSGi application design best practices  OSGi application develop best practices  Resources

31 http://www.osgi.org.cnhttp://www.osgi.org.cn 致力于 OSGi 的推广和发展 OSGi China User Group: http://www.osgi.org.cn 致力于 OSGi 的推广和发展http://www.osgi.org.cn 2015-10-2131 Resources  OSGi R4 Specifications OSGi R4 Specifications  《 OSGi 实战》 Opendoc 《 OSGi 实战》 Opendoc  《 OSGi 进阶》 Opendoc 《 OSGi 进阶》 Opendoc  http://www.osgi.orghttp://www.osgi.org  http://www.osgi.org.cnhttp://www.osgi.org.cn  http://www.aqute.bizhttp://www.aqute.biz  http://blog.bluedavy.cnhttp://blog.bluedavy.cn

32 Click to edit company slogan. OSGi China User Group http://www.osgi.org.cn


Download ppt "OSGi in action BlueDavy 1.1 2007-10-20."

Similar presentations


Ads by Google