Is there an OSGi like framework that is based on C/C++? I have plenty of legacy code in C/C++ that would be too expensive to be ported to Java.
-
2One option is to use OSGi in Java *and* use your C/C++ code -- e.g., through through SWIG, JNA or JNI. – Andy Thomas Feb 12 '12 at 15:24
-
1OSGi frameworks support JNI libraries including updating them by unloading and reloading as required. – Peter Lawrey Feb 12 '12 at 17:33
-
2Even though it is easy to use JNI and native libs with OSGi, it has a huge drawback. If, for whatever reason, the native code crashes, the entire VM also crashes. This might be a reason for not using JNI. A solution using something like Apache Celix with remote services might be more useful in such case. – Alexander Feb 12 '12 at 19:40
3 Answers
Here is a list of OSGi-like C/C++ frameworks I know of (and which are still active):
- Apache Celix [Language: C, License: Apache License 2.0]
- SOF [Language: C++, License: Unknown]
- CTK [Language: C++, License: Apache License 2.0]
- nOSGi [Language: C++, License: GPLv3]
- Poco OSP [Language: C++, License: Commercial]
- CppMicroServices [Language: C++, License: Apache License 2.0]
This blog post gives a high-level overview about these frameworks.
Have a look at Apache Celix, which gives you an OSGi-like module framework for C, combined with C/Java interoperability through OSGi's Remote Services mechanism.

- 3,611
- 18
- 24
-
One of the things we (Apache Celix) are currently investigating is, is how to extend Celix so that it is also possible to use C++ in a natural way. Currently Celix only focusses on C. – Alexander Feb 13 '12 at 07:26
Since OSGi is nowadays a complete ecosystem with many standards, substandards and so on - the strict answer is: No, because it relies on to many things specific to Java (bytecode, classloading, garbage collection, ...) which are not part of C/C++ and which cannot be even simulated - especially for legacy code.
But if you tell us what parts of OSGi you are interested in and especially what parts you consider not relevant for your code, answers may come up.
Meanwhile you can browse some other similar questions on this site or use the search:
-
Another similar question, with answers, can be found here: http://stackoverflow.com/questions/7069144/how-to-compose-osgi-based-project-with-c-based-project – Alexander Feb 12 '12 at 19:43