Book Image

Force.com Enterprise Architecture

By : Andrew Fawcett
Book Image

Force.com Enterprise Architecture

By: Andrew Fawcett

Overview of this book

Table of Contents (20 chapters)
Force.com Enterprise Architecture
Credits
Foreword
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

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 =
  Application.Domain.newInstance(recordIds);

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(
    ...