public class DispatchEvents extends JacobObject
The callback mechanism will take any event that it receives and try and find a java method with the same name that accepts the Variant... as a parameter. It will then wrap the call back data in the Variant array and call the java method of the object that this DispatchEvents object was initialized with.
Instances of this class are created with "sink object" that will receive the event messages. The sink object is wrapped in an Invocation handler that actually receives the messages and then forwards them on to the "sink object". The constructors recognize when an instance of InvocationProxy is passed in and do not create a new InvocationProxy as a wrapper. They instead use the passed in InvocationProxy.
Constructor and Description |
---|
DispatchEvents(Dispatch sourceOfEvent,
java.lang.Object eventSink)
This is the most commonly used constructor.
|
DispatchEvents(Dispatch sourceOfEvent,
java.lang.Object eventSink,
java.lang.String progId)
None of the samples use this constructor.
|
DispatchEvents(Dispatch sourceOfEvent,
java.lang.Object eventSink,
java.lang.String progId,
java.lang.String typeLib)
Creates the event callback linkage between the the MS program represented
by the Dispatch object and the Java object that will receive the
callback.
|
Modifier and Type | Method and Description |
---|---|
protected void |
finalize() |
protected InvocationProxy |
getInvocationProxy(java.lang.Object pTargetObject)
Returns an instance of the proxy configured with pTargetObject as its
target
|
void |
safeRelease()
Finalizers call this method.
|
debug, getBuildDate, getBuildVersion, isDebugEnabled
public DispatchEvents(Dispatch sourceOfEvent, java.lang.Object eventSink)
Creates the event callback linkage between the the MS program represented by the Dispatch object and the Java object that will receive the callback.
Can be used on any object that implements IProvideClassInfo.
sourceOfEvent
- Dispatch object who's MS app will generate callbackseventSink
- Java object that wants to receive the eventspublic DispatchEvents(Dispatch sourceOfEvent, java.lang.Object eventSink, java.lang.String progId)
Creates the event callback linkage between the the MS program represented by the Dispatch object and the Java object that will receive the callback.
Used when the program doesn't implement IProvideClassInfo. It provides a way to find the TypeLib in the registry based on the programId. The TypeLib is looked up in the registry on the path HKEY_LOCAL_MACHINE/SOFTWARE/Classes/CLSID/(CLID drived from progid)/ProgID/Typelib
sourceOfEvent
- Dispatch object who's MS app will generate callbackseventSink
- Java object that wants to receive the eventsprogId
- program id in the registry that has a TypeLib subkey. The
progrId is mapped to a CLSID that is they used to look up the
key to the Typelibpublic DispatchEvents(Dispatch sourceOfEvent, java.lang.Object eventSink, java.lang.String progId, java.lang.String typeLib)
This method was added because Excel doesn't implement IProvideClassInfo and the registry entry for Excel.Application doesn't include a typelib key.
DispatchEvents de = new DispatchEvents(someDispatch, someEventHAndler, "Excel.Application", "C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE");
sourceOfEvent
- Dispatch object who's MS app will generate callbackseventSink
- Java object that wants to receive the eventsprogId
- , mandatory if the typelib is specifiedtypeLib
- The location of the typelib to useprotected InvocationProxy getInvocationProxy(java.lang.Object pTargetObject)
pTargetObject
- protected void finalize()
finalize
in class java.lang.Object
public void safeRelease()
JacobObject
safeRelease
in class JacobObject
http://jacob-project.sourceforge.net