Version 1.2 API changes

Printer-friendly

The new release I'm almost finished with has some slight additions and interesting twists to the API.

First of all, its 100% backward compatible. Another words no API has been removed. I did add support for JRE 1.5 and 1.4. An interesting twist came up when I was trying to rewrite the API for JRE 1.4 since its always been targeted for JRE 1.5 is that StringBuilder doesn't exist in JRE 1.4. If you can remember back to the API the standard was to use StringBuffer. It also didn't implement the Appendable interface which could have worked in its place and would take care of StringBuilder and StringBuffer compatibility.

What I ended up doing is back ported for JRE 1.4 the API where all the methods use StringBuffer for errbuf while at the same the API for JRE 1.5 continues to use StringBuilder but also adds the use of StringBuffer now found in JRE 1.4 targets. In addition just to round things out, I added versions of methods with errbuf:Appendable.

Appendable is an IO based interface that allows strings to be appended. System.out implements Appendable as well as a host of other classes including StringBuilder.

So the API has grown a little since there are now 3 versions of methods that supply the "errbuf" parameter like openLive() and others. openLive(..., StringBuffer), openLive(...,StringBuilder) and openLive(..., Appendable) and so on with the other methods. While the API for JRE 1.4 only contains the StringBuffer versions.

The installable packages of jNetPcap will now contain 2 jar files one for each JRE. On UNIX systems there will be a soft link to RJE 1.5 version of the jar file of the normal jnetpcap-version.jar file to provide a default, but the user can add to classpath either of the JRE targeted jar files.

Both versions share the exact same native jnetpcap library. There are only API differences in java space.

I also added PcapUtils class with some static helper methods and added 2 new loop dispather methods to Pcap. PcapUtils.dispatchInBackground() and PcapUtils.loopInBackground() where the loop is placed in a background thread. Both methods return a PcapTask object with which the user can interact and get error messages and issue breakLoop() or stop() calls. No exactly pure native libpcap API but very useful in java environment. As a conveniece both of these routines have been added to Pcap class although they simply delegate to PcapUtils class.