public void refreshBundles()

in src/main/java/org/apache/sling/installer/core/impl/util/WABundleRefresher.java [61:102]


    public void refreshBundles(final InstallationContext ctx,
            final List<Bundle> bundles,
            final boolean wait) {
        if ( bundles == null || bundles.size() > 0 ) {
            if ( bundles == null ) {
                ctx.log("Full package refreshing");
            } else {
                ctx.log("Refreshing {} bundles: {}", bundles.size(), bundles);
            }
            if ( !wait ) {
                this.frameworkWiring.refreshBundles(bundles == null ? null : bundles);
            } else {
                this.refreshEventCount = 0;
                this.frameworkWiring.refreshBundles(bundles == null ? null : bundles, this);
                final long end = System.currentTimeMillis() + (MAX_REFRESH_PACKAGES_WAIT_SECONDS * 1000);
                do {
                    synchronized ( this.lock ) {
                        final long waitTime = end - System.currentTimeMillis();
                        if ( this.refreshEventCount < 1 && waitTime > 0 ) {
                            try {
                                ctx.log("Waiting up to {} seconds for bundles refresh", MAX_REFRESH_PACKAGES_WAIT_SECONDS);
                                this.lock.wait(waitTime);
                            } catch (final InterruptedException ignore) {
                                // ignore
                            }
                            if ( end <= System.currentTimeMillis() && this.refreshEventCount < 1 ) {
                                logger.warn("No FrameworkEvent.PACKAGES_REFRESHED event received within {}"
                                        + " seconds after refresh, aborting wait.",
                                        MAX_REFRESH_PACKAGES_WAIT_SECONDS);
                                this.refreshEventCount++;
                            }
                        }
                    }
                } while ( this.refreshEventCount < 1);
            }
            if ( bundles == null ) {
                ctx.log("Done full package refresh");
            } else {
                ctx.log("Done refreshing {} bundles", bundles.size());
            }
        }
    }