Search in sources :

Example 31 with ConfigWeb

use of lucee.runtime.config.ConfigWeb in project Lucee by lucee.

the class GatewayEngineImpl method getCFC.

private Component getCFC(PageContextImpl pc, String requestURI) throws PageException {
    HttpServletRequest req = pc.getHttpServletRequest();
    try {
        String ext = ResourceUtil.getExtension(requestURI, "");
        ConfigWeb config = (ConfigWeb) ThreadLocalPageContext.getConfig(pc);
        int dialect = config.getFactory().toDialect(ext);
        req.setAttribute("client", "lucee-gateway-1-0");
        req.setAttribute("call-type", "store-only");
        if (dialect == CFMLEngine.DIALECT_LUCEE)
            pc.execute(requestURI, true, false);
        else
            pc.executeCFML(requestURI, true, false);
        return (Component) req.getAttribute("component");
    } finally {
        req.removeAttribute("call-type");
        req.removeAttribute("component");
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Component(lucee.runtime.Component) ConfigWeb(lucee.runtime.config.ConfigWeb)

Example 32 with ConfigWeb

use of lucee.runtime.config.ConfigWeb in project Lucee by lucee.

the class CreationImpl method createPageContext.

@Override
public PageContext createPageContext(HttpServletRequest req, HttpServletResponse rsp, OutputStream out) {
    Config config = ThreadLocalPageContext.getConfig();
    if (!(config instanceof ConfigWeb))
        throw new RuntimeException("need a web context to create a PageContext");
    CFMLFactory factory = ((ConfigWeb) config).getFactory();
    return (PageContext) factory.getPageContext(factory.getServlet(), req, rsp, null, false, -1, false);
}
Also used : ServletConfig(javax.servlet.ServletConfig) Config(lucee.runtime.config.Config) CFMLFactory(lucee.runtime.CFMLFactory) PageContext(lucee.runtime.PageContext) ThreadLocalPageContext(lucee.runtime.engine.ThreadLocalPageContext) ConfigWeb(lucee.runtime.config.ConfigWeb)

Example 33 with ConfigWeb

use of lucee.runtime.config.ConfigWeb in project Lucee by lucee.

the class Log4jUtil method getLogger.

public static final Logger getLogger(Config config, Appender appender, String name, Level level) {
    // fullname
    String fullname = name;
    if (config instanceof ConfigWeb) {
        ConfigWeb cw = (ConfigWeb) config;
        fullname = "web." + cw.getLabel() + "." + name;
    } else
        fullname = "server." + name;
    Logger l = LogManager.exists(fullname);
    if (l != null)
        l.removeAllAppenders();
    else
        l = LogManager.getLogger(fullname);
    l.setAdditivity(false);
    l.addAppender(appender);
    l.setLevel(level);
    return l;
}
Also used : Logger(org.apache.log4j.Logger) ConfigWeb(lucee.runtime.config.ConfigWeb)

Example 34 with ConfigWeb

use of lucee.runtime.config.ConfigWeb in project Lucee by lucee.

the class ResourceLockImpl method _read.

private void _read(String path) {
    long start = -1, now;
    Thread t;
    do {
        if ((t = resources.get(path)) == null) {
            // print.ln("read ok");
            return;
        }
        if (t == Thread.currentThread()) {
            // aprint.err(path);
            Config config = ThreadLocalPageContext.getConfig();
            if (config != null)
                SystemOut.printDate(config.getErrWriter(), "conflict in same thread: on " + path);
            // SystemOut.printDate(config.getErrWriter(),"conflict in same thread: on "+path+"\nStacktrace:\n"+StringUtil.replace(ExceptionUtil.getStacktrace(new Throwable(), false),"java.lang.Throwable\n","",true));
            return;
        }
        // bugfix when lock von totem thread, wird es ignoriert
        if (!t.isAlive()) {
            resources.remove(path);
            return;
        }
        if (start == -1)
            start = System.currentTimeMillis();
        try {
            token.wait(lockTimeout);
            now = System.currentTimeMillis();
            if ((start + lockTimeout) <= now) {
                Config config = ThreadLocalPageContext.getConfig();
                if (config != null) {
                    PageContextImpl pc = null;
                    String add = "";
                    if (config instanceof ConfigWeb) {
                        CFMLFactory factory = ((ConfigWeb) config).getFactory();
                        if (factory instanceof CFMLFactoryImpl) {
                            Map<Integer, PageContextImpl> pcs = ((CFMLFactoryImpl) factory).getActivePageContexts();
                            Iterator<PageContextImpl> it = pcs.values().iterator();
                            PageContextImpl tmp;
                            while (it.hasNext()) {
                                tmp = it.next();
                                if (t == tmp.getThread()) {
                                    pc = tmp;
                                    break;
                                }
                            }
                        }
                    }
                    if (pc != null) {
                        add = " The file is locked by a request on the following URL " + ReqRspUtil.getRequestURL(pc.getHttpServletRequest(), true) + ", that request started " + (System.currentTimeMillis() - pc.getStartTime()) + "ms ago.";
                    }
                    SystemOut.printDate(config.getErrWriter(), "timeout after " + (now - start) + " ms (" + (lockTimeout) + " ms) occured while accessing file [" + path + "]." + add);
                } else
                    SystemOut.printDate("timeout (" + (lockTimeout) + " ms) occured while accessing file [" + path + "].");
                return;
            }
        } catch (InterruptedException e) {
        }
    } while (true);
}
Also used : CFMLFactoryImpl(lucee.runtime.CFMLFactoryImpl) Config(lucee.runtime.config.Config) CFMLFactory(lucee.runtime.CFMLFactory) PageContextImpl(lucee.runtime.PageContextImpl) ConfigWeb(lucee.runtime.config.ConfigWeb)

Aggregations

ConfigWeb (lucee.runtime.config.ConfigWeb)34 Resource (lucee.commons.io.res.Resource)9 PageContextImpl (lucee.runtime.PageContextImpl)9 StructImpl (lucee.runtime.type.StructImpl)7 PageSource (lucee.runtime.PageSource)6 ConfigServer (lucee.runtime.config.ConfigServer)6 IOException (java.io.IOException)5 CFMLFactory (lucee.runtime.CFMLFactory)5 ConfigWebImpl (lucee.runtime.config.ConfigWebImpl)5 ThreadLocalPageContext (lucee.runtime.engine.ThreadLocalPageContext)5 PageException (lucee.runtime.exp.PageException)5 Struct (lucee.runtime.type.Struct)5 CFMLFactoryImpl (lucee.runtime.CFMLFactoryImpl)4 PageContext (lucee.runtime.PageContext)4 Config (lucee.runtime.config.Config)4 Log (lucee.commons.io.log.Log)3 Pair (lucee.commons.lang.Pair)3 Component (lucee.runtime.Component)3 Query (lucee.runtime.type.Query)3 QueryImpl (lucee.runtime.type.QueryImpl)3