Programming with the XSA engine

The full javadoc documentation.

A basic overview

The heart of the XSA package is the XSAEngine object, which does all the work. Your application simply uses it by registering an XSAClient object and then passing the URLs of XSA documents to it one by one.

The XSAClient is very primitive, and simply receives the contents of XSA documents encapsulated in objects. The ChangeListener interface is more high-level and allows clients to receive only notifications of changes. The DefaultClient implements this interface.

Basic operation

The basic operation of an XSA monitoring scan is simple and goes like this:

  1. Instantiate the XSA engine.
  2. Call setParser to tell it which parser to use. (If this method is not called the driver class given by the org.xml.sax.parser Java property will be used. If this property is not defined the scan will fail.)
  3. Call setClient to tell the engine where to send events.
  4. Call checkingStarts to inform the engine that we're about to start looking at XSA documents.
  5. Call checkURL for each document. (This will trigger corresponding events in the client.)
  6. Call checkingDone to inform the engine that we're done.

Events passed to the XSAClient and ChangeListener interfaces will use the Vendor and Product classes to encapsulate information.

More advanced stuff

Ignoring ChangeListener events

If you want to ignore all events (or a base class for a handler that does not react to all events) you can use the SilentListener class.

Inserting your own objects into the engine

If you want the engine to pass subclasses of Vendor and Product back to your clients rather than the default classes you can provide an ObjectFactory implementation that creates objects of the classes you want. Use the setFactory method on the XSAEngine to inform the engine.

Instantiating a SAX parser

If you for some reason need to instantiate a SAX parser you can use the two factory classes in the XSA.Util package.

Loading an XSA document

If you want to read an XSA document into a Vendor object you can use the loadDocument method on the XSA engine. This requires you to have set which parser to use and a client to receive errors.

Changing the internal workings of the engine

This can be achieved to some extent by subclassing InternalObjectsFactory and telling the engine to use the subclass. This makes it possible to change the creation of SAX parsers, SAX error handling and also to use a different SAX DocumentHandler.


19990322, Lars Marius Garshol.