From f10210a5f2a42ff41438d77235c2ed3b9d670cbc Mon Sep 17 00:00:00 2001 From: Robert Baillie Date: Wed, 20 Apr 2022 11:38:33 +0100 Subject: [PATCH] Lazy load the Unit of Work, so it doesn't get built when it isn't needed --- .../ortoo-core/default/classes/Application.cls | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/framework/default/ortoo-core/default/classes/Application.cls b/framework/default/ortoo-core/default/classes/Application.cls index 073f69b1a0c..cdb6dd5c833 100644 --- a/framework/default/ortoo-core/default/classes/Application.cls +++ b/framework/default/ortoo-core/default/classes/Application.cls @@ -7,7 +7,16 @@ public inherited sharing class Application { public class InvalidApplicationConfigurationException extends Exceptions.DeveloperException {} - public final static ortoo_UnitOfWorkFactory UNIT_OF_WORK = new ortoo_UnitOfWorkFactory(); // is created with no default since that needs to be defined by the consumer + public final static ortoo_UnitOfWorkFactory UNIT_OF_WORK { + get { + if ( UNIT_OF_WORK == null ) + { + UNIT_OF_WORK = new ortoo_UnitOfWorkFactory(); // is created with no default since that needs to be defined by the consumer + } + return UNIT_OF_WORK; + } + set; + } public static ortoo_SelectorFactory SELECTOR; // NOPMD: want to give the impression that this is final, even though it isn't. public static ortoo_DomainFactory DOMAIN; // NOPMD: want to give the impression that this is final, even though it isn't.