public ProvisioningRuntime build() throws ProvisioningException { try { return doBuild(); } catch(ProvisioningException | RuntimeException | Error e) { throw e; } finally { layout.close(); } }
@Override public void close() { layout.close(); if (messageWriter.isVerboseEnabled()) { final long time = System.currentTimeMillis() - startTime; final long seconds = time / 1000; messageWriter.verbose("Done in %d.%d seconds", seconds, (time - seconds * 1000)); } } }
ProvisioningRuntime(final ProvisioningRuntimeBuilder builder, final MessageWriter messageWriter) throws ProvisioningException { this.startTime = builder.startTime; this.config = builder.config; this.layout = builder.layout.transform(new FeaturePackLayoutTransformer<FeaturePackRuntime, FeaturePackRuntimeBuilder>() { @Override public FeaturePackRuntime transform(FeaturePackRuntimeBuilder other) throws ProvisioningException { return other.build(builder); } }); this.fsDiff = builder.fsDiff; try { this.configs = builder.getResolvedConfigs(); this.stagedDir = layout.newStagedDir(); } catch (ProvisioningException | RuntimeException | Error e) { layout.close(); throw e; } this.messageWriter = messageWriter; }
@Override public ResolvedPlugins resolve() throws ResolutionException { boolean closeLayout = layout == null; ProvisioningLayout<FeaturePackLayout> pLayout = layout; // Silent resolution. session.unregisterTrackers(); try { try { if (pLayout == null) { if (config != null) { pLayout = session.getLayoutFactory().newConfigLayout(config); } else { // No registration in universe during completion pLayout = session.getLayoutFactory().newConfigLayout(file, false); } } return resolvePlugins(pLayout); } catch (Exception ex) { throw new ResolutionException(ex.getLocalizedMessage(), ex); } finally { if (closeLayout && pLayout != null) { pLayout.close(); } } } finally { session.registerTrackers(); } }