Search in sources :

Example 61 with PageContextImpl

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

the class Admin method doGetComponent.

/**
 * @throws PageException
 * @throws PageException
 */
private void doGetComponent() throws PageException {
    Struct sct = new StructImpl();
    pageContext.setVariable(getString("admin", action, "returnVariable"), sct);
    // Base Component
    try {
        PageSource psCFML = config.getBaseComponentPageSource(CFMLEngine.DIALECT_CFML);
        if (psCFML != null && psCFML.exists())
            sct.set("baseComponentTemplateCFML", psCFML.getDisplayPath());
        else
            sct.set("baseComponentTemplateCFML", "");
    } catch (PageException e) {
        sct.set("baseComponentTemplateCFML", "");
    }
    try {
        PageSource psLucee = config.getBaseComponentPageSource(CFMLEngine.DIALECT_LUCEE);
        if (psLucee != null && psLucee.exists())
            sct.set("baseComponentTemplateLucee", psLucee.getDisplayPath());
        else
            sct.set("baseComponentTemplateLucee", "");
    } catch (PageException e) {
        sct.set("baseComponentTemplateLucee", "");
    }
    sct.set("strBaseComponentTemplateCFML", config.getBaseComponentTemplate(CFMLEngine.DIALECT_CFML));
    sct.set("strBaseComponentTemplateLucee", config.getBaseComponentTemplate(CFMLEngine.DIALECT_LUCEE));
    // dump template
    try {
        PageSource ps = ((PageContextImpl) pageContext).getPageSourceExisting(config.getComponentDumpTemplate());
        if (ps != null)
            sct.set("componentDumpTemplate", ps.getDisplayPath());
        else
            sct.set("componentDumpTemplate", "");
    } catch (PageException e) {
        sct.set("componentDumpTemplate", "");
    }
    sct.set("strComponentDumpTemplate", config.getComponentDumpTemplate());
    sct.set("deepSearch", Caster.toBoolean(config.doComponentDeepSearch()));
    sct.set("componentDataMemberDefaultAccess", ComponentUtil.toStringAccess(config.getComponentDataMemberDefaultAccess()));
    sct.set("triggerDataMember", Caster.toBoolean(config.getTriggerComponentDataMember()));
    sct.set("useShadow", Caster.toBoolean(config.useComponentShadow()));
    sct.set("ComponentDefaultImport", config.getComponentDefaultImport());
    sct.set("componentLocalSearch", config.getComponentLocalSearch());
    sct.set("componentPathCache", config.useComponentPathCache());
}
Also used : PageException(lucee.runtime.exp.PageException) StructImpl(lucee.runtime.type.StructImpl) PageContextImpl(lucee.runtime.PageContextImpl) Struct(lucee.runtime.type.Struct) PageSource(lucee.runtime.PageSource)

Example 62 with PageContextImpl

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

the class UDFImpl method _callCachedWithin.

private Object _callCachedWithin(PageContext pc, Collection.Key calledName, Object[] args, Struct values, boolean doIncludePath) throws PageException {
    PageContextImpl pci = (PageContextImpl) pc;
    Object cachedWithin = getCachedWithin(pc);
    String cacheId = CacheHandlerCollectionImpl.createId(this, args, values);
    CacheHandler cacheHandler = pc.getConfig().getCacheHandlerCollection(Config.CACHE_TYPE_FUNCTION, null).getInstanceMatchingObject(getCachedWithin(pc), null);
    if (cacheHandler instanceof CacheHandlerPro) {
        CacheItem cacheItem = ((CacheHandlerPro) cacheHandler).get(pc, cacheId, cachedWithin);
        if (cacheItem instanceof UDFCacheItem) {
            UDFCacheItem entry = (UDFCacheItem) cacheItem;
            try {
                pc.write(entry.output);
            } catch (IOException e) {
                throw Caster.toPageException(e);
            }
            return entry.returnValue;
        }
    } else if (cacheHandler != null) {
        // TODO this else block can be removed when all cache handlers implement CacheHandlerPro
        CacheItem cacheItem = cacheHandler.get(pc, cacheId);
        if (cacheItem instanceof UDFCacheItem) {
            UDFCacheItem entry = (UDFCacheItem) cacheItem;
            // if(entry.creationdate+properties.cachedWithin>=System.currentTimeMillis()) {
            try {
                pc.write(entry.output);
            } catch (IOException e) {
                throw Caster.toPageException(e);
            }
            return entry.returnValue;
        // }
        // cache.remove(id);
        }
    }
    // cached item not found, process and cache result if needed
    long start = System.nanoTime();
    // execute the function
    BodyContent bc = pci.pushBody();
    try {
        Object rtn = _call(pci, calledName, args, values, doIncludePath);
        if (cacheHandler != null) {
            String out = bc.getString();
            cacheHandler.set(pc, cacheId, cachedWithin, new UDFCacheItem(out, rtn, getFunctionName(), getSource(), System.nanoTime() - start));
        }
        return rtn;
    } finally {
        BodyContentUtil.flushAndPop(pc, bc);
    }
}
Also used : UDFCacheItem(lucee.runtime.cache.tag.udf.UDFCacheItem) BodyContent(javax.servlet.jsp.tagext.BodyContent) CacheHandlerPro(lucee.runtime.cache.tag.CacheHandlerPro) PageContextImpl(lucee.runtime.PageContextImpl) CacheItem(lucee.runtime.cache.tag.CacheItem) UDFCacheItem(lucee.runtime.cache.tag.udf.UDFCacheItem) IOException(java.io.IOException) CacheHandler(lucee.runtime.cache.tag.CacheHandler)

