- 仔细阅读下列文章,并实际动手:
Equinox in a Servlet Container说明文档(教程)
Http Service Servlets扩展点帮助
Eclipse, Equinox, and OSGi(有图)
Building Server-Side Eclipse based web applications 2010(PPT)
- :pserver:anonymous@dev.eclipse.org:/cvsroot/rt
org.eclipse.equinox/server-side/
- 下载依赖插件
org.eclipse.equinox.http.servletbridge
org.eclipse.equinox.servletbridge
org.eclipse.equinox.servletbridge.extensionbundle
- 发布参考
org.eclipse.equinox.server.examples.servletbridge.product
org.eclipse.equinox.server.servletbridge
- 创建插件工程,继承HttpServlet开发自己的Servlet类
- 继承ServiceTracker,在自己的类中注册第3步开发的servlets
- 在插件激活的时候创建并打开第4步开发的tracker
- 发布和激活相关的插件(通过配置和使用product文件)
发布到tomcat\webapps\<mywebapp>\WEB-INF\
该文件夹内容除了标准的plugins、features、configuration外,还会有lib、.eclipseproduct、launch.ini和web.xml
- 开http服务测试
- 其余要注意的点:
- 清tomcat\work目录里缓存的相应内容
- 清webapps目录相应 WEB-INF 里的内容
- 导出webapp.product时,在向导页面配置:
- Root directory为空
- 去掉Synchronize before exporting的勾勾
- Directory直接配置为WEB-INF目录,如:\apache-tomcat-6.0.29\webapps\mywebapp\WEB-INF
- 去掉Generate metadata repository的勾勾
- 点Finish
- 启动tomcat后,用ss查看所有插件(除了fragments)是否都是ACTIVE状态
不是的话,在product文件Configuration里配置Auto-Start为true
- webapp需要的插件,feature.xml里全要自己手工加上
注意参考equinox cvs仓库里的例子,另外可以借用webapp.product生成一个列表来参考
- 调试:
- 解压eclipse插件开发环境,然后解压eclipse jee开发环境覆盖
- 添加tomcat服务器,然后把webapp配置到服务器上
- 在servlet里下断点,启动服务器调试即可