class OakMachine {

    final void internalProcessSubpackage(final @NotNull Session admin,
                                         final @NotNull JcrPackageManager manager,
                                         final @NotNull PackageId packageId,
                                         final boolean preInstall,
                                         final @NotNull Fun.ThrowingSupplier<JcrPackage> jcrPackageSupplier,
                                         final @NotNull Fun.ThrowingConsumer<ProgressCheck> identifyEvent,
                                         final @NotNull Consumer<Exception> onError) throws RepositoryException {
        try (JcrPackage jcrPackage = jcrPackageSupplier.tryGet()) {
            if (jcrPackage != null) {
                propagateCheckPackageEvent(preInstall, packageId, identifyEvent);

                processPackage(admin, manager, jcrPackage, preInstall);
            } else {
                throw new PackageException("JcrPackageManager returned null package");
            }
        } catch (IOException | PackageException | RepositoryException e) {
            onError.accept(e);
            admin.refresh(false);
        } catch (Exception e) {
            onError.accept(e);
        }
    }

    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);

}