Pass an instance of the main class, not the class, to the application context factory