atom feed1 message in sink interface in Java
FromSent OnAttachments
Philipp KursaweMar 29, 2009 11:48 am 
Subject:Implement sink interface in Java
From:Philipp Kursawe (
Date:Mar 29, 2009 11:48:24 am


I wanted to use com4j for Microsofts Remote API 2. This comes not with an typelib but only C++ headers that have the following:

MIDL_INTERFACE("b4fd053e-4810-46db-889b-20e638e334f0") IRAPISink : public IUnknown { public: virtual HRESULT STDMETHODCALLTYPE OnDeviceConnected( /* [in] */ IRAPIDevice *pIDevice) = 0;

virtual HRESULT STDMETHODCALLTYPE OnDeviceDisconnected( /* [in] */ IRAPIDevice *pIDevice) = 0;


In C++ you would have to implement this as a fully fledged COM object and hand it in to this method: MIDL_INTERFACE("dcbeb807-14d0-4cbd-926c-b991f4fd1b91") IRAPIDesktop : public IUnknown { public: virtual HRESULT STDMETHODCALLTYPE Advise( /* [in] */ IRAPISink *pISink, /* [out] */ DWORD_PTR *pdwContext) = 0; };

Is there any way to implement a COM object purely on java side so that it could be used in this scenario? The IRAPIDesktop does not support COM events so the standard Com4jObject.advise method cannot be used. I think we would need a Proxy Object in the native lib of com4j similar to the one used for events (CEventHandler). This would have to be instantiated and used as the "ptr" in the wrapper.

T COM4J.createInstance(Class<? extends Com4jObject> intf) { return new Wrapper(intf, Native.createInstance()); }

Should this be possible?

Thanks in advance, Phil