XMLizable interface and component model

While learning about the architecture and design of the promotion engine, you will repeatedly encounter objects that implement the XMLizable interface. This is a fundamental interface that serves as the basis for the component model the promotion engine employs.

The XMLizable interface declares that objects of the classes that implement this interface can be serialized into an XML document, and can be de-serialized from an XML document. These two actions are defined as methods on the interface.

An example of an object that implements this interface is the CategoryFilter. The CategoryFilter filters a given LineItemSet, and returns a subset of this input LineItemSet, such that all items in the output LineItemSet belong to categories allowed by the filter object. The next diagram shows the XMLized form of a CategoryFilter:

image goes here

Notes:

  1. The name of the tag binds this XML element to a business object interface.
  2. This attribute specifies the implementation class.
  3. The content of this XML element captures the configuration data for this instance of the business object.

In this diagram, the Filter element signifies that this object implements the Filter interface, and therefore follows the contract as specified by the interface. Its implementation class is the CategoryFilter class. The implementation defines the behavior of objects of this class. The body of the Filter element specifies an included category: Store 201 Sweaters. The body of the Filter element is only interpreted by the CategoryFilter. It knows how to resurrect a CategoryFilter object based on this content of the Filter element. The content can be viewed as the configuration of the CategoryFilter object.

The combination of the interface, implementation, and XML element provide a business object with the interaction contract, behavior, and configuration, and forms the basis of all customizable components in the promotion engine.

Objects implementing the XMLizable interface must provide a public default constructor.