Although I'm a Windows developer, I can see some advantages in
developing filters in Java. First, they would offer a better cross-
platform support, but I think one of the main interests also reside
in the good i18n functionality Java provides. MLANG and standard
Windows API do offer a lot, and you can also use ICU if needed, but
it may be less organized and consistent than the Java support
(although Unicode support in Java needs to be updated).
This said, I think the callers of filters are often developed for a
single platform (often Windows), and when it comes to GUI
applications Java -from my modest experience- seems to be 'a little
behind'.
Overall we should have a way to access Java filters from Windows
applications and it could be done as follow:
- Java filters implement a filter interface Java class.
- A JNI layer, wrapped in a C++ class, allows you to access the Java
interface from C++. A single class is enough to access any filter.
- A thin COM layer wraps the C++ class and allows any COM-enable
application to also access the filters.
or, in image:
+-----------------------+
| Java filter(s) | =====> Java apps
| +-------------------+ |
| | Filter interface | |<-+
| +-------------------+ | |
+-----------------------+ |
|
+-----------------------+ |
| +-------------------+ | |
| | JNI Layer | |<-+
| +-------------------+ | =====> C++ apps
| C++ wrapper |<-+ (not using COM)
+-----------------------+ |
|
+-----------------------+ |
| COM interface |<-+
+-----------------------+ =====> COM apps
There is a price to this interoperability: The JNI layer has some
overhead in passing parameters (especially strings), but hopefully
this won't be to noticeable especially for high-level calls where the
calls are not numerous anyways.
There are also a number of issues (for example: how to use callback
in such architecture) that also need to be addressed, but they should
be resolved anyway to make C++ implementations be flexible.
I've done some experimentations this week-end: JNI lacks of good
documentation and is definitively 'unsavory' to program with, but it
seems to do the job. I've looked at other alternatives: cxxwrap, CNI,
SWIG, etc. but most of them are to call C++ from Java, not the
reverse.
Okapi would provide:
- the Java interface class
- the JNI/C++ class wrapper
- the COM object that wraps the JNI/C++ class
All this obviously doesn't prevent to write filters in C++ if it is
your preference: the important part is to have a common interface so
layers for interoperability can be also constructed and re-used.
Cheers,
-yves