简体   繁体   English

您可以在不同的 OSGi 包中拥有 JSF 自定义组件吗?

[英]Can you have JSF custom components in different OSGi bundles?

Has anyone used OSGi and JSF together?有没有人一起使用过 OSGi 和 JSF?

I ask because JSF uses class-loader magic to find custom components.我问是因为 JSF 使用类加载器魔法来查找自定义组件。 From a tutorial (emphasis mine):从教程(强调我的):

This configuration file will end up being META-INF/faces-config.xml in the .jar file that represents this component.此配置文件最终将是代表此组件的 .jar 文件中的 META-INF/faces-config.xml。 JSF will look for such a file name in each of the .jar files that are loaded at runtime (in the WEB-INF/lib directory for .war files) and use each of them in its configuration. JSF 将在运行时加载的每个 .jar 文件(在 WEB-INF/lib 目录中用于 .war 文件)中查找这样的文件名,并在其配置中使用每个文件名。 In this way, multiple component .jar files can be combined into one web application, and all of the components described in each .jar will be available to the application.通过这种方式,可以将多个组件 .jar 文件组合成一个 Web 应用程序,并且每个 .jar 中描述的所有组件都可用于该应用程序。

I would like to be able to have JSF custom components as OSGi bundles (ie custom components are in different OSGi bundles than the JSF runtime) and for JSF to be able to find these at runtime.我希望能够将 JSF 自定义组件作为 OSGi 包(即自定义组件位于与 JSF 运行时不同的 OSGi 包中)并且让 JSF 能够在运行时找到这些组件。

Has anyone done anything similar?有没有人做过类似的事情?

I am not sure it does exactly answer your problem, but I found this thread about Spring and osgi interresting, especially thisspecific answer where dependencies and classpath are bundled in the MANIFEST.MF.我不确定它是否完全回答了您的问题,但我发现这个关于Spring 和 osgi interresting 的线程,尤其是这个特定的答案,其中依赖项和类路径捆绑在 MANIFEST.MF 中。

That thread also leads to the update of this for tutorial about Spring Dynamic Modules (DM) for OSGi™ Service Platforms which may also be of interest.该线程还导致了有关 OSGi™ 服务平台的 Spring 动态模块 (DM) 教程的更新,这也可能引起您的兴趣。

It is possible in the following way:可以通过以下方式:

  • Your web osgi bundle has to have "Require-Bundle" in MANIFEST.MF pointing to the bundle that contains the components您的 web osgi 包必须在 MANIFEST.MF 中有“Require-Bundle”指向包含组件的包
  • Your component jar has to have Export-Package containing META-INF and subpackages of META-INF where there is any JSF related file (and of course standard packages of the component).您的组件 jar 必须具有包含 META-INF 和 META-INF 子包的导出包,其中有任何 JSF 相关文件(当然还有组件的标准包)。 For example: Export-Package: META-INF,META-INF.resources...例如:Export-Package: META-INF,META-INF.resources...

If you use maven-bundle plugin you must use an apostrophe and an equal for exporting META-INF and sub-packages.如果您使用 maven-bundle 插件,则必须使用撇号和等号来导出 META-INF 和子包。 For example:例如:

<Export-Package>
  a.b.c,
  '=META-INF',
  '=META-INF.resources',
  ...
</Export-Package>

In JSF Spec 2.2 there might be parts about JSF-OSGI relationship.在 JSF Spec 2.2 中可能有一些关于 JSF-OSGI 关系的部分。 To see the progress see http://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-942要查看进度,请参阅http://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-942

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

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