All sitemap components follow some basic contracts, which makes learning how to write components a bit easier. The first and most important contract is that all components usable in the sitemap implement the SitemapComponent interface. This is the very first contract to understand and learn. We then build on each of the contracts a little at a time until we have the full understanding of what is happening between the sitemap and the components it uses. Other contracts that we will look at are the SitemapOutputComponent, CacheableProcessingComponent, Generator, Transformer, Serializer, Reader, and Action.
The goal of this series is to introduce you to the mechanics of the different components and how they are created. When applicable we will address when is a good time to create these components, although that is not the primary focus.
The sitemap is responsible for setting up and using the components for a given pipeline. A pipeline consists of one or more SitemapModelComponents and a SitemapOutputComponent. Examples of this are a pipeline consisting of a Generator, some Transformers, and a Serializer. The Generator and Transformer interfaces implement the SitemapModelComponent while the Serializer interface implements the SitemapOutputComponent. The same goes for a pipeline consisting only of a Reader. The Reader interface implements both the SitemapModelComponent interface and the SitemapOutputComponent interface.
The basic progression of a request consists of the Sitemap reserving the components that will be used for the request. It then performs the setup that is necessary for the components to find the resources they use and set up any caching directives. Next, it executes the pipeline to produce your results. Lastly, it releases all the components used to process the request back to the respective pools.
The particular pipeline type used can support additional contracts like caching. The CachingPipeline uses the CacheableProcessingComponent interface to determine how and when to control caching. Remember that some items in your system are dependent on more than the URL used to access it. For example, if you are navigating through a list, the important meta-information of what page you are on should be part of the cache so that you don't get repeated results just because the URL didn't really change. We'll look at that in more detail as well.