protected boolean process(Session sess,
HttpServletRequest request, HttpServletResponse response, String path,
boolean bRichlet)
throws ServletException, IOException {
final WebApp wapp = sess.getWebApp();
final WebAppCtrl wappc = (WebAppCtrl)wapp;
final Configuration config = wapp.getConfiguration();
final boolean bInclude = Servlets.isIncluded(request);
final boolean compress = _compress && !bInclude;
final Writer out = compress ? (Writer)new StringWriter(): response.getWriter();
final DesktopRecycle dtrc = bInclude ? null: config.getDesktopRecycle();
Desktop desktop = dtrc != null ?
Utils.beforeService(dtrc, _ctx, sess, request, response, path): null;
try {
if (desktop != null) { //recycle
final Page page = Utils.getMainPage(desktop);
if (page != null) {
final Execution exec = new ExecutionImpl(
_ctx, request, response, desktop, page);
_webman.setDesktop(request, desktop);
wappc.getUiEngine().recycleDesktop(exec, page, out);
} else
desktop = null; //something wrong (not possible; just in case)
}
if (desktop == null) {
desktop = _webman.getDesktop(sess, request, response, path, true);
if (desktop == null) //forward or redirect
return true;
final RequestInfo ri = new RequestInfoImpl(
wapp, sess, desktop, request,
PageDefinitions.getLocator(wapp, path));
sess.setAttribute(Attributes.GAE_FIX, new Integer(0));
((SessionCtrl)sess).notifyClientRequest(true);
final UiFactory uf = wappc.getUiFactory();
if (uf.isRichlet(ri, bRichlet)) {
final Richlet richlet = uf.getRichlet(ri, path);
if (richlet == null)
return false; //not found
final Page page = WebManager.newPage(uf, ri, richlet, response, path);
final Execution exec = new ExecutionImpl(
_ctx, request, response, desktop, page);
wappc.getUiEngine().execNewPage(exec, richlet, page, out);
//no need to set device type here, since UiEngine will do it later
} else {
final PageDefinition pagedef = uf.getPageDefinition(ri, path);
if (pagedef == null)
return false; //not found
final Page page = WebManager.newPage(uf, ri, pagedef, response, path);
final Execution exec = new ExecutionImpl(
_ctx, request, response, desktop, page);
wappc.getUiEngine().execNewPage(exec, pagedef, page, out);
}
}
if (compress) {
final String result = ((StringWriter)out).toString();