Search in sources :

Example 21 with ConfigWeb

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

the class ComponentImpl method readExternal.

// MUST more native impl
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    boolean pcCreated = false;
    PageContext pc = ThreadLocalPageContext.get();
    try {
        if (pc == null) {
            pcCreated = true;
            ConfigWeb config = (ConfigWeb) ThreadLocalPageContext.getConfig();
            Pair[] parr = new Pair[0];
            pc = ThreadUtil.createPageContext(config, DevNullOutputStream.DEV_NULL_OUTPUT_STREAM, "localhost", "/", "", new Cookie[0], parr, null, parr, new StructImpl(), true, -1);
        }
        // reading fails for serialized data from Lucee version 4.1.2.002
        String name = in.readUTF();
        if (name.startsWith("evaluateComponent('") && name.endsWith("})")) {
            readExternalOldStyle(pc, name);
            return;
        }
        String md5 = in.readUTF();
        Struct _this = Caster.toStruct(in.readObject(), null);
        Struct _var = Caster.toStruct(in.readObject(), null);
        try {
            ComponentImpl other = (ComponentImpl) EvaluateComponent.invoke(pc, name, md5, _this, _var);
            _readExternal(other);
        } catch (PageException e) {
            throw ExceptionUtil.toIOException(e);
        }
    } finally {
        if (pcCreated)
            ThreadLocalPageContext.release();
    }
}
Also used : Cookie(javax.servlet.http.Cookie) PageException(lucee.runtime.exp.PageException) StructImpl(lucee.runtime.type.StructImpl) ThreadLocalPageContext(lucee.runtime.engine.ThreadLocalPageContext) ConfigWeb(lucee.runtime.config.ConfigWeb) Pair(lucee.commons.lang.Pair) Struct(lucee.runtime.type.Struct)

Example 22 with ConfigWeb

use of lucee.runtime.config.ConfigWeb 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 23 with ConfigWeb

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

the class CFMLEngineImpl method onStart.

public void onStart(ConfigImpl config, boolean reload) {
    String context = config instanceof ConfigWeb ? "Web" : "Server";
    if (!ThreadLocalPageContext.callOnStart.get())
        return;
    Resource listenerTemplateLucee = config.getConfigDir().getRealResource("context/" + context + "." + lucee.runtime.config.Constants.getLuceeComponentExtension());
    Resource listenerTemplateCFML = config.getConfigDir().getRealResource("context/" + context + "." + lucee.runtime.config.Constants.getCFMLComponentExtension());
    // dialect
    int dialect;
    if (listenerTemplateLucee.isFile())
        dialect = CFMLEngine.DIALECT_LUCEE;
    else if (listenerTemplateCFML.isFile())
        dialect = CFMLEngine.DIALECT_CFML;
    else
        return;
    // we do not wait for this
    new OnStart(config, dialect, context, reload).start();
}
Also used : Resource(lucee.commons.io.res.Resource) ConfigWeb(lucee.runtime.config.ConfigWeb)

Example 24 with ConfigWeb

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

the class Surveillance method getInfoMemory.

private static void getInfoMemory(Struct parent, ConfigImpl config) throws PageException {
    DoubleStruct server = new DoubleStruct();
    DoubleStruct web = new DoubleStruct();
    parent.set(KeyConstants._server, server);
    parent.set(KeyConstants._web, web);
    boolean isConfigWeb = config instanceof ConfigWeb;
    // web
    if (isConfigWeb) {
        _getInfoMemory(web, server, (ConfigWeb) config);
    } else {
        ConfigWeb[] configs = ((ConfigServer) config).getConfigWebs();
        for (int i = 0; i < configs.length; i++) {
            _getInfoMemory(web, server, configs[i]);
        }
    }
}
Also used : ConfigServer(lucee.runtime.config.ConfigServer) DoubleStruct(lucee.runtime.type.DoubleStruct) ConfigWeb(lucee.runtime.config.ConfigWeb)

Example 25 with ConfigWeb

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

the class RHExtension method readManifestConfig.

private void readManifestConfig(Element el, String label, String _img) throws ApplicationException {
    boolean isWeb = config instanceof ConfigWeb;
    type = isWeb ? "web" : "server";
    Log logger = ((ConfigImpl) config).getLog("deploy");
    Info info = ConfigWebUtil.getEngine(config).getInfo();
    readName(label, el.getAttribute("name"));
    label = name;
    readVersion(label, el.getAttribute("version"));
    label += " : " + version;
    readId(label, el.getAttribute("id"));
    readReleaseType(label, el.getAttribute("release-type"), isWeb);
    description = el.getAttribute("description");
    trial = Caster.toBooleanValue(el.getAttribute("trial"), false);
    if (_img == null)
        _img = el.getAttribute("image");
    image = _img;
    String cat = el.getAttribute("category");
    if (StringUtil.isEmpty(cat, true))
        cat = el.getAttribute("categories");
    readCategories(label, cat);
    readCoreVersion(label, el.getAttribute("lucee-core-version"), info);
    readLoaderVersion(label, el.getAttribute("lucee-loader-version"));
    startBundles = Caster.toBooleanValue(el.getAttribute("start-bundles"), true);
    readAMF(label, el.getAttribute("amf"), logger);
    readResource(label, el.getAttribute("resource"), logger);
    readSearch(label, el.getAttribute("search"), logger);
    readORM(label, el.getAttribute("orm"), logger);
    readMonitor(label, el.getAttribute("monitor"), logger);
    readCache(label, el.getAttribute("cache"), logger);
    readCacheHandler(label, el.getAttribute("cache-handler"), logger);
    readJDBC(label, el.getAttribute("jdbc"), logger);
    readMapping(label, el.getAttribute("mapping"), logger);
    readEventGatewayInstances(label, el.getAttribute("event-gateway-instance"), logger);
}
Also used : Log(lucee.commons.io.log.Log) Info(lucee.Info) BundleInfo(lucee.runtime.osgi.BundleInfo) ConfigWeb(lucee.runtime.config.ConfigWeb) ConfigImpl(lucee.runtime.config.ConfigImpl)

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