Download presentation
Presentation is loading. Please wait.
1
Introduce OSGi BlueDavy http://www.osgi.org.cn http://blog.bluedavy.cn 1.0 2007-10-28
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-4-142 Agenda Play OSGi Who use OSGi What is OSGi OSGi R4 Implemention How to develop OSGi app OSGi 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-4-143 Play OSGi Let’s see a short demo First we see an bulletin application,but only have bulletin list function; We want to add new bulletin,so we find newbulletin module from module respository,then install & start it,now we can add new bulletin; We see the feature of OSGi application modularity dynamic,”Plug and Play” extensionable these features are supported by OSGi,the meaning is that you don’t need realize those features yourself,what you need do is just use it
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-4-144 Agenda Play OSGi Who use OSGi What is OSGi OSGi R4 Implemention How to develop OSGi app OSGi Resources
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-4-145 Who use OSGi IBM Websphere RSA BEA microServices,All BEA product will be based on microServices Eclipse Apache Struts 2 Spring Spring-OSGi Simens,Nokia,BMW,Cisco etc. SAP,Oracle,IONA etc. are interested in OSGi,and be OSGi EEG member
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-4-146 Agenda Play OSGi Who use OSGi What is OSGi OSGi R4 Implemention How to develop OSGi app OSGi Resources
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-4-147 What is OSGi Dynamic Module System For Java JSR232 JSR291 Universal Middleware Best practice guide and support for building modularity/dynamic/extensionable system Modularity with rule; Dynamic support for module,OSGi service,configuration; Extension support with OSGi service.
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-4-148 OSGi Basic Concepts Modularity Define module in OSGi; Publish functions for other modules; Use functions provided by other modules. Bundle JAVA Operating System Hardware OSGi Framework Service registry packages
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-4-149 Define module in OSGi In OSGi module compose of one or more bundles; Bundle is a normal jar file,the difference is its Manifest.mf file,OSGi add some specical header info property to declarative bundle,such as: bundle-version,export-package,import-package
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-4-1410 Publish functions for other bundles add export-package header info to provide package for other bundles to use,such as cn.org.osgi.ppt.service; add Fragment-Host header info to provide all resources for host bundle to use; publish OSGi service for other bundles; Use BundleContext.registerService to register normal java interface as OSGi service; Write xml with rule to declarative normal java class as OSGi component,and provide service interface for other bundles,such as:
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-4-1411 Use functions provided by other modules add import-package header info to import packages provided by other bundles,then you can use the java class in those packages; add require-bundle header info to use all export packages and resources provider by bundle; use OSGi service provided by other bundles; Use BundleContext.getService to get OSGi service provided by other bundles; Write xml with rule to declarative normal java class as OSGi component,and inject OSGi service provided by other bundles,such as:
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-4-1412 OSGi Basic Concepts Dynamic Bundle lifecycle OSGi component lifecycle Handle the dynamic – when bundle lifecycle changed; – when OSGi component lifecycle changed; – when configuration changed; – when framework changed; – when custom event published;
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-4-1413 Bundle lifecycle OSGi provide an API for manageing bundles lifecycle (Install/Resolve/Start/Stop/Refresh/Update/Unin stall),so OSGi framework RI will control bundle lifecycle self; INSTALLED RESOLVED UNINSTALLED ACTIVE STOPPING STARTING start stop
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-4-1414 OSGi component lifecycle Component that provide no service; when all need OSGi services(exclued optional service) are usable,the component will be actived; Component that provide services; when all need OSGi services(exclued optional service) are usable; other component call this OSGi service implemention.
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-4-1415 Handle the dynamic when bundle lifecycle changed; OSGi component lifecycle will change automatically; OSGi will handle bundle lifecycle dynamic self; when OSGi component lifecycle changed; OSGi service tracker can be used to monitor OSGi service; Declarative Services use bind-method,unbind-method to notify the dynamic of OSGi service. when configuration changed; Configuration Admin Service automatically notify the configuration change. when framework changed; FrameworkEventListener can be implemented to monitor framework. when custom event published; EventAdmin Service can to used to publish & handle custom event.
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-4-1416 OSGi Basic Concepts Extensionable Service filter supported by OSGi can be used to extension function; Multi service reference supported by OSGi can be used to extension function; Extension point provided by Equinox can be used to extension function.
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-4-1417 Agenda Play OSGi Who use OSGi What is OSGi OSGi R4 Implemention How to develop OSGi app OSGi Resources
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-4-1418 OSGi R4 Implemention Equinox Realized by Eclipse team; As the OSGi R4 RI; http://www.eclipse.org/equinox. Used by Eclipse RCP & Eclipse other products. Felix Realized by Apache Team; http://felix.apache.org.
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-4-1419 Agenda Play OSGi Who use OSGi What is OSGi OSGi R4 Implemention How to develop OSGi app OSGi Resources
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-4-1420 How to develop OSGi app Get started Write your first bundle Deploy & Manage first bundle Publish and use OSGi Service FAQ
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-4-1421 Get started Download Eclipse from www.eclipse.org Download Equinox bundles from www.eclipse.org/equinox www.eclipse.org/equinox most bundles exist in eclipse
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-4-1422 Write your first bundle New plugin-project,select this plug-in is targeted to run with an OSGi framework in project wizard page;
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-4-1423 Write your first bundle Then enter the plug-in content page Write associate info,then click finish to create the project.
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-4-1424 Write your first bundle Write activator class Say ‘hello’ when bundle started; Say ‘byebye’ when bundle stopped;
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-4-1425 Deploy & Manage first bundle Deploy in eclipse Deploy outside alone Manage bundle in console
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-4-1426 Deploy in eclipse Open run dialog,new in Equinox OSGi Framework, select Workspace Plug-ins and org.eclipse.osgi in Target platform;
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-4-1427 Deploy in eclipse Click Run button,then you can see this in console;
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-4-1428 Deploy outside alone Create equinox framework app outside alone first; create Equinox directory,then create configuration,plugins directory in Equinox directory; put org.eclipse.osgi.jar & org.eclipse.osgi.services.jar to plugins directory; create config.ini in configuration directory,content in config.ini like this: osgi.noShutdown=true osgi.bundles=org.eclipse.osgi.services_3.1.100.v20060601.jar@start osgi.bundles.defaultStartLevel=4 osgi.configuration.cascaded=false eclipse.ignoreApp=true create run.bat in Equinox directory,content in run.bat(windows) like this: @echo off java -jar plugins/org.eclipse.osgi_3.2.1.R32x_v20060919.jar - configuration configuration -console
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-4-1429 Deploy outside alone Start equinox framework and install first bundle in OSGi console; install first bundle use directory mode; – Input command like this in OSGi console: install file:/D:\work\workspace\OSGi-Bulletin\FirstBundle install first bundle use jar file; – package first bundle into jar file; – Export the project as deployable plug-ins and fragments – Input command like this in OSGi conosle: install file:/D:\Opendoc\Equinox\plugins\FirstBundle_1.0.0.jar
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-4-1430 Manage bundle in console use ss to find bundle id use start,stop,update,uninstall to manage bundle with bundle id start 2 (start bundle) stop 2 (stop bundle) update 2 (update bundle on the fly) uninstall 2 (uninstall bundle)
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-4-1431 Publish OSGi Service Use OSGi declarative services to publish and use OSGi Service,then when you run OSGi application,you need install Equinox DS plugin; Create ServiceBundle to publish OSGi service; Create cn.org.osgi.ppt.service.HelloService Interface; Create cn.org.osgi.ppt.component.HelloComponent to implemention HelloService; Publish HelloService as OSGi service using DS component xml; Add component.xml to MANIFEST.MF Service-Component property Export package cn.org.osgi.ppt.service
32
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-4-1432 Use OSGi Service Add cn.org.osgi.ppt.service to import-package; Use HelloService in firstbundle with two kind methods; context.getService method – In Activator class: ServiceReference serviceRef=context.getServiceReference(HelloService.class.getName()); if(serviceRef!=null){ HelloService service=(HelloService) context.getService(serviceRef); service.say("Activator"); } Declarative Services method –create cn.org.osgi.ppt.firstbundle.FirstComponent class with inject service method: public void setService(HelloService service){ this.service=service; } public void unsetService(HelloService service){ if(this.service!=service) return; this.service=null; System.out.println("HelloService 不可用 "); } –write ds component xml to inject OSGi service; –Add component.xml to MANIFEST.MF Service-Component property
33
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-4-1433 Agenda Play OSGi Who use OSGi What is OSGi OSGi R4 Implemention How to develop OSGi app OSGi Resources
34
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-4-1434 OSGi Resources OSGi R4 SpecificationsOSGi 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
35
Click to edit company slogan. OSGi China User Group
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.