问题描述
请就如何做Java Web应用程序插件的架构一种提醒。
Please give an advise on how to do "plugin" architecture for Java web application.
目前,我们正在使用相当简单和标准的Spring + Hibernate的+ Struts的2 Tomcat servlet容器。 (内置与Maven)
Currently we are using quite simple and standard Spring+Hibernate+Struts 2 in Tomcat servlet container. (Built with maven)
我需要像。凡任何模块都可以启用/禁用,更新
I need something like Redmine. Where any module can be enabled/disabled, updated
请排除重选项,如OSGi的,Portlet的。
Please exclude heavy options like OSGi, Portlet.
- OSGi是太重了,没有什么好采用该技术的网络的。我已经看了看;
- 的只是老了,从来没有流行。
- OSGi is too heavy, there is no good adoption of the technology for web. I already looked at Eclipse Germini;
- Portlet it just old, and never was popular.
推荐答案
我会尽量提供一些可能的解决方案。我没有花费我工作的项目有一段时间preparing小型概念验证,所以我们希望下面的选项是相关的。
I will try to provide several possible solution. I did spent some time preparing small PoCs for the project I'm working on, so let's hope the options below are relevant.
重要提示:它是很容易定义一些扩展点,不要解决,找到可用的实现。有很多可用的解决方案,例如好,简单的 -
Important note: it is really easy to define some extension point, do resolve and find available implementations. There are a lot of solutions available, for example good and simple one -- JSPF
资源是Web应用程序的主要问题
的OSGi
OSGi的,是不是坏的,可能是有用的。这似乎是重(以及一些实现是沉重的),但是这是标准化的平台的价格。我建议检查。它可以在一个轻量级模式下使用。顺便说一句,它包括Web控制台是建立松散耦合的基于插件的应用程序,可能会有所帮助:
OSGi, is not that bad and can be useful. It seems to be heavy (and some implementations are heavy) but this is price of standardized platform. I would suggest to check Apache Felix. It can be used in a "lightweight" mode. By the way, it includes Web Console which is build as loosely coupled plugin-based application, could be helpful:
一些例子扩展Apache的菲利克斯Web控制台
Web控制台可以通过注册一个OSGi服务扩展
与服务属性界面javax.servlet.Servlet
felix.webconsole.label设置为标签(最后一段中的网址)
这一页。各自的服务被称为Web控制台插件或
插件短。
您还可以查看是干净和简单,并使用OSGi的管理插件。可能是你一个很好的例子。
You can also check eie-manager which is clean and simple and uses OSGi to manage plugins. Could be a good example for you.
自定义插件框架
我会建议检讨背后的解决方案。我会说詹金斯插件系统非常成熟,可靠。可以作为一个很好的例子。
I would suggest to review solution behind Jenkins/Hudson. I would say Jenkins plug-in system is quite mature and reliable. Can be used as a good example.
另外,也请
简单的解决方案
有关我的项目,我已经根据与构建插件抽象层自定义依赖解析器。
For my project I've build plugin abstraction layer based on JSPF with custom dependency resolver.
优点:
- 简单的小
- 廉洁理念
- 做工不错
缺点:
- 如果没有适当的插件管理可能会很慢(全类路径搜索)
- 提供了非常基本的功能
- 可能需要额外注意
我会建议使用只有当你确实需要一些简单,想控制一切。 提供了很多有趣的功能开箱即用,例如:
I would suggest to use JSPF only if you really need some simplicity and want to control everything. JPF provides a lot of interesting features out of the box, for example:
插件可以热注册,并在偶数非注册
执行应用程序。更重要的是,注册插件即可
激活对飞停用,最大限度地减少运行时资源
用法。
问题是JPF已经死了。
The problem is JPF is dead.
建议
做花一些时间与。它是足够成熟,所以你的时间投资可能回报了不少。
Do spend some time with Apache Felix. It is mature enough, so your time investments may pay back a lot.
这篇关于Java Web应用程序"插件"建筑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!