在eclipse中配置基于OSGi的webx项目
From Tuscany中文社区
本文讨论如何在eclipse中开发基于OSGi的WebX 我将分5步介绍一个完成的可运行的项目:
目录 |
[编辑] 创建jetty服务器
直接创建一个OSGi Framework类型的运行项 在(右侧)的Bundles里面,去掉不相关的bundle,保留以下:
org.apache.commons.logging 版本1.0.4.v200706111724 javax.servlet 版本2.4.0.v200706111738 org.eclipse.equinox.http.jetty 版本1.0.1.R33x_v20070816 org.eclipse.equinox.http.servlet 版本1.0.1.R33x_v20070816 org.eclipse.osgi 版本3.3.1.R33x_v20070828 org.eclipse.osgi.services 版本3.1.200.v20070605 org.mortbay.jetty 版本5.1.11.v200706111724
以上都是eclipse3.3自带的bundle。
[编辑] 添加spring-osgi环境
下载spring dynamic module,当前版本是1.0-rc2。将以下jar放到eclipse/plugins目录下。
spring-osgi-core-1.0-rc2.jar spring-osgi-io-1.0-rc2.jar spring-osgi-extender-1.0-rc2.jar
下载spring,当前版本2.5.1,将以下jar放到eclipse/plugins目录下。
spring-beans-2.5.1.jar spring-aop-2.5.1.jar(依赖aopalliance.osgi-1.0-SNAPSHOT.jar) spring-core-2.5.1.jar spring-context-2.5.1.jar
重启eclipse,并在运行选项中钩选新添加的这些bundle。
[编辑] 下载org.eclipse.equinox.http.helper
- CVS下载地址:(请在命令行方式下执行下面的CVS命令)
cvs -d :pserver:anonymous@dev.eclipse.org/cvsroot/eclipse co equinox-incubator/org.eclipse.equinox.http.helper
- 本站下载
org.eclipse.equinox.http.helper
用Import->Existing Project into Workspace来将下载的代码“目录”输入为一个plugin project。
[编辑] 创建web层应用bundle
接下来,我创建一个plugin project,取名为book.web,该bundle不需要Activator,其职责将是这个应用的web层的内容,包括jsp,struts,action,以及css,js等。
注意:创建plugin项目的时候,务必将“target platform”选择为“an OSGi framework”,否则bundle将会被描述为依赖不必要的eclipse的bundle,另外,在“plug-in options”部分,取消创建Activator,但是这个问题不会导致过分的问题。
- 动态加载一个web应用
[编辑] 创建服务层bundle
接下来,我继续创建一个plugin project,取名为book.service,该bundle也不需要Activator,其职责是提供服务层的内容,暂时不包括hibernate,包括service对象和置空的服务方法。

