class OakMachine {

    public <E extends Throwable> void adminInitAndInspect(final InspectBody<E> inspectBody)
            throws AbortedScanException, RepositoryException, E {
        Session admin = null;
        Repository scanRepo = null;
        try {
            scanRepo = initRepository();
            admin = loginAdmin(scanRepo);
            addOakpalTypes(admin);

            final JcrPackageManager manager = packagingService.getPackageManager(admin);

            for (InitStage initStage : this.initStages) {
                initStage.initSession(admin, getErrorListener(), repoInitProcessor);
            }

            initSlingSimulator(admin, manager, errorListener);

            for (final URL url : preInstallUrls) {
                processPackageUrl(admin, manager, true, url);
            }

            inspectBody.tryAccept(admin);
        } finally {
            if (admin != null) {
                admin.logout();
            }

            shutdownRepository(scanRepo);
        }
    }

    private  OakMachine(final Packaging packagingService,
                       final List<ProgressCheck> progressChecks,
                       final ErrorListener errorListener,
                       final List<URL> preInstallUrls,
                       final List<InitStage> initStages,
                       final JcrCustomizer jcrCustomizer,
                       final InstallHookProcessorFactory installHookProcessorFactory,
                       final ClassLoader installHookClassLoader,
                       final boolean enablePreInstallHooks,
                       final InstallHookPolicy scanInstallHookPolicy,
                       final Supplier<NodeStore> nodeStoreSupplier,
                       final SubpackageSilencer subpackageSilencer,
                       final RepoInitProcessor repoInitProcessor,
                       final SlingSimulatorBackend slingSimulator,
                       final Set<String> runModes);

}