Search in sources :

Example 41 with PageSource

use of lucee.runtime.PageSource in project Lucee by lucee.

the class FDSignal method createExceptionStack.

public static List createExceptionStack(PageException pe) {
    StackTraceElement[] traces = pe.getStackTrace();
    PageContextImpl pc = (PageContextImpl) ThreadLocalPageContext.get();
    String template = "";
    StackTraceElement trace = null;
    List list = new ArrayList();
    Resource res;
    PageSource ps;
    FDStackFrameImpl frame;
    for (int i = traces.length - 1; i >= 0; i--) {
        trace = traces[i];
        ps = null;
        if (trace.getLineNumber() <= 0)
            continue;
        template = trace.getFileName();
        if (template == null || ResourceUtil.getExtension(template, "").equals("java"))
            continue;
        res = ResourceUtil.toResourceNotExisting(pc, template);
        ps = pc.toPageSource(res, null);
        frame = new FDStackFrameImpl(null, pc, trace, ps);
        if (ASMUtil.isOverfowMethod(trace.getMethodName()))
            list.set(0, frame);
        else
            list.add(0, frame);
    }
    if (pe instanceof TemplateException) {
        TemplateException te = (TemplateException) pe;
        if (te.getPageSource() != null)
            list.add(0, new FDStackFrameImpl(null, pc, te.getPageSource(), te.getLine()));
    }
    return list;
}
Also used : TemplateException(lucee.runtime.exp.TemplateException) ArrayList(java.util.ArrayList) Resource(lucee.commons.io.res.Resource) ArrayList(java.util.ArrayList) List(java.util.List) PageContextImpl(lucee.runtime.PageContextImpl) PageSource(lucee.runtime.PageSource)

Example 42 with PageSource

use of lucee.runtime.PageSource in project Lucee by lucee.

the class FDThreadImpl method getStack.

@Override
public List<IFDStackFrame> getStack() {
    List<PageSource> stack = pc.getPageSourceList();
    StackTraceElement[] traces = pc.getThread().getStackTrace();
    String template = "";
    StackTraceElement trace = null;
    ArrayList<IFDStackFrame> list = new ArrayList<IFDStackFrame>();
    PageSource ps;
    int index = stack.size();
    for (int i = traces.length - 1; i >= 0; i--) {
        trace = traces[i];
        ps = null;
        if (trace.getLineNumber() <= 0)
            continue;
        template = trace.getFileName();
        if (template == null || ResourceUtil.getExtension(template, "").equals("java"))
            continue;
        if (index > 0)
            ps = stack.get(--index);
        if (ps == null || !isEqual(ps, trace)) {
            ps = toPageSource(pc, template);
        }
        FDStackFrameImpl frame = new FDStackFrameImpl(this, pc, trace, ps);
        if (ASMUtil.isOverfowMethod(trace.getMethodName()))
            list.set(0, frame);
        else
            list.add(0, frame);
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) IFDStackFrame(com.intergral.fusiondebug.server.IFDStackFrame) PageSource(lucee.runtime.PageSource)

Example 43 with PageSource

use of lucee.runtime.PageSource in project Lucee by lucee.

the class FDThreadImpl method getTopStackFrame.

@Override
public IFDStackFrame getTopStackFrame() {
    PageSource ps = pc.getCurrentPageSource();
    StackTraceElement[] traces = pc.getThread().getStackTrace();
    String template = "";
    StackTraceElement trace = null;
    for (int i = 0; i < traces.length; i++) {
        trace = traces[i];
        if (trace.getLineNumber() <= 0)
            continue;
        template = trace.getFileName();
        if (template == null || ResourceUtil.getExtension(template, "").equals("java"))
            continue;
        if (ps == null || !isEqual(ps, trace)) {
            ps = toPageSource(pc, template);
        }
        break;
    }
    return new FDStackFrameImpl(this, pc, trace, ps);
}
Also used : PageSource(lucee.runtime.PageSource)

Example 44 with PageSource

use of lucee.runtime.PageSource in project Lucee by lucee.

the class CFMLEngineImpl method serviceFile.

@Override
public void serviceFile(HttpServlet servlet, HttpServletRequest req, HttpServletResponse rsp) throws ServletException, IOException {
    req = new HTTPServletRequestWrap(req);
    CFMLFactory factory = getCFMLFactory(servlet.getServletConfig(), req);
    ConfigWeb config = factory.getConfig();
    PageSource ps = config.getPageSourceExisting(null, null, req.getServletPath(), false, true, true, false);
    if (ps == null) {
        rsp.sendError(404);
    } else {
        Resource res = ps.getResource();
        if (res == null) {
            rsp.sendError(404);
        } else {
            ReqRspUtil.setContentLength(rsp, res.length());
            String mt = servlet.getServletContext().getMimeType(req.getServletPath());
            if (!StringUtil.isEmpty(mt))
                ReqRspUtil.setContentType(rsp, mt);
            IOUtil.copy(res, rsp.getOutputStream(), true);
        }
    }
}
Also used : HTTPServletRequestWrap(lucee.runtime.net.http.HTTPServletRequestWrap) Resource(lucee.commons.io.res.Resource) CFMLFactory(lucee.runtime.CFMLFactory) ConfigWeb(lucee.runtime.config.ConfigWeb) PageSource(lucee.runtime.PageSource)

Example 45 with PageSource

use of lucee.runtime.PageSource in project Lucee by lucee.

the class PageExceptionImpl method getTagContext.

public static Array getTagContext(Config config, StackTraceElement[] traces) {
    Array tagContext = new ArrayImpl();
    _getTagContext(config, tagContext, traces, new LinkedList<PageSource>());
    return tagContext;
}
Also used : Array(lucee.runtime.type.Array) ArrayImpl(lucee.runtime.type.ArrayImpl) PageSource(lucee.runtime.PageSource)

Aggregations

PageSource (lucee.runtime.PageSource)59 PageContextImpl (lucee.runtime.PageContextImpl)19 Resource (lucee.commons.io.res.Resource)16 Struct (lucee.runtime.type.Struct)10 ConfigWebImpl (lucee.runtime.config.ConfigWebImpl)8 Mapping (lucee.runtime.Mapping)7 PageException (lucee.runtime.exp.PageException)7 StructImpl (lucee.runtime.type.StructImpl)7 ConfigImpl (lucee.runtime.config.ConfigImpl)6 ConfigWeb (lucee.runtime.config.ConfigWeb)6 ExpressionException (lucee.runtime.exp.ExpressionException)6 ArrayList (java.util.ArrayList)5 Component (lucee.runtime.Component)5 PageSourceCode (lucee.transformer.util.PageSourceCode)5 IOException (java.io.IOException)4 MissingIncludeException (lucee.runtime.exp.MissingIncludeException)4 Array (lucee.runtime.type.Array)4 LitString (lucee.transformer.expression.literal.LitString)4 HTTPResource (lucee.commons.io.res.type.http.HTTPResource)3 Entry (java.util.Map.Entry)2