protected void activate()

in src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java [1147:1183]


    protected void activate(final ComponentContext ctx, final ModelAdapterFactoryConfiguration configuration) {
        this.invocationCountThreadLocal = new ThreadLocal<ThreadInvocationCounter>() {
            @Override
            protected ThreadInvocationCounter initialValue() {
                return new ThreadInvocationCounter(configuration.max_recursion_depth());
            }
        };

        this.adapterCache = Collections.synchronizedMap(new WeakHashMap<Object, Map<Class<?>, SoftReference<Object>>>());

        BundleContext bundleContext = ctx.getBundleContext();
        this.queue = new ReferenceQueue<>();
        this.disposalCallbacks = new ConcurrentHashMap<>();
        this.requestDisposalCallbacks = new RequestDisposalCallbacks();
        Hashtable<String, Object> properties = new Hashtable<>();
        properties.put(Constants.SERVICE_VENDOR, "Apache Software Foundation");
        properties.put(Constants.SERVICE_DESCRIPTION, "Sling Models OSGi Service Disposal Job");
        properties.put("scheduler.name", "Sling Models OSGi Service Disposal Job");
        properties.put("scheduler.concurrent", false);
        properties.put("scheduler.period", configuration.cleanup_job_period());

        this.jobRegistration = bundleContext.registerService(Runnable.class, this, properties);

        this.scriptEngineFactory = new SlingModelsScriptEngineFactory(bundleContext.getBundle());
        this.listener = new ModelPackageBundleListener(ctx.getBundleContext(), this, this.adapterImplementations, bindingsValuesProvidersByContext, scriptEngineFactory);

        Hashtable<String, Object> printerProps = new Hashtable<>();
        printerProps.put(Constants.SERVICE_VENDOR, "Apache Software Foundation");
        printerProps.put(Constants.SERVICE_DESCRIPTION, "Sling Models Configuration Printer");
        printerProps.put("felix.webconsole.label", "slingmodels");
        printerProps.put("felix.webconsole.title", "Sling Models");
        printerProps.put("felix.webconsole.configprinter.modes", "always");

        this.configPrinterRegistration = bundleContext.registerService(Object.class,
                new ModelConfigurationPrinter(this, bundleContext, adapterImplementations), printerProps);

    }