30 July
Because I have not had an entry in a while I am going to outline ''from memory'' what has happened in the last two weeks.
29 July
I have worked on cleaning up the handling of creating the XML output. I have also modified the test program to perform setName on any component created. This will make the XML output more readable during testing. An issue has been found about menus though: if a menu is not expanded during execution the branch of components is not added to the XML tree.
27 July
Stuart has found a
shutdown hook that allows us to perform any clean-up before the JVM shuts down. I have been tasked to get this working before Sunday.
I managed to get this working and outputting the XML tree as soon as the program exits.
26 July
A problem has also been discovered that the main thread, which the inquisitor started on, finished before the GUI threads finish. The XML output is therefore done before the GUI exits.
25 July
Added Key and Mouse events to the structure. Some minor modifications were made to the XML schema to make events children of their respective GUI component.
23 July
Submitted milestone two report.
20 July
Created multiple drafts of the milestone two report
15 July
I have begun dealing with ContainerEvent. One if the issues I have come across is that the base panes (GlassPane, layeredPane) are added to the RootPane before that is added to the JFrame. This means for a short time the RootPane, which contains the other panes, is an orphaned component. This means that I need to find a way of storing orphaned components until their correct hierarchy is established.
I have also found that you cannot find information about the Mouse or Keyboard buttons until an event occurs for that button. The mouse does have a MouseInfo class but that only lists the number of buttons, not the function of each.
Some minor changes were made to the generic XML schema to accommodate missing hardware information and handing multiplicity of child elements.
14 July
I have outputted the AWTEvents for the command ''JFrame window = new JFrame()'' and begun working out how to extrapolate a GUI structure from that.
I have also been playing more with the XML output of Java (via Xerces). I have figured out how to validate my XML DOM structure versus the XML Schema defined. We would validate before we serialize out to a file.
At this point once we should be able to output XML files in the next few days. We may need to modify the schema files if they do not work with realistic outputs. I have already had to modify the generic.xsd file as it broke an XML rule, a document may not have more than one root node, even though the W3C validator validated that schema.
10 July
I have managed to find a way to
'serialize' a Document object to print out XML. It uses the Xerces API which is not part of the standard javax.xml package. This means that the serialization component will not necessarily be as portable as the components building the DOM tree. This may present us with problems down the line if Java changes the default XML parser from Xerces.
Another thing we need to consider is how to 'uniquely' identify each component in the Java GUI tree. At this time using the hash code for each component should suffice though this is not ideal as a hash code is not meaningful to a human and does not remain constant across multiple executions. This is something that should be looked at later.
Tomorrow I am rather busy but may be able to put some more work in to exploring some AWTEvents.
09 July
I have managed to get SPI working so that I can plug in any circa or post event processor.
Each SPI has been hooked in to the tool in a form of Observer pattern. One of the issues I have dealt with is the fact that an AWTEventListener class gets given a AWTEvent (which we want to discern from). At the moment I have done a huge if-else block using interfaceOf conditionals and casting. I think this is inefficient so may investigate a better way.
Further research in to Java's XML capabilities has revealed a disturbing fact that there seems to be little documentation on how to output XML from Java (other than using System.out.println - Yuk!). I have just stumbled upon the XMLSerialization class that may be able to take a DOM tree and dump it to an XML file.
I am hoping that I can use the Java XML capabilities otherwise we may have to write a NASTY hack of an XML writer.
I have also been tossing up between SAX and DOM. SAX is said to be faster but may not be appropriate as it appears to be parsing driven rather than the DOM that (from memory) you can create nodes yourself.
06 July
After my meeting with Alex, the following fortnights goals are
* Consume at least two to three events
* Output these events to one of the XML schemas already defined
I have looked at JDOM and it does not support schema validation (you need to use something like
Xerces). There is an
article at JavaWorld which talks about using JAXP (Java API for XML parsing), which is parser implementation independent, to handle XML and their schemas. In Java 4 the default parser used is Crimson (which cannot validate) and in Java 5 it is Xerces (which can validate).
I have been also looking at making the prototype modular using Java's
SPI (Service Provider Interface) system. This means that multiple modules can be used to hook into the event system and do particular jobs, such as output to different XML models.
A possible performance tweak that may be useful in the future is dumping events to an object stream then consuming then after the main program has terminated. One problem with this is that AWTEvent (which extends EventObject) has a transient link to the source object, so we would need to handle that ourselves (which may cause more problems than it is worth). This is just an idea if performance becomes an issue.
02 July
I have finished my marking, exams, and CIMS4 course.
I now have 'some' time to work on my project.
I have built a program that can classload another class and then invoke the main method on it. I have successfully tested this on a GUI program and can see all events associated with the GUI program.
The next thing I need to do is output this to XML. I have used a package called
JDOM before and think it may be useful here. I do not know if JDOM handles XML schemas so that will be something I will need to investigate in the coming days.
More tomorrow...