Reputation: 1588
I want to develop OSGi bundle which can call Java Native interface. I have a few questions:
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?
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?
Upvotes: 1
Views: 565
Reputation: 1823
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
or
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
Upvotes: 1