gpt4 book ai didi

java - OSGI 中的 Websocket 客户端

转载 作者:行者123 更新时间:2023-11-29 08:41:12 25 4
gpt4 key购买 nike

我目前已经使用 tyrus 客户端实现了 websocket 客户端,并且 websockets 客户端在 OSGI 环境之外可以正常工作。

问题是 websocket 不能在 apache karaf 上运行。我已经安装了 websocket 客户端的所有依赖项。列表是

 ID | State     | Lvl | Version        | Name
------------------------------------------------------------------------------------
52 | Active | 80 | 4.3.0 | Apache Felix Dependency Manager
96 | Active | 80 | 1.0 | WebSocket server API
97 | Active | 80 | 1.1.0 | Tyrus Server
98 | Active | 80 | 1.1.0 | Tyrus Core
99 | Active | 80 | 1.1.0 | Tyrus Container SPI
100 | Active | 80 | 1.1.0 | Tyrus WebSocket Core
102 | Active | 80 | 1.1.0 | Tyrus Grizzly Container
103 | Active | 80 | 2.3.3 | grizzly-framework
104 | Active | 80 | 2.3.3 | grizzly-http
105 | Active | 80 | 2.3.3 | grizzly-http-server
106 | Active | 80 | 2.3.3 | grizzly-rcm
118 | Active | 80 | 1.0.8 | Apache Aries SPI Fly Dynamic Weaving Bundle
134 | Active | 80 | 1.1.0 | Tyrus Client
135 | Installed | 80 | 1.0.0.SNAPSHOT | rna-websocket-client

tyrus客户端通过ServiceLoader提供实现。所以我使用 Apache Aries SPI Fly Dynamic Weaving Bundle 来实现。但我仍然收到Could not find an implementation class. 错误。

经过调查,我发现 tyrus 客户端没有添加

Provide-Capability: osgi.serviceloader; osgi.serviceloader="javax.websocket.ContainerProvider"

到 list ,需要通知处理包有关所提供服务的信息。在我的 rna-websocket-client 包中,我添加了

<Require-Capability>osgi.serviceloader; filter:="(osgi.serviceloader=javax.websocket.ContainerProvider)";cardinality:=multiple,osgi.extender; filter:="(osgi.extender=osgi.serviceloader.processor)"</Require-Capability>.

这将需要通知 aries 动态编织包我们使用 javax.websocket.ContainerProvider 服务。

这是在 OSGI 中运行 websockets 的正确方法,还是有任何其他方法在 OSGI 中运行 websockets?对这个问题的任何见解都会非常有帮助。

最佳答案

有一个explanation how to use websockets with jetty在 bndtools。也许这会有所帮助。

关于java - OSGI 中的 Websocket 客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40172546/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com