public Module()

in src/main/java/org/apache/sling/scripting/esx/Module.java [82:107]


    public Module(EsxScriptEngineFactory factory, Resource resource,
            ModuleScript moduleScript, String id, Module parent,
            SlingScriptHelper scriptHelper,
            String loader) throws ScriptException {
        this.factory = factory;
        this.scriptHelper = scriptHelper;
        this.moduleScript = moduleScript;
        this.loader = loader;

        put(CONTEXT_FIELD_PARENT, parent);
        put(CONTEXT_FIELD_SLING, scriptHelper);

        put(CONTEXT_FIELD_ID, id);
        put(CONTEXT_FIELD_MAIN, (parent == null) ? this : (Module) parent.get(CONTEXT_FIELD_PARENT));
        put(CONTEXT_FIELD_IS_LOADED, isLoaded);
        put(CONTEXT_FIELD_FILENAME, moduleScript.getResource().getPath());
        put(CONTEXT_FIELD_RESOURCE, resource);
        put(CONTEXT_FIELD_CHILDREN, children);
        put(CONTEXT_FIELD_MODULE_RESOURCE, moduleScript.getResource());

        put(CONTEXT_FIELD_EXPORTS, ((JSObject) factory.getNashornEngine().eval("Object")).newObject());

        log.debug("this is the main script: " + (get(CONTEXT_FIELD_MAIN) == this));

        put(CONTEXT_FIELD_CONSOLE, new ConsoleLog((String) get(CONTEXT_FIELD_FILENAME)));
    }