部署ZK到OSGi框架
TOC
March
New Features of ZK Studio 1.0.2 Integrate ZK5 with Spring 3 and Hibernate
?
?
Open MANIFEST.MF file to modify the OSGi Bundle attributes- Click Runtime tab. In Classpath panel, add all jars in lib folder. In Export Packages add all packages that zk jars provided, include non-java packages.






With BndTools, we can convert ZK jars into OSGi bundle quickly, and it will prepare import packages automatically, where with Eclipse Plug-in Project we need to specify import packages by ourselves. However, one thing to note is that with BndTools we have to wrap ZK jar files one by one because the Export Packages are duplicate due to duplicated package name, such as metainfo.zk.
Export the project by Eclipse Deployable plug-ins and fragments wizard. The final project structure:


web:list
1osgi:restart BundleID
EclipseRT Virgo The Virgo Web Server from EclipseRT is a completely module-based Java application server that is designed to run enterprise Java applications and Spring-powered applications with a high degree of flexibility and reliability. It offers a simple yet comprehensive platform to develop, deploy, and service enterprise Java applications.[5]
Steps to deploy the project- Download EclipseRT Virgo from http://eclipse.org/virgo/download/.Follow the user guide to install and start the server.Open the Web Admin Console via http://localhost:8080/admin with default account/password(admin/springsource)Follow the bundle installation guide hereDeploy the three bundles one by one with the following sequence.zkee-osgi_5.0.10.jarosgi.demo.data_1.0.0.jarosgi.demo.webview_1.0.0.jarVisit http://localhost:8080/osgidemo/index.zul to see the result.
The OSGi standard provides powerful modularization and version control which I think is very convenient for developers to control the bundle versions with various functions, and can help developers to design the skeleton of the project with loose coupling. Also it reduces the time for restarting the server during development phase. Following this article you should be able to convert ZK jar files into OSGi bundles and start your first OSGi-supported application.
DownloadDownload the sample bundles:
zkee-osgi_5.0.10.jarosgi.demo.data_1.0.0.jarosgi.demo.webview_1.0.0.jar Reference- ↑ Erko Knoll's article: Small_Talks/2011/December/ZK_OSGi_-_Developing_plug-in_based_applications_with_OSGi↑ Some OSGi containers will read Webapp-Context attribute instead of reading standard Web-ContextPath attribute so here we define both attributes for compatibility.↑ Eclipse Equinox: http://eclipse.org/equinox/ Eclipse↑ Apache ServiceMix: http://servicemix.apache.org/↑ EclipseRT Virgo: http://eclipse.org/virgo/