private PageContextImpl createPageContext( CFMLFactory factory, ComponentAccess app, String applicationName, String cfid, Collection.Key methodName) throws PageException { Resource root = factory.getConfig().getRootDirectory(); String path = app.getPageSource().getFullRealpath(); // Request HttpServletRequestDummy req = new HttpServletRequestDummy(root, "localhost", path, "", null, null, null, null, null); if (!StringUtil.isEmpty(cfid)) req.setCookies(new Cookie[] {new Cookie("cfid", cfid), new Cookie("cftoken", "0")}); // Response OutputStream os = DevNullOutputStream.DEV_NULL_OUTPUT_STREAM; try { Resource out = factory .getConfig() .getConfigDir() .getRealResource("output/" + methodName.getString() + ".out"); out.getParentResource().mkdirs(); os = out.getOutputStream(false); } catch (IOException e) { e.printStackTrace(); // TODO was passiert hier } HttpServletResponseDummy rsp = new HttpServletResponseDummy(os); // PageContext PageContextImpl pc = (PageContextImpl) factory.getRailoPageContext(factory.getServlet(), req, rsp, null, false, -1, false); // ApplicationContext ClassicApplicationContext ap = new ClassicApplicationContext( factory.getConfig(), applicationName, false, app == null ? null : ResourceUtil.getResource(pc, app.getPageSource(), null)); initApplicationContext(pc, app); ap.setName(applicationName); ap.setSetSessionManagement(true); // if(!ap.hasName())ap.setName("Controler") // Base pc.setBase(app.getPageSource()); return pc; }
static void _onRequest( PageContext pc, PageSource requestedPage, PageSource application, RequestListener rl) throws PageException { ((PageContextImpl) pc).setAppListenerType(AppListenerUtil.TYPE_CLASSIC); // on requestStart if (application != null) pc.doInclude(new PageSource[] {application}, false); if (rl != null) { requestedPage = rl.execute(pc, requestedPage); if (requestedPage == null) return; } // request try { pc.doInclude(new PageSource[] {requestedPage}, false); } catch (MissingIncludeException mie) { ApplicationContext ac = pc.getApplicationContext(); boolean rethrow = true; if (ac instanceof ClassicApplicationContext) { ClassicApplicationContext cfc = (ClassicApplicationContext) ac; UDF udf = cfc.getOnMissingTemplate(); if (udf != null) { String targetPage = requestedPage.getFullRealpath(); rethrow = (!Caster.toBooleanValue(udf.call(pc, new Object[] {targetPage}, true), true)); } } if (rethrow) throw mie; } // on Request End if (application != null) { PageSource onReqEnd = application.getRealPage("OnRequestEnd.cfm"); if (onReqEnd.exists()) pc.doInclude(new PageSource[] {onReqEnd}, false); } }