SF 1702604 - alpha prototype for activeXInvocationProxy event callbacks

This commit is contained in:
clay_shooter
2007-04-18 02:59:38 +00:00
parent 536fc35171
commit 7d7ed62066
13 changed files with 747 additions and 534 deletions

View File

@@ -1,408 +0,0 @@
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 11">
<meta name=Originator content="Microsoft Word 11">
<link rel=File-List href="EventCallbacks_files/filelist.xml">
<title>Jacob can register Java classes for MS application events or callbacks</title>
<!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:RemovePersonalInformation/>
</o:OfficeDocumentSettings>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:DisplayBackgroundShape/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:Compatibility>
<w:SelectEntireFieldWithStartOrEnd/>
<w:UseWord2002TableStyleRules/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" LatentStyleCount="156">
</w:LatentStyles>
</xml><![endif]-->
<style>
<!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
{margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Courier New";
mso-fareast-font-family:"Times New Roman";}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 65.95pt 1.0in 65.95pt;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;}
div.Section1
{page:Section1;}
/* List Definitions */
@list l0
{mso-list-id:369961789;
mso-list-type:hybrid;
mso-list-template-ids:-80199436 -1920937264 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
{mso-level-text:"%1\)";
mso-level-tab-stop:42.0pt;
mso-level-number-position:left;
margin-left:42.0pt;
text-indent:-24.0pt;}
@list l0:level2
{mso-level-tab-stop:1.0in;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level3
{mso-level-tab-stop:1.5in;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level4
{mso-level-tab-stop:2.0in;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level5
{mso-level-tab-stop:2.5in;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level6
{mso-level-tab-stop:3.0in;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level7
{mso-level-tab-stop:3.5in;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level8
{mso-level-tab-stop:4.0in;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level9
{mso-level-tab-stop:4.5in;
mso-level-number-position:left;
text-indent:-.25in;}
@list l1
{mso-list-id:638341914;
mso-list-type:hybrid;
mso-list-template-ids:-1620437462 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l1:level1
{mso-level-tab-stop:.75in;
mso-level-number-position:left;
margin-left:.75in;
text-indent:-.25in;}
@list l2
{mso-list-id:1316765558;
mso-list-type:hybrid;
mso-list-template-ids:860497186 -1920937264 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l2:level1
{mso-level-text:"%1\)";
mso-level-tab-stop:42.0pt;
mso-level-number-position:left;
margin-left:42.0pt;
text-indent:-24.0pt;}
@list l2:level2
{mso-level-tab-stop:1.0in;
mso-level-number-position:left;
text-indent:-.25in;}
@list l2:level3
{mso-level-tab-stop:1.5in;
mso-level-number-position:left;
text-indent:-.25in;}
@list l2:level4
{mso-level-tab-stop:2.0in;
mso-level-number-position:left;
text-indent:-.25in;}
@list l2:level5
{mso-level-tab-stop:2.5in;
mso-level-number-position:left;
text-indent:-.25in;}
@list l2:level6
{mso-level-tab-stop:3.0in;
mso-level-number-position:left;
text-indent:-.25in;}
@list l2:level7
{mso-level-tab-stop:3.5in;
mso-level-number-position:left;
text-indent:-.25in;}
@list l2:level8
{mso-level-tab-stop:4.0in;
mso-level-number-position:left;
text-indent:-.25in;}
@list l2:level9
{mso-level-tab-stop:4.5in;
mso-level-number-position:left;
text-indent:-.25in;}
@list l3
{mso-list-id:1718122875;
mso-list-type:hybrid;
mso-list-template-ids:-1873125376 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l3:level1
{mso-level-tab-stop:.5in;
mso-level-number-position:left;
text-indent:-.25in;}
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
-->
</style>
<!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
</style>
<![endif]--><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="2050"/>
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1"/>
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-US style='tab-interval:.5in'>
<div class=Section1>
<p class=MsoPlainText>Jacob can register Java classes for MS application events
or callbacks.<span style='mso-spacerun:yes'><EFBFBD> </span>The normal flow for this
is:</p>
<p class=MsoPlainText><o:p>&nbsp;</o:p></p>
<p class=MsoPlainText style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:
l2 level1 lfo2;tab-stops:list 42.0pt'><![if !supportLists]><span
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>1)<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]>Application thread creates an instance of the
event handler and registers it with Jacob</p>
<p class=MsoPlainText style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:
l2 level1 lfo2;tab-stops:list 42.0pt'><![if !supportLists]><span
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>2)<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]>The application continues on doing other work.</p>
<p class=MsoPlainText style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:
l2 level1 lfo2;tab-stops:list 42.0pt'><![if !supportLists]><span
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>3)<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]>Some time later, the MS application takes some
action and initiates the event callback.</p>
<p class=MsoPlainText style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:
l2 level1 lfo2;tab-stops:list 42.0pt'><![if !supportLists]><span
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>4)<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]>The Java VM receives the event and spins up a
new thread to handle it.</p>
<p class=MsoPlainText style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:
l2 level1 lfo2;tab-stops:list 42.0pt'><![if !supportLists]><span
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>5)<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]>The Jacob jni EventProxy in the dll is called by
the VM.</p>
<p class=MsoPlainText style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:
l2 level1 lfo2;tab-stops:list 42.0pt'><![if !supportLists]><span
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>6)<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]>The Jacob jni EventProxy creates Variant objects
to handle the parameters of the passed in event.</p>
<p class=MsoPlainText style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:
l2 level1 lfo2;tab-stops:list 42.0pt'><![if !supportLists]><span
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>7)<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]>The Jacob jni EventProxy sends the name of the
callback and the array of Variant objects to the Java<span
style='mso-spacerun:yes'><EFBFBD> </span>InvocationProxy that was registered to catch
events.</p>
<p class=MsoPlainText style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:
l2 level1 lfo2;tab-stops:list 42.0pt'><![if !supportLists]><span
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>8)<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]>The Java InvocationProxy uses reflection to map
the event name to a method name with the exact same name.</p>
<p class=MsoPlainText style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:
l2 level1 lfo2;tab-stops:list 42.0pt'><![if !supportLists]><span
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>9)<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]>The Java InvocationProxy sends the message to
the registered event handler and returns if the event handler is of type void
(standard behavior).<span style='mso-spacerun:yes'><EFBFBD> </span></p>
<p class=MsoPlainText style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:
l2 level1 lfo2;tab-stops:list 42.0pt'><![if !supportLists]><span
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>10)<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp; </span></span></span><![endif]>The
Java InvocationProxy sends the message to the registered event handler and
returns the Variant that resulted from the call back to the Jacob jni
EventProxy that then returns it to the windows calling program.</p>
<p class=MsoPlainText><o:p>&nbsp;</o:p></p>
<p class=MsoPlainText>Swing developers should note that this message comes in
on a thread other than the event thread.<span style='mso-spacerun:yes'><EFBFBD>
</span>All objects receiving events that require user intervention or drawing
in the UI should use invokeLater() to post requests for actions onto the event
queue.<span style='mso-spacerun:yes'><EFBFBD> </span>Failure to do so will insure random
failures in the GUI.</p>
<p class=MsoPlainText><o:p>&nbsp;</o:p></p>
<p class=MsoPlainText><o:p>&nbsp;</o:p></p>
<p class=MsoPlainText>Java Web Start (JWS) and other launchers can have
additional issues related to the class loader.<span style='mso-spacerun:yes'><EFBFBD>
</span>The Jacob C++ library uses FindClass() to find the Variant class when
building the parameter list.<span style='mso-spacerun:yes'><EFBFBD> </span>FindClass()
uses the system class loader which includes only the classes specified at run
time or in the CLASSPATH.<span style='mso-spacerun:yes'><EFBFBD> </span>Most of the
application classes in this situation live in an alternate set of class loaders
that were created when the launcher located and ran the application
classes.<span style='mso-spacerun:yes'><EFBFBD> </span>This means that the search for
Variant will fail usually with the silent and immediate termination of the Java
application.<span style='mso-spacerun:yes'><EFBFBD> </span>The thread classloader
probably can<61>t be used to try and find the class because this new thread does
not have a classloader associated with it other than the system class
loader.<span style='mso-spacerun:yes'><EFBFBD> </span>The end result is that the
Variant class needs to be located via other means and that the thread
classloader should be set to be the context class loader of the event handler
class.</p>
<p class=MsoPlainText><o:p>&nbsp;</o:p></p>
<p class=MsoPlainText>&lt;b&gt;1.8 and 1.9 behavior&lt;/b&gt;</p>
<p class=MsoPlainText>The Jacob EventProxy class has been modified (off of the
1.8 tree) so that it takes a two step approach <span
style='mso-spacerun:yes'><EFBFBD></span>towards fixing these problems.</p>
<p class=MsoPlainText><span style='mso-tab-count:2'><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> </span></p>
<p class=MsoPlainText style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:
l0 level1 lfo4;tab-stops:list 42.0pt'><![if !supportLists]><span
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>1)<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]>The EventProxy constructor now accepts an extra
object, an instance of the Variant class.<span style='mso-spacerun:yes'><EFBFBD>
</span>This gives the EventProxy a way to get to the Variant class and thus to
its classloader. All of the callers of the constructor have been modified to
pass a Variant object to the EventProxy without programmer intervention.</p>
<p class=MsoPlainText style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:
l0 level1 lfo4;tab-stops:list 42.0pt'><![if !supportLists]><span
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>2)<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]>EventProxy first attempts to locate the Variant
class using FindClass()</p>
<p class=MsoPlainText style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:
l0 level1 lfo4;tab-stops:list 42.0pt'><![if !supportLists]><span
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>3)<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]>Failing that, it looks to see if a variant
object had been passed in. If so, it calls class() and goes from there.<span
style='mso-spacerun:yes'><EFBFBD> </span></p>
<p class=MsoPlainText style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:
l0 level1 lfo4;tab-stops:list 42.0pt'><![if !supportLists]><span
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>4)<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]>If all that fails, it logs a message and then
fails in the spectacular fashion of the previous versions.</p>
<p class=MsoPlainText>&lt;b&gt;1.10 behavior&lt;/b&gt;</p>
<p class=MsoPlainText>The Jacob EventProxy class has been modified so that it
takes a different approach towards fixing this problem.</p>
<p class=MsoPlainText style='margin-left:.75in;text-indent:-.25in;mso-list:
l1 level1 lfo6;tab-stops:list .75in'><![if !supportLists]><span
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>1.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp; </span></span></span><![endif]>All
objects that request event notification are now wrapped in a Java
InvocationProxy so that a standard interface is always presented to the JNI
EventProxy object.</p>
<p class=MsoPlainText style='margin-left:.75in;text-indent:-.25in;mso-list:
l1 level1 lfo6;tab-stops:list .75in'><![if !supportLists]><span
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>2.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp; </span></span></span><![endif]>The
EventProxy constructor accepts an Java InvocationProxy as the object that will
receive any callbacks for this set of events.</p>
<p class=MsoPlainText style='margin-left:.75in;text-indent:-.25in;mso-list:
l1 level1 lfo6;tab-stops:list .75in'><![if !supportLists]><span
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>3.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp; </span></span></span><![endif]>The
Java InvocationProxy has a method on it that will return the Variant class that
the EventProxy.</p>
<p class=MsoPlainText><o:p>&nbsp;</o:p></p>
<p class=MsoPlainText>Developers can receive call back events in JWS other Java
launching programs without implementing any additional code.<span
style='mso-spacerun:yes'><EFBFBD> </span>They should be aware that their callback
methods may need to set the class loader. If they expect to create any objects.:</p>
<p class=MsoPlainText><span style='mso-tab-count:1'><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> </span>Public xxx
someHandler(Variant[] foo){</p>
<p class=MsoPlainText><span style='mso-tab-count:2'><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> </span>Thread.currentThread().setContextClassLoader(</p>
<p class=MsoPlainText><span style='mso-tab-count:3'><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> </span>this.getClass().getClassLoader());</p>
<p class=MsoPlainText><span style='mso-tab-count:2'><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> </span>// do
something</p>
<p class=MsoPlainText><span style='mso-tab-count:1'><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> </span>}</p>
<p class=MsoPlainText><o:p>&nbsp;</o:p></p>
<p class=MsoPlainText>There may still be a dual event queue issue in JWS
applications that needs to be looked at.</p>
<p class=MsoPlainText><o:p>&nbsp;</o:p></p>
</div>
</body>
</html>

