Home arrow Support arrow Knowledge Base arrow Breaking Changes from SmartInspect 1.x to 2.x

Breaking Changes from SmartInspect 1.x to 2.x

Published on Friday, 23. February 2007
Products: SmartInspect Professional

This knowledge base article describes the breaking changes regarding the SmartInspect library APIs from SmartInspect 1.x to 2.0.

Java Event System

In SmartInspect 1.x, each event in the SmartInspect class had a Listener interface with a single method and its corresponding add, remove and clear methods. As an example, the Log Entry event had a LogEntryListener interface and the addLogEntryListener, removeLogEntryListener and clearLogEntryListeners methods in the SmartInspect class.

This event system has been redesigned to use a single interface for all events instead of an own interface for each event. The new interface is called SmartInspectListener (a new SmartInspectAdapter class which provides an empty default implementation for this interface is available as well). The following code fragments explain the required code changes with the Log Entry event as example.

/* Old event system */

import com.gurock.smartinspect.*;

class Listener implements LogEntryListener
{
   public void logEntryProcessed(LogEntryEvent e)
   {
      System.out.println(e.getLogEntry().getTitle());
   }
}

public class LogEntryEvent
{
   public static void main(String[] args)
   {
      SiAuto.si.setEnabled(true);
      SiAuto.si.addLogEntryListener(new Listener());
      SiAuto.main.logMessage("This is an event test!");
   }
}

...

/* New event system */

import com.gurock.smartinspect.*;

class Listener extends SmartInspectAdapter
{
   public void onLogEntry(LogEntryEvent e)
   {
      System.out.println(e.getLogEntry().getTitle());
   }
}

public class LogEntryEvent
{
   public static void main(String[] args)
   {
      SiAuto.si.setEnabled(true);
      SiAuto.si.addListener(new Listener());
      SiAuto.main.logMessage("This is an event test!");
   }
}

We think this change was necessary because of the increasing amount of events in the SmartInspect class. In the old system, it was unpractical and inconvenient to register for multiple events whereas with the new event system, this is straightforward and simple.


« Back to overview

Support
We provide support over different channels: