protected synchronized void activate()

in src/main/java/org/apache/sling/jcr/contentloader/internal/BundleContentLoaderListener.java [259:296]


    protected synchronized void activate(BundleContext bundleContext, BundleContentLoaderConfiguration configuration) {
        this.slingId = this.settingsService.getSlingId();
        this.bundleContentLoader = new BundleContentLoader(this, contentReaderWhiteboard, configuration);

        bundleContext.addBundleListener(this);
        // start listening for new ContentReader components
        contentReaderWhiteboard.setListener(this);

        Session session = null;
        try {
            session = this.getSession();
            this.createRepositoryPath(session, BUNDLE_CONTENT_NODE);
            log.debug("Activated - attempting to load content from all "
                    + "bundles which are neither INSTALLED nor UNINSTALLED");

            int ignored = 0;
            Bundle[] bundles = bundleContext.getBundles();
            for (Bundle bundle : bundles) {
                if ((bundle.getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
                    // load content for bundles which are neither INSTALLED nor
                    // UNINSTALLED
                    loadBundle(bundle, session);
                } else {
                    ignored++;
                }

            }

            log.debug("Out of {} bundles, {} were not in a suitable state for initial content loading", bundles.length,
                    ignored);

        } catch (Exception t) {
            log.error("activate: Problem while loading initial content and"
                    + " registering mappings for existing bundles", t);
        } finally {
            this.ungetSession(session);
        }
    }