Example 63 with PageContextImpl

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

the class UDFPropertiesImpl method readExternal.

@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    try {
        PageContextImpl pc = (PageContextImpl) ThreadLocalPageContext.get();
        ConfigWebImpl cw = (ConfigWebImpl) ThreadLocalPageContext.getConfig(pc);
        String path = ExternalizableUtil.readString(in);
        ps = PageSourceImpl.best(cw.getPageSources(pc, null, path, false, true, true));
    } catch (Exception e) {
        throw ExceptionUtil.toIOException(e);
    }
    startLine = in.readInt();
    endLine = in.readInt();
    arguments = (FunctionArgument[]) in.readObject();
    access = in.readInt();
    index = in.readInt();
    returnFormat = in.readInt();
    returnType = in.readInt();
    description = ExternalizableUtil.readString(in);
    displayName = ExternalizableUtil.readString(in);
    functionName = ExternalizableUtil.readString(in);
    hint = ExternalizableUtil.readString(in);
    meta = (Struct) in.readObject();
    output = in.readBoolean();
    bufferOutput = ExternalizableUtil.readBoolean(in);
    secureJson = ExternalizableUtil.readBoolean(in);
    strReturnFormat = ExternalizableUtil.readString(in);
    strReturnType = ExternalizableUtil.readString(in);
    verifyClient = ExternalizableUtil.readBoolean(in);
    cachedWithin = ExternalizableUtil.readString(in);
    int tmp = in.readInt();
    localMode = tmp == -1 ? null : tmp;
    if (arguments != null && arguments.length > 0) {
        this.argumentsSet = new HashSet<Collection.Key>();
        for (int i = 0; i < arguments.length; i++) {
            argumentsSet.add(arguments[i].getName());
        }
    }
}
Also used : ConfigWebImpl(lucee.runtime.config.ConfigWebImpl) PageContextImpl(lucee.runtime.PageContextImpl) IOException(java.io.IOException) Key(lucee.runtime.type.Collection.Key)

Example 64 with PageContextImpl

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

the class FDControllerImpl method pause.

private void pause(String name, CFMLFactoryImpl factory, List<IFDThread> threads) {
    Map<Integer, PageContextImpl> pcs = factory.getActivePageContexts();
    Iterator<PageContextImpl> it = pcs.values().iterator();
    PageContextImpl pc;
    while (it.hasNext()) {
        pc = it.next();
        try {
            pc.getThread().wait();
        } catch (InterruptedException e) {
            SystemOut.printDate(e);
        }
        threads.add(new FDThreadImpl(this, factory, name, pc));
    }
}
Also used : PageContextImpl(lucee.runtime.PageContextImpl)

Example 65 with PageContextImpl

use of lucee.runtime.PageContextImpl 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)

Aggregations

PageContextImpl (lucee.runtime.PageContextImpl)84 PageSource (lucee.runtime.PageSource)19 Resource (lucee.commons.io.res.Resource)17 Key (lucee.runtime.type.Collection.Key)15 Struct (lucee.runtime.type.Struct)15 StructImpl (lucee.runtime.type.StructImpl)14 IOException (java.io.IOException)12 ApplicationException (lucee.runtime.exp.ApplicationException)10 PageException (lucee.runtime.exp.PageException)10 Component (lucee.runtime.Component)9 ConfigWeb (lucee.runtime.config.ConfigWeb)9 ConfigWebImpl (lucee.runtime.config.ConfigWebImpl)9 CFMLFactoryImpl (lucee.runtime.CFMLFactoryImpl)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 ArrayList (java.util.ArrayList)6 Mapping (lucee.runtime.Mapping)6 PageContext (lucee.runtime.PageContext)6 ConfigImpl (lucee.runtime.config.ConfigImpl)6 ExpressionException (lucee.runtime.exp.ExpressionException)6 HttpServletResponse (javax.servlet.http.HttpServletResponse)5