Java OSGi 集中网络配置
我正在寻找基于 OSGi 模型创建一个应用程序。其中一个要素是网络访问(最初是 http 和 obr),
我正在寻找一种将网络配置(代理、加密等)集中到一个捆绑包中的方法,以便应用程序的其余部分可以调用。
有人做过这个/有想法吗?
谢谢
I'm looking to create an app based on the OSGi model. One of the elements of this will be network access (http and obr initially)
I am looking for a way of centralising the network config (proxying, encryption, etc) perhaps to a single bundle that the rest of the app can call into.
Has anybody done this/got ideas?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这种情况下,一种可能性是创建一个 OSGi 服务或一组服务(可能封装在一个单独的包中)来提供所有必需的网络访问方法。服务本身可以通过 进行配置配置管理服务是OSGi Service Compendium的一部分。
服务提供的一些方法实际上可以是用于创建预配置网络访问对象的工厂方法,例如 java.net.URLConnection 或 java.net.Socket。例子:
In that case one possibility would be to create an OSGi service or a set of services (possibly encapsulated in a separate bundle) that would provide all the required network access methods. The service(s) themselves could be configured through Configuration Admin Service that is part of OSGi Service Compendium.
Some of the methods provided by the service(s) can actually be factory methods for creating pre-configured network access objects like java.net.URLConnection or java.net.Socket. Example: