|
SYS-CON Magazines
|
Top Linux Links You Must Click On
Feature j-Interop: An Open Source Library for COM Interoperability Without JNI
A search for pure, non-native, bi-directional interoperability with COM servers
By: Vikram Roopchand
Dec. 28, 2006 05:00 PM
Phew! I have drawn a picture to explain this entire cycle, just follow the alphabet. I hope I was able to provide a concise introduction to the discovery and activation cycle. Let's see how the "QueryInterface" works and how the API call "Add (...)" is handled.
12. The remote connection has now been established and we have an
interface pointer to the remote IUnknown
(the "IRemUnknown"). A QueryInterface () call to obtain the
"ITestCOMServer"" interface will result in the following activities
taking place. This completes the entire cycle of obtaining an interface, executing an API on it, and subsequently releasing it. There's an additional task that the COM runtime also does and that's keeping the COM Server objects alive during a session. This is done via a ping mechanism. Pinging is carried out on a per-object (per-OID), not a per-interface (per-IPID) basis. Architecturally, at its server machine, each exported object (each exported OID) has associated with it a "ping period" that must elapse without getting a ping on that OID before all the remote references to IPIDs associated with that OID can be considered to have expired. Once expiration has occurred, the interfaces behind the IPIDs might get reclaimed (exactly when is implementation-specific). I've tried to keep the explanation of DCOM internals as simple as possible. There's much more that happens, but I'm running out of space and I think you're running out of patience, so let's get to j-Interop. (Figure 4)
j-Interop The library comes with pre-implemented packages for automation. This includes support for IDispatch, ITypeInfo, and ITypeLib. For more flexibility, it provides an API set to invoke operations directly on a COM server without going through automation. Another important feature is to allow full access and manipulation of the Windows Registry in a platform-independent manner. The implementation has been tested on all advanced Windows and Fedora platforms and displays upward compatibility from JRE 1.3.1. For more technical specifications please visit http://j-interop.sourceforge.net. I'll show you an implementation using j-Interop to call the ITestCOMServer from Java is Listing 1. As you can see it's pretty straightforward. The ITestCOMServer supports the IDispatch interface. I've shown both ways of accessing the COM server, i.e., via the dispatch interface as well as via a direct call. From my experience, I'd suggest using the IDispatch interface, whenever it's available. It's much easier to program that way. Figure 5 is normally how a Windows COM client communicates with its COM server. j-Interop does this as well and so for the COM server it's like an ordinary COM client. Whether the Java application is on Windows or Unix, it doesn't matter. More examples and documentation can be downloaded from the SourceForge site mentioned previously. The advantages offered by using a non-native library like j-Interop include:
DCE/RPC stands for Distributed Computing Environment/Remote Procedure Calls. It originated from Network Computing System (NCS) RPC developed by Apollo (which later got acquired by HP).DCE/RPC specifies a complete set of APIs and Models to abstract the usual nuances of an RPC system like a named lookup, subsequent handshake\binding, passing of call data between two parties , handling communication errors, security etc.. It provides protocol support for both Connectionless and Connection Oriented communication and has a wide transport base, UDP, TCP/IP, SMB, HTTP to name a few. It also has a generic security model supporting several authentication mechanisms such as DCE, Kerberos and GSSAPI. The full specification can be obtained from www.theopengroup.com. Reader Feedback: Page 1 of 1
Subscribe to our RSS feeds now and receive the next article instantly!
Subscribe to the World's Most Powerful Newsletters
|
||||||||||||||