public ModuleScript loadAsModule()

in src/main/java/org/apache/sling/scripting/esx/Module.java [537:558]


    public ModuleScript loadAsModule(String module, Resource currentResource, boolean isFileResource, String loader) throws ScriptException {
        ModuleScript script = null;

        String[] dirs = loadModulePaths(currentResource.getPath());
        log.debug("loading modules from dir path");
        for (String dir : dirs) {
            log.debug("trying to resolve. " + dir);
            Resource searchPath = currentResource.getResourceResolver().resolve(dir);
            log.debug("searchpath  = " + searchPath.getPath());
            if (searchPath != null && !ResourceUtil.isNonExistingResource(searchPath)) {
                log.debug("searchpath loadasmodule: " + searchPath.getPath());
                script = loadLocalModule(module, searchPath, false, loader);
                if (script != null) {
                    return script;
                }
            } else {
                log.debug("dir is null = " + dir);
            }
        }
        log.debug("finsihed loading dirs, script is loaded?!");
        return script;
    }