use of php.runtime.env.CompileScope in project jphp by jphp-compiler.
the class WebServerController method get.
@RequestMapping
public void get(OutputStream stream, HttpServletRequest request, HttpServletResponse response) throws Throwable {
PWebServer webServer = webServerMap.get(serverId);
Environment environment = webServer.getEnvironment();
CompileScope scope = environment.getScope();
Environment requestEnvironment;
if (!webServer.isIsolated()) {
requestEnvironment = new Environment(environment);
} else {
if (webServer.isHotReload()) {
scope = new CompileScope(scope);
}
requestEnvironment = new Environment(scope);
}
requestEnvironment.getDefaultBuffer().setOutput(stream);
if (webServer.isImportAutoloaders()) {
for (SplClassLoader loader : environment.getClassLoaders()) {
requestEnvironment.registerAutoloader(loader.forEnvironment(requestEnvironment), false);
}
}
Invoker onRequest = webServer.getOnRequest().forEnvironment(requestEnvironment);
PWebRequest webRequest = new PWebRequest(requestEnvironment, request);
PWebResponse webResponse = new PWebResponse(requestEnvironment, response);
requestEnvironment.setUserValue(webServer);
requestEnvironment.setUserValue(webRequest);
requestEnvironment.setUserValue(webResponse);
try {
onRequest.call(ObjectMemory.valueOf(webRequest), ObjectMemory.valueOf(webResponse));
} catch (Throwable throwable) {
Environment.catchThrowable(throwable, requestEnvironment);
} finally {
requestEnvironment.doFinal();
}
}
Aggregations