OSGi 和 Java 本机接口

发布于 2025-01-02 06:05:12 字数 241 浏览 5 评论 0原文

我想开发可以调用Java Native接口的OSGi包。我有几个问题:

  1. 是否可以开发 OSGi 包并将 C 包装类和 JNI 放入其中?是否有我可以使用的已开发示例?

  2. 放置在 OSGi 包中的 java 方法是否可以调用放置在托管 bean 中的 java 方法?

祝愿

最美好的 还有一个问题:如何将一个简单的托管 bean 制作成 EJB?

I want to develop OSGi bundle which can call Java Native interface. I have a few questions:

  1. Is it possible to develop OSGi bundle and place in it C wrapper classes and JNI? Is there already developed example which I can use?

  2. Is it possible java methods placed in OSGi bundle to call java methods placed into managed bean?

Best wishes

P.S. One more question: How I can make one simple managed bean into EJB?

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

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

发布评论

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

评论(1

海之角 2025-01-09 06:05:12

通过在捆绑清单中包含 Bundle-NativeCode 标头,您可以相当轻松地完成此操作,并以跨平台的非常便携的方式进行。

例如:

Bundle-NativeCode: lib/mylib1.dll ; lib/mylib2.dll ;
  osname=Win32 ;
  processor=x86,
  lib/libmylib1.so ; lib/libmylib2.so ;
  osname=linux;
  processor=x86

则将加载

  • 如果操作系统是 Win32 并且处理器类型是 x86

  • lib/libmylib1.so 和 lib/libmylib2, lib/mylib1.dll 和 lib/mylib2.dll(从捆绑包内部)。因此,如果操作系统是 Linux 并且处理器类型是 x86

这种方法的优点在于,您可以根据架构包含各种不同的本机库,并且 OSGi 运行时将自动为当前 platofmr 选择正确的设置例如,当您调用 System.loadLibrary("mylib1");

这是关于该主题的旧博客:http://robertvarttinen.blogspot.co.uk/2008/12/bundle-nativecode-in-osgi-manifest.html

You can do this fairly easily, and in a very portable way across platforms, by including the Bundle-NativeCode header in your bundle manifest.

For example:

Bundle-NativeCode: lib/mylib1.dll ; lib/mylib2.dll ;
  osname=Win32 ;
  processor=x86,
  lib/libmylib1.so ; lib/libmylib2.so ;
  osname=linux;
  processor=x86

Will load

  • lib/mylib1.dll and lib/mylib2.dll (from inside the bundle) if the OS is Win32 and processor type is x86

or

  • lib/libmylib1.so and lib/libmylib2.so if the OS is Linux and the processor type is x86

The beauty of this approach is that you can include various different native libraries based on the architecture, and the OSGi runtime will automatically select the correct set for the current platofmr when you, for example, call System.loadLibrary("mylib1");

Here's an old blog on the topic: http://robertvarttinen.blogspot.co.uk/2008/12/bundle-nativecode-in-osgi-manifest.html

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