public Object require()

in src/main/java/org/apache/sling/scripting/javascript/helper/SlingGlobal.java [222:237]


	public Object require(Context cx, Scriptable thisObj, Object[] args) {
		if (args.length != 1 || !(args[0] instanceof String)) {
			throw Context
					.reportRuntimeError("require() requires a String argument");
		}
		String modulePath = (String) args[0];

		ModuleScope moduleScope = null;
		if (thisObj instanceof ModuleScope) {
			moduleScope = (ModuleScope) thisObj;
		}

		ModuleScope module = loadModule(cx, modulePath.trim(), moduleScope,
				thisObj);
		return module.getExports();
	}