87
docs/EventCallbacks.html Normal file
View File

@@ -0,0 +1,87 @@
<html>
<head>
<title>Jacob can register Java classes for MS application events or callbacks</title>
<BODY>
<H2>Events</H2>
Jacob can register Java classes for MS application events or callbacks. The normal flow for this is:
<OL>
<LI>Application thread creates an instance of the event handler and registers it with Jacob
<LI>The application continues on doing other work.
<LI>Some time later, the MS application takes some action and initiates the event callback.
<LI>The Java VM receives the event and spins up a new thread to handle it.
<LI>The Jacob jni EventProxy in the dll is called by the VM.
<LI>The Jacob jni EventProxy creates Variant objects to handle the parameters of the passed in event.
<LI>The Jacob jni EventProxy sends the name of the callback and the array of Variant objects to the Java InvocationProxy that was registered to catch events.
<LI>The Java InvocationProxy uses reflection to map the event name to a method name with the exact same name.
<LI>The Java InvocationProxy sends the message to the registered event handler and returns if the event handler is of type void (standard behavior).
<LI>The Java InvocationProxy sends the message to the registered event handler and returns the Variant that resulted from the call back to the Jacob jni EventProxy that then returns it to the windows calling program.
</OL>
<H2>SWING Issues</H2>
Swing developers should note that this message comes in on a thread other than the event thread.
All objects receiving events that require user intervention or drawing in the UI should use
invokeLater() to post requests for actions onto the event queue. Failure to do so will
insure random failures in the GUI.
Java Web Start (JWS) and other launchers can have additional issues related to the class loader.
The Jacob C++ library uses FindClass() to find the Variant class when building the parameter list.
FindClass() uses the system class loader which includes only the classes specified at run time or
in the CLASSPATH. Most of the application classes in this situation live in an alternate set of
class loaders that were created when the launcher located and ran the application classes. This
means that the search for Variant will fail usually with the silent and immediate termination of
the Java application. The thread classloader probably can<61>t be used to try and find the class
because this new thread does not have a classloader associated with it other than the system class
loader. The end result is that the Variant class needs to be located via other means and that the
thread classloader should be set to be the context class loader of the event handler class.
<H2>1.8 and 1.9 behavior</H2>
The Jacob EventProxy class has been modified (off of the 1.8 tree) so that it takes a two step approach towards fixing these problems.
<OL>
<LI>The EventProxy constructor now accepts an extra object, an instance of the Variant class. This gives the EventProxy a way to get to the Variant class and thus to its classloader. All of the callers of the constructor have been modified to pass a Variant object to the EventProxy without programmer intervention.
<LI>EventProxy first attempts to locate the Variant class using FindClass()
<LI>Failing that, it looks to see if a variant object had been passed in. If so, it calls class() and goes from there.
<LI>If all that fails, it logs a message and then fails in the spectacular fashion of the previous versions.
</OL>
<p>
<H2>1.10 behavior</H2>
The Jacob EventProxy class has been modified so that it takes a different approach towards fixing this problem.
<OL>
<LI>All objects that request event notification are now wrapped in a Java InvocationProxy
so that a standard interface is always presented to the JNI EventProxy object.
<LI>The EventProxy constructor accepts any Java class. It wraps the class if it is not an
InvocationProxy or uses just the passed in object if it is an InvocationProxy.
The JNI layer talks to the InvocationProxy instead of talking directly to the event listener
as in previous releases.
<LI>The Java InvocationProxy has a method on it that will return the Variant class that the
EventProxy. The JNI code uses this method to acquire the class so that it can call newInstance().
</OL>
Developers can receive call back events in JWS other Java launching programs without implementing any additional code. They should be aware that their callback methods may need to set the class loader. If they expect to create any objects.:
<pre>
Public xxx someHandler(Variant[] foo){
Thread.currentThread().setContextClassLoader(
this.getClass().getClassLoader());
// do something
}
</pre>
There may still be a dual event queue issue in JWS applications that needs to be looked at.
<p>
<H2>1.12 Experimental Behavior</H2>
Release 1.12 adds experimental support for event handlers that accept java objects as parameters
to closer match the signature of the windows callback. New ActiveXDispatchEvents and
ActiveXInvocationProxy operate in tandem in the same way as DispatchEvents and InvocationProxy.
DispatchEvents overrides getInvocationProxy() to create a new ActiveXInvocationProxy in place
of the normal InvocationProxy. ActiveXInvocationProxy has its own invoke() method that uses
reflection to call back using java objects as parameters.
<p>
Issues with this approach
<ul>
<li>Event callbacks that use java signatures do not support parameter modification. Many
windows callbacks let a user reject an event that is about to happen by modifying one of the
parameters. In this situation, the old DispatchEvents/InvocationProxy pair must be used instead
of the new handlers.
</ul>
</body>
</html>

View File

@@ -86,6 +86,13 @@
<td width="87%" valign="top">(pre-release 1) Dispatch static methods should throw runtime exceptions when
null is passed in for the Dispatch object and when the Dispatch object is in an invalid state. </td>
</tr>
<tr>
<td width="13%" valign="top">1702604 </td>
<td width="87%" valign="top">(pre-release 6) Support java semantics in event callbacks. Create
ActiveXInvocationProxy and ActiveXDispatchEvents that provide the supplemental API.
See IETestActiveXProxy.java for an example.
</td>
</tr>
<tr>
<td width="13%" valign="top">&nbsp;</td>
<td width="87%" valign="top">&nbsp;</td>