Book Image Enterprise Architecture

By : Andrew Fawcett
Book Image Enterprise Architecture

By: Andrew Fawcett

Overview of this book

Table of Contents (20 chapters) Enterprise Architecture
About the Author
About the Reviewers

Introducing the Selector factory

The last chapter introduced the concept of a Domain factory, which was used to dynamically construct Domain class instances implementing a common Apex Interface in order to implement the compliance framework.

The following code is used in the ComplianceService.verify method's implementation, making no reference at all to a Selector class to query the records needed to construct the applicable Domain class:

fflib_SObjectDomain domain =

So, how did the Domain factory retrieve the records in order to pass them to the underlying Domain class constructor? The answer is that it internally used another factory implementation called the Selector factory.

As with the Domain factory, the Selector factory resides within the Application class as a static instance, exposed via the Selector static class member, as follows:

public class Application 
  public static final SelectorFactory Selector = 
    new SelectorFactory(