如何使用 OSGi 开发客户端-服务器系统?

发布于 2024-10-31 09:57:43 字数 224 浏览 3 评论 0原文

最近几天我正在学习如何使用OSGi进行开发,但面临很多问题。

我不知道如何设计基于 OSGi 并以 Equinox 作为框架的客户端-服务器系统。我应该使用套接字连接来实现这个还是使用分布式模型?

我也很困惑是否需要导入一些第三方包来支持我在套接字、jdbc、swing 等上的编程,或者是否有 Equinox 或其他 OSGi 开源项目提供的现有包?

第一次在这里提问,谁能帮帮我吗?

I'm learning how to develop with OSGi in recent days, but facing a lot of problems.

I don't know how to design my client-server system based OSGi with Equinox as framework. Should I use socket connections to implement this or use a distributed model?

I'm also confused whether I need to import some third party packages to support my programming on socket, jdbc, swing, etc, or there're existing packages offered by Equinox or other OSGi open source projects?

First time to ask questions here, can anybody help me?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

鹿! 2024-11-07 09:57:43

只需看一下 OSGi 远程服务实现(更多详细信息请参阅 OSGi 规范):

干杯,

Dmytro

just take a look at OSGi Remote services implementations (more details in OSGi spec):

Cheers,

Dmytro

十二 2024-11-07 09:57:43

与基于低级套接字处理和二进制协议的协议相比,HTTP 模型可能是最容易实现的。

我要问的第一个问题是您的客户端和服务器需要交换什么样的信息。如果您可以接受 HTTP(在很多情况下您可以),那么您可以只在服务器端使用 servlet,在客户端使用 http 客户端库以及 RESTful 通信模型。

使用 HttpService 在 OSGi 中很容易实现 Servlet,请参见示例 http://www.osgilook.com/2009/09/08/osgi-http-service-registering-servlets-on-the-fly/

The HTTP model is probably the simplest to implement, as opposed to protocols based on low-level socket handling and binary protocols.

The first question I'd ask is what kind of information your clients and server need to exchange. If you can live with HTTP (and in many cases you can), you can just use servlets on the server-side, http client libraries on the client side and a RESTful communications model.

Servlets are easy to implement in OSGi using the HttpService, see for example http://www.osgilook.com/2009/09/08/osgi-http-service-registering-servlets-on-the-fly/

遮了一弯 2024-11-07 09:57:43

在 OSGi 中使用套接字并不比在“普通”Java 中复杂。您设计应用程序的方式与通常的方式大致相同,但通过使用 OSGi 可以获得模块化和服务的好处。

例如,您可以通过引入诸如 WorkerFactory 之类的东西来解耦连接接受和请求处理,或者可以在客户端和服务器上重用服务;这些都是 OSGi 所擅长的。

OSGi 作为一种“技术”(就该概念成立而言)并不强制要求任何特定的交互方法。纲要规范提到了远程服务(又名分布式 OSGi),但它还包含 HTTP 服务规范,Servlet 就是您的事。

简而言之,只需选择最适合您场景的交互解决方案,让 OSGi 帮助您提供服务和模块化。

Working with sockets is not more or less complicated in OSGi than it is in 'plain' Java. You design your application in much the same way as you would normally, but gain the benefits of modularity and services by using OSGi.

You could, for instance, decouple connection acceptance and request handling by introducing something like a WorkerFactory, or maybe reuse services on both the client and the server; those are the things that OSGi is good at.

OSGi as a 'technology' (as far as that notion holds water) does not mandate any specific interaction method. The compendium specification mentions Remote Services (a.k.a. Distributed OSGi), but it also contains an HTTP service specification is Servlets are your thing.

In short, just pick the interaction solution that best matches your scenario, and let OSGi help you with the services and modularity.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文