Java Web 应用程序“插件"建筑学 [英] Java Web application "plugin" architecture

查看:31
本文介绍了Java Web 应用程序“插件"建筑学的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请提供有关如何为 Java Web 应用程序做插件"架构的建议.

目前我们在 Tomcat servlet 容器中使用非常简单和标准的 Spring+Hibernate+Struts 2.(用maven构建)

我需要类似 ;

  • <块引用>

    Web 控制台可以通过注册 OSGi 服务来扩展接口 javax.servlet.Servlet 与服务属性felix.webconsole.label 设置为的标签(URL 中的最后一段)这一页.相应的服务称为 Web 控制台插件或简称插件.

    您还可以查看

    简单的解决方案

    对于我的项目,我构建了基于 JSPF 的插件抽象层和自定义依赖项解析器.

    优点:

    • 简单小巧
    • 干净的概念
    • 效果很好

    缺点:

    • 没有适当的插件管理可能会很慢(完整的类路径搜索)
    • 提供非常基本的功能
    • 可能需要额外注意

    我建议仅在您确实需要一些简单性并想要控制时才使用 JSPF一切.JPF 提供了很多开箱即用的有趣功能,例如:

    <块引用>

    插件可以热注册",甚至可以在期间取消注册应用程序执行.更重要的是,注册插件可以即时"激活和停用,最大限度地减少运行时资源用法.

    问题是 JPF 已死.

    建议

    一定要花一些时间使用 Apache Felix.它足够成熟,因此您的时间投资可能会得到很多回报.

    Please give an advise on how to do "plugin" architecture for Java web application.

    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

    Please exclude heavy options like OSGi, Portlet.

    • 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.

    解决方案

    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

    Resources are the main problem for WEB applications

    OSGi

    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:

    Some examples Extending the Apache Felix Web Console

    The Web Console can be extended by registering an OSGi service for the interface javax.servlet.Servlet with the service property felix.webconsole.label set to the label (last segment in the URL) of the page. The respective service is called a Web Console Plugin or a plugin for short.

    You can also check eie-manager which is clean and simple and uses OSGi to manage plugins. Could be a good example for you.

    Custom plugin framework

    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.

    Please also check Hudson Plugin Architecture

    Simple solution

    For my project I've build plugin abstraction layer based on JSPF with custom dependency resolver.

    PROS:

    • simple and small
    • clean concept
    • works good

    CONS:

    • without proper plugin management can be slow (full classpath search)
    • provides very basic functionality
    • may require additional attention

    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:

    Plug-ins can be "hot-registered" and even de-registered during application execution. What's more, registered plug-ins can be activated and deactivated "on the fly", minimizing runtime resource usage.

    The problem is JPF is dead.

    Suggestion

    Do spend some time with Apache Felix. It is mature enough, so your time investments may pay back a lot.

    这篇关于Java Web 应用程序“插件"建筑学的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