将OSGi WAB用作战争中的资源包 [英] Using OSGi WAB as a Resource bundle inside a war

查看:92
本文介绍了将OSGi WAB用作战争中的资源包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在为内部开发的大量Web应用程序开发翻译服务.我面临的问题是,我们将所有应用程序都打包了包含不同语言的属性文件,以提供i18n支持.

I'm currently in the process of developing a translation service for a host of web applications that was developed in house. I'm faced with the problem where we have packed all of the applications with properties files containing different languages to have i18n support.

在头脑风暴会议上提出的建议之一是使翻译服务成为OSGi模块.问题是我对OSGi经验为0,不知道该怎么做.进一步的讨论和谷歌搜索建议将服务开发为WAB.

One of the things that was suggested during a brain storming session was to make a translation service an OSGi module. Problem is I have 0 experience with OSGi and don't know how to go about it. Further talks and googleing suggests developing the services as a WAB.

我面临的问题是如何从WAB调用资源?完全有可能还是我走错了路?

The problem I am faced with is how do I call a resource from a WAB? Is it possible at all or am I going in the wrong path?

任何帮助都将非常合适.

Any help would be greatly appropriated.

问候

推荐答案

在不知道更多细节的情况下很难肯定地说,但是您可能想使用wab代替战争,而不是战争.摇晃只是与osgi元数据的战争.一个很好的国际化方法(我想是这个主意出现的原因)是对资源包使用片段. 本文的教程均涉及开发wab然后添加片段以进行国际化.

It's hard to say for sure without knowing more details, but you probably want to use a wab instead of a war, rather than inside of a war. A wab is just a war with osgi metadata. A nice approach for internationalisation (and the reason the idea came up, I'm guessing) is to use fragments for the resource bundles. This article has a tutorial of both developing a wab and then adding fragments for internationalisation.

我还建议不要尝试直接从osgi捆绑包加载资源,因为osgi封装通常会使资源不可访问,除非您对软件包的导入和导出进行了难看的事情.相反,请查找服务并使其进行资源加载.使用声明式服务或蓝图之类的东西比编程服务访问要容易得多.

I'd also advise against trying to load resources directly from an osgi bundle, since osgi encapsulation often makes the resources inaccessible unless you do ugly things with package imports and exports. Instead, look up a service and have it do the resource loading. Using something like declarative services or blueprint is much easier than programmatic service access.

这篇关于将OSGi WAB用作战争中的资源包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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