Monday, January 19, 2009

JAXP Switching Implementations

I was thinking about the kind of effort it would take to switch between different implementations underlying the JAXP API so I did a Google search and came across an article on the Sun website with the following. It basically means you can switch between JAXP implementations with absolutely zero code changes.

The factory APIs let you plug in an XML implementation offered by another vendor without changing your source code. The implementation you get depends on the setting of the javax.xml.parsers.SAXParserFactory, javax.xml.parsers.DocumentBuilderFactory, and javax.xml.transform.TransformerFactory system properties, using System.setProperties() in the code, <sysproperty key="..." value="..."/> in an Ant build script, or -DpropertyName="..." on the command line. The default values (unless overridden at runtime on the command line or in the code) point to Sun's implementation.

No comments: