难以理解整个 OSGi Web 生态系统
我对整个 Java 和 OSGi 世界还很陌生,并且很难理解 OSGi Web 应用程序的生态系统。
更准确地说,我目前正在尝试了解生态系统的所有部分是如何相互关联的:
- OSGi 框架(例如 Apache Felix、Equinox、Knoplerfish)
- OSGi 运行时(例如 Spring DM Server、Pax Runner、Apache Karaf) )
- Web Extender(例如 Pax Web Extender、Spring Web Extender)
- Web 容器(例如 Apache Tomcat、Jetty)
为了让您直观地了解我对它们关系的实际理解,请查看此图片:
据我所知,OSGi 框架是 OSGi 规范的实现。运行时是一个发行版,它在 OSGi 规范之上添加了附加功能,例如日志记录。由于 OSGi 和 Web 容器(如 Tomcat)的类路径机制似乎存在一些差异,因此您需要某种转换器。这部分由“Web Extender”处理。
您能帮我澄清一下整个事情吗?我对一切的理解正确吗?
I am pretty new to the whole Java and OSGi world and I have trouble understanding the eco system of a OSGi web application.
To be more precise I am at the moment trying to understand how all the parts of the eco system are related to each other:
- OSGi Framework (e.g. Apache Felix, Equinox, Knoplerfish)
- OSGi Runtime (e.g. Spring DM Server, Pax Runner, Apache Karaf)
- Web Extender (e.g. Pax Web Extender, Spring Web Extender)
- Web Container (e.g. Apache Tomcat, Jetty)
To give you a visual representation of my actual understanding of their relationship check out this image:
As far as I know the OSGi Framework is a implementation of the OSGi specification. The runtime is a distribution which adds additional functionality on top of the OSGi specification like logging for instance. Since there seem to be some differences in the classpath mechanism of OSGi and web containers like Tomcat you need some kind of translator. This part is handled by the "Web Extender".
Would you please clarify this whole thing for me? Am I understanding everything correct?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
OSGi 是交互软件模块的 API 和封装方面的标准。这与 JPA 或 Java EE 等其他 API 标准类似。
OSGi运行时是遵循OSGi标准的服务器,它是该标准的实现。您提到了一些常见的:Knopflerfish、Equinox。这些让您可以运行 OSGi 包。
Web 容器通常指 Java EE (servlet) 的 Web 特定部分的实现。 Servlet 标准也定义了 API 和封装,就像 OSGi 一样,只是不同。
您需要一台服务器来运行 Java EE Web 应用程序。您将应用程序打包为 Java Web Archive (WAR),并要求应用程序服务器启动它。正如您提到的,有多种服务器,例如 Tomcat、Jetty,但也有更大的服务器,涵盖了 Java EE 标准的大部分内容,例如 Glassfish 和 JBoss。
Web 扩展器试图将 servlet 标准与 OSGi 统一起来。通过将一些特定于 OSGi 的数据添加到已打包的 WAR 中,WAR 将由 OSGi 运行时自动解析并启动。您的 WAR servlet 将由 Web 扩展器发布到 OSGi http 服务。借助 Web 扩展器,您可以仅使用 OSGi 运行时来运行标准 OSGi 应用程序和 WAR,而无需 Tomcat 等符合 Java EE 的服务器。
OSGi is a standard in terms of API and packaging for interacting software modules. This is similar to other API standards like JPA or Java EE.
An OSGi runtime is a server which follows the OSGi standard, it is an implementation of the standard. You mention some common ones: Knopflerfish, Eqinox. These let you run OSGi bundles.
A web container usually refers to an implementation of the web-specific parts of Java EE (servlets). The servlet standard also defines an API and packaging, just like OSGi, only different.
You need a server to run your Java EE web apps. You package your app as a Java Web Archive (WAR), and ask your application server to start it. There are several servers, as you mention, like Tomcat, Jetty, but also bigger servers which cover larger parts of the Java EE standard, like Glassfish and JBoss.
A web extender tries to unify the servlet standard with OSGi. By adding some OSGi-specific data to your already packaged WAR, the WAR will be automatically parsed and started by your OSGi runtime. Your WAR servlets will be published to the OSGi http service by the web extender. With a web extender, you can run both standard OSGi applications as well as WARs using only a OSGi runtime, without the need for a Java EE-compliant server like Tomcat.
Jens,
由于我对 OSGi 有一些经验,我真的不建议您从普通的 OSGi 开始。
请从 Eclipse RCP(富客户端平台) 开始。
如果您下载适用于 RCP 和 RAP 开发人员的 Eclipse IDE,您不仅可以获得 OSGi 运行时,而且可以获得功能齐全的集成 IDE版本在这里。
幸运的是,您可以获得Eclipse Rich Client Platform(第二版) 该文件仅在几个月前发布,包含有关 Eclipse RCP 的更新信息/指南。
OSGi 是 Eclipse RCP 的基本构建块,但是 OSGi 本身令人困惑且无聊(至少对于初学者而言)。掌握 Eclipse RCP 的速度变得更加容易和愉快,您可以在几个小时内构建一个功能性的“做某事”应用程序。
对于普通的 OSGi,如果您能够在最初几天内消除 ClassNotFound 异常,那么您已经很幸运了。
使用 Eclipse RCP 一段时间后,将您的应用程序“转换”为 Eclipse RAP 以将其作为 Web 运行Java servlet 容器上的应用程序。看看您是否喜欢它,即使您不喜欢...此时您已经掌握了 OSGi 概念和操作。实践表明,与从头开始相比,您向“普通 OSGi”的航行会更顺利一些。
祝詹斯好运!
PS 我还在 我的 Java EE 博客 上写过这些内容,尽管并不总是专门针对 OSGi 。
Jens,
As I have some experience with OSGi, I really would not suggest you start with plain OSGi.
Start with Eclipse RCP (Rich Client Platform) instead.
You not only get a OSGi runtime, but a full-featured integrated IDE if you download Eclipse IDE for RCP and RAP Developers edition here.
Lucky for us all, you can get the book Eclipse Rich Client Platform (2nd Edition) which was recently released only a few months ago and contains updated info/guide on Eclipse RCP.
OSGi is the fundamental building blocks of Eclipse RCP, however OSGi by itself is confusing and boring (at least for starters). Getting up to speed on Eclipse RCP is much easier and enjoyable, you can build a functional "do-something" app within hours.
With plain OSGi, you'd already be lucky if you can get rid of ClassNotFound exceptions within the first few days.
After some time with Eclipse RCP, "convert" your app to Eclipse RAP to run it as a web application on a Java servlet container. See if you like it, even if you don't... by this time you'd have already grasped the OSGi concepts & practices that your sailing to "plain OSGi" would be somewhat smoother than if you had started from scratch.
Good luck Jens!
P.S. I also write about this stuff on my Java EE blog, though not always specifically on OSGi.