简体   繁体   English

GlassFish如何成为OSGi容器?

[英]How is GlassFish an OSGi container?

In researching OSGi and OSGi containers, I stumbled across this SO question mentioning GlassFish as an OSGi container, and I have to say I'm quite baffled. 在研究OSGi和OSGi容器时,我偶然发现了这样一个问题,提到将GlassFish作为OSGi容器,我不得不感到困惑。

How is this possible?!?! 这怎么可能?!?!

My understanding was that OGS - a Java-compliant app server - has 2 containers: 我的理解是OGS(一种Java兼容的应用服务器)具有2个容器:

  • Web Container: where you deploy WAR files for web apps and services Web容器:在其中部署Web应用程序和服务的WAR文件
  • App Container: where you deploy EJBs for business logic 应用程序容器:您在其中部署EJB的业务逻辑

Where do OSGi bundles fit into this paradigm?!? OSGi捆绑软件在哪里适合这种范例?! Does OGS allow you to deploy an OSGi bundle to the app container and treat it like an EJB or something? OGS是否允许您将OSGi捆绑软件部署到应用容器并将其像EJB一样对待? And if I'm mistaken about how OGS works please correct me! 如果我对OGS的工作方式有误,请纠正我! Thanks in advance! 提前致谢!

OSGi is a module system that allows to add/remove/upgrade different bundles, handles dependencies, provides runtime information on the status, etc. OSGi是一个模块系统,允许添加/删除/升级不同的包,处理依赖关系,提供有关状态的运行时信息等。

When it comes to GlassFish (which has an Apache Felix OSGi container in it), the different features of the application server (eg HTTP server, JMS server, etc.) are implemented as bundles. 当涉及GlassFish(其中具有Apache Felix OSGi容器)时,应用程序服务器(例如HTTP服务器,JMS服务器等)的不同功能被实现为捆绑软件。 There is console and web based interface for the OSGi container where you can start, install, remove services (see the PDF below) OSGi容器具有基于控制台和基于Web的界面,您可以在其中启动,安装和删除服务(请参见下面的PDF)

As far as Java EE applications go, they can interact with the OSGI container too. 就Java EE应用程序而言,它们也可以与OSGI容器进行交互。 For example, an EJB can be exported as an OSGi service and also the EJB can consume an OSGi service itself. 例如,可以将EJB导出为OSGi服务,并且EJB也可以使用OSGi服务本身。

For more info, see http://glassfish.java.net/public/GF-OSGi-Features.pdf 有关更多信息,请参见http://glassfish.java.net/public/GF-OSGi-Features.pdf

Hmm, a rather total misunderstanding of what OSGi is ... 嗯,对OSGi是什么完全误解了...

OSGi is a framework that allows you to organize your code so that you can built it from reusable components that can then collaborate through the service layer (no more Class.forName or XML!). OSGi是一个框架,允许您组织代码,以便可以从可重用的组件中构建代码,这些组件随后可以通过服务层进行协作(不再需要Class.forName或XML!)。

OSGi frameworks can run standalone, they run inside an application, the can run in a WAR file, and they can run inside an application server. OSGi框架可以独立运行,可以在应用程序中运行,可以在WAR文件中运行,并且可以在应用程序服务器中运行。 And you can even run OSGi inside OSGi inside OSGi since it does not rely on statics anywhere. 您甚至可以在OSGi中的OSGi中运行OSGi,因为它不依赖于任何静态变量。

The OSGi Alliance specifies a format for the modules (bundles) so that modules can specify their dependencies. OSGi联盟指定模块(捆绑包)的格式,以便模块可以指定其依赖性。 The Alliance also specifies an API to install and manage modules. 联盟还指定了用于安装和管理模块的API。 And last, it specifies a large number of interfaces that are useful when you develop applications. 最后,它指定了大量在开发应用程序时有用的接口。

Websphere, Glassfish, JBoss, Jonas, all support deploying OSGi bundles. Websphere,Glassfish,JBoss和Jonas均支持部署OSGi捆绑软件。

Glassfish internally uses OSGi to provide the features you mentioned. Glassfish在内部使用OSGi提供您提到的功能。 Besides that you can deploy your own OSGi bundles on it. 除此之外,您可以在上面部署自己的OSGi捆绑软件。 See https://wikis.oracle.com/display/GlassFish/OSGi There is no real connection between OSGi and Java EE though. 请参见https://wikis.oracle.com/display/GlassFish/OSGi尽管OSGi与Java EE之间没有真正的联系。 You can not yet use JavaEE in OSGi bundles on Glassfish. 您还不能在Glassfish的OSGi捆绑软件中使用JavaEE。 For this case there are first initiatives like Weld on OSGi: http://www.slideshare.net/TrevorReznik/weldosgi-injecting-easiness-in-osgi They are not really production ready though. 对于这种情况,有一些像OSGi上的Weld这样的倡议: http ://www.slideshare.net/TrevorReznik/weldosgi-injecting-easiness-in-osgi尽管它们还没有真正做好生产准备。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